summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* all: don't use math.h or link with libm.soThomas Haller2017-03-231-1/+1
|
* lib: escape usage of strerror_l() if it doesn't exist in libcAlexey Brodkin2017-03-121-1/+7
| | | | | | | | | | | | | | | | uClibc doesn't implement strerror_l() and thus libnl starting from 3.2.29 couldn't be compiled with it any longer. To work-around that problem we'll just do a check on strerror_l() availability during configuration and if it's not there just fall back to locale-less strerror(). See-also: 6c2d111177e91184073c44f83d4a6182aaba06d7 http://lists.infradead.org/pipermail/libnl/2017-March/002301.html Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* include: don't include kernel headers in public libnl3 headersThomas Haller2017-03-0211-0/+13
| | | | | | | | | | | | | | | | | It would be desirable not to include kernel headers in our public libnl3 headers. As a test, remove all those includes, and fix compilation by explicitly including the kernel headers where needed. In some cases, that requires forward declaration for kernel structures, as we use them as part of our own headers. Realistically, we cannot drop those includes as it probalby breaks compilation for users that expect to get a certain kernel header when including a libnl3 header. So, this will not be done and the includes will be restored in the next commit. Do this step to show how it would be and to verify that we could build with such a change. The reason not to do this is backward compatibility (at compile-time).
* xfrm: NUL terminate the ctx_str buffer in xfrmnl_sa_set_sec_ctx()Thomas Haller2017-02-272-2/+4
| | | | | | | and xfrmnl_sp_set_sec_ctx(). The user already must pass a NUL terminated string, where the NUL is included in ctx_len. Just allocate one more by and ensure the buffer is '\0' terminated.
* xfrm: allow quering optional arguments from xfrmnl_sp_get_sec_ctx()Thomas Haller2017-02-272-7/+34
| | | | | | | | | | The previous API of xfrmnl_sp_get_sec_ctx() is totally broken, as it requires all out-arguments to be set. The user can thus not know how large the ctx_str buffer must be. Fix the API by allowing all arguments to be optional. Thus, a user can first query the size only, and then in a second step query the ctx_str. Previous version are broken.
* fix of boolean operatorsSimon Buttgereit2017-02-271-4/+4
| | | | | Mixed up boolean operators in commit f38fb7a. This commit is the appropriate fix.
* update documentation of xfrmnl_sp_get_sec_ctxSimon Buttgereit2017-02-271-5/+5
|
* add possibity to delete policy without indexSimon Buttgereit2017-02-271-4/+45
| | | | | security policy can be identified with direction, selector and security context too. Therefore the code to append approptiate data to delete message is added.
* update sp_attr condition in build_xfrm_sp_messageSimon Buttgereit2017-02-271-1/+3
| | | | | | | | Identification of policy are possible with: 1. direction and index 2. direction and selector Theoretically second one needs a security context, but non existing context is valid too.
* little style fixes.Simon Buttgereit2017-02-271-2/+2
|
* fix xfrmnl_sp_set_sec_ctx length attributesSimon Buttgereit2017-02-271-5/+17
| | | | | | Fixed xfrmnl_sp->sec_ctx length parameters in xfrmnl_sp_set_sec_ctx, because former use of only one value wasn't right. Therefore parameter len is unsued and could be removed.
* fix build_xfrm_sp_message index conditionSimon Buttgereit2017-02-271-2/+1
| | | | | Index is not needed and not known if adding a policy. Seems to be copied from build_xfrm_sp_delete_message.
* route: neigh: use NDA_MASTER for neigh->n_master if availableRoopa Prabhu2017-02-271-10/+14
| | | | | | | | | | | | | | fdb cache is per bridge and hence hashed by: <bridge_ifindex, family, mac> newer kernels send bridge ifindex in NDA_MASTER. Use NDA_MASTER for neigh->n_master when available. Also imports a few more NDA_* attributes from upstream to keep linux/neighbour.h NDA_* attributes in sync with upstream. Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
* build: merge lib/Makefile.am into top-level makefileThomas Haller2017-02-271-183/+0
|
* lib: check for integer-overflow in nlmsg_reserve()Thomas Haller2017-02-071-0/+3
| | | | | | | | | | | | | | | In general, libnl functions are not robust against calling with invalid arguments. Thus, never call libnl functions with invalid arguments. In case of nlmsg_reserve() this means never provide a @len argument that causes overflow. Still, add an additional safeguard to avoid exploiting such bugs. Assume that @pad is a trusted, small integer. Assume that n->nm_size is a valid number of allocated bytes (and thus much smaller then SIZE_T_MAX). Assume, that @len may be set to an untrusted value. Then the patch avoids an integer overflow resulting in reserving too few bytes.
* lib: fix comment for nl_recv() about return value for non-blocking readThomas Haller2017-01-201-1/+3
| | | | | | | | Since commit 375a6294a41e003f873821a01d947f0ecfaf76d4, nl_recv() would fail with -NLE_AGAIN if there is nothing to read. Fix the documentation. https://github.com/thom311/libnl/issues/129
* build: Add -Wmissing-prototypes to CPPFLAGSTobias Klauser2017-01-201-1/+1
| | | | | | | | | | Now that all -Wmissing-prototypes warnings are fixed, add it to the default CPPFLAGS. This should hopefully prevent additions of public functions with wrong prototype or no prototype at all to the public header. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* ematch: Add missing function prototypesTobias Klauser2017-01-201-0/+3
| | | | | | | | | Older versions of flex (namely the one used on Travis CI) don't properly emit function prototypes for ematch_get_column() and ematch_set_column(), leading to GCC -Wmissing-prototypes warnings. Fix them by manually adding these prototypes. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* pktloc: Add missing function prototypesTobias Klauser2017-01-201-0/+3
| | | | | | | | | Older versions of flex (namely the one used on Travis CI) don't properly emit function prototypes for pktloc_get_column() and pktloc_set_column(), leading to GCC -Wmissing-prototypes warnings. Fix them by manually adding these prototypes. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* xfrm/template: Include own public header for function prototypesTobias Klauser2017-01-201-1/+2
| | | | | | | | | | | | Include the own public header in order to get function prototypes for all public functions defined in this module. This fixes GCC -Wmissing-prototype warnings. Also adjust the implementation of xfrmnl_user_tmpl_set_family() to match the declaration (family parameter is unsigned int, not int). Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* xfrm/selector: Include own public header for function prototypesTobias Klauser2017-01-201-1/+2
| | | | | | | | | | | | Include the own public header in order to get function prototypes for all public functions defined in this module. This fixes GCC -Wmissing-prototype warnings. Also adjust the implementation of xfrmnl_sel_set_family() to match the declaration (family parameter is unsigned int, not int). Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* xfrm/sa: Include own public header for function prototypesTobias Klauser2017-01-201-0/+1
| | | | | | | | | | | | Include the own public header in order to get function prototypes for all public functions defined in this module. This fixes GCC -Wmissing-prototype warnings. Also adjust the function prototype of xfrmnl_sa_get_sec_ctx() to match the definition. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* xfrm/lifetime: Include own public header for function prototypesTobias Klauser2017-01-201-0/+1
| | | | | | | | | Include the own public header in order to get function prototypes for all public functions defined in this module. This fixes GCC -Wmissing-prototype warnings. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* xfrm/ae: Include own public header for function prototypesTobias Klauser2017-01-201-0/+1
| | | | | | | | | Include the own public header in order to get function prototypes for all public functions defined in this module. This fixes GCC -Wmissing-prototype warnings. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* link/ipgre: Add prototype for ABI-preserving wrapper rtnl_link_get_pmtudisc()Tobias Klauser2017-01-201-0/+4
| | | | | | | | | Avoid a GCC -Wmissing-prototypes warning by explicitely adding a prototype for the ABI-preserving wrapper added in commit 8d04ebf55400 ("lib/route: preserve old ABI for rtnl_link_get_pmtudisc()") and add an explanatory comment. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* link/macsec: Include own public header for function prototypesTobias Klauser2017-01-201-0/+1
| | | | | | | | | Include the own public header in order to get function prototypes for all public functions defined in this module. This fixes GCC -Wmissing-prototype warnings Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* link/ipvti: Include own public header for function prototypesTobias Klauser2017-01-201-0/+1
| | | | | | | | | Include the own public header in order to get function prototypes for all public functions defined in this module. This fixes GCC -Wmissing-prototype warnings. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* link/ipip: Include own public header for function prototypesTobias Klauser2017-01-201-0/+1
| | | | | | | | | Include the own public header in order to get function prototypes for all public functions defined in this module. This fixes GCC -Wmissing-prototype warnings. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* link/inet6: Include own public header for function prototypesTobias Klauser2017-01-201-0/+1
| | | | | | | | | Include the own public header in order to get function prototypes for all public functions defined in this module. This fixes GCC -Wmissing-prototype warnings. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* lib/attr.c: check for valid length argument in nla_reserve()Thomas Haller2017-01-181-2/+9
| | | | https://github.com/thom311/libnl/issues/124
* fopen: add O_CLOEXECNick Kralevich2017-01-174-6/+6
| | | | | | | | | | Add O_CLOEXEC to various fopen() calls. This avoids file descriptors leaking across an exec() boundary in a multi-threaded program. Please see "man 2 open" for additional information about O_CLOEXEC. Signed-off-by: Nick Kralevich <nnk@google.com> https://github.com/thom311/libnl/pull/128
* lib/utils.c: add mutex to get_psched_settings()Thomas Haller2017-01-171-12/+20
| | | | | | | | | Let's add a mutex to get_psched_settings() hoping to solve worst case scenarios when calling get_psched_settings() from multiple threads. Also, only read the environment variables once, who knows whether they are modified concurrently.
* lib/utils.c: ensure calling get_psched_settings() for ↵Thomas Haller2017-01-171-0/+2
| | | | nl_us2ticks()/nl_ticks2us()
* lib/utils.c: lazy initialize user_hz and psched_hzNick Kralevich2017-01-171-1/+8
| | | | | | | | | | | | | | | | | | | | | | | Rather than initializing user_hz and psched_hz when libnl is loaded, defer initialization of these variables to the first time they are used. This has several advantages: 1) Avoids an unnecessary permission denied error on /proc/net/psched, which can occur on systems where /proc/net isn't readable due to security policy. 2) Allows program code to initialize the environment variables PROC_NET_PSCHED and/or PROC_ROOT prior to the first libnl call, giving a program more flexibility about where libnl should look. 3) Trivially faster startup time (although unlikely to be significant). 4) Compiler may be able to prove that the get_psched_settings() function is unreachable and optimize appropriately, because the callers never (directly or indirectly) use this method. This could occur, for instance, in doing dead code elimination for programs which statically link libnl. Signed-off-by: Nick Kralevich <nnk@google.com> https://github.com/thom311/libnl/pull/123
* sriov: avoid buffer overrun in rtnl_link_sriov_parse_vflist()Thomas Haller2017-01-171-0/+2
| | | | | | Fixes: 5d6e43ebef12deadf31fccfa46c0b34892675d36 Signed-off-by: Thomas Haller <thaller@redhat.com>
* sriov: fix crash in rtnl_link_sriov_parse_vflistLaine Stump2017-01-171-1/+1
| | | | | | | | | | | | | vf_vlan_info was incorrectly indexed with "len" (the length in bytes of the entire vfinfo_list rather than list_len (the index of the current end of the vf_vlan_info array) https://github.com/thom311/libnl/issues/126 http://lists.infradead.org/pipermail/libnl/2017-January/002270.html Fixes: 5d6e43ebef12deadf31fccfa46c0b34892675d36 Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/tc: Remove unused function tca_set_kind()Tobias Klauser2017-01-131-6/+0
| | | | | | | | | | | | The public prototype and the last internal user of the function were removed in commit 8eb5b5532e ("Unified TC API") and it was unexported in commit 4280dfb85d ("build: don't export internal symbols"), so it is safe to remove it. Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Thomas Haller <thaller@redhat.com> https://github.com/thom311/libnl/pull/122
* libnl-3.2.29 releaselibnl3_2_29Thomas Haller2016-12-301-0/+9
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* macsec: fix endianness of sci during dump()Thomas Haller2016-12-151-2/+2
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* macsec: document byte order for the SCI and port attributesBeniamino Galvani2016-12-151-1/+63
| | | | | | | | Document that the SCI is in network order while the port is in host order. Signed-off-by: Beniamino Galvani <bgalvani@redhat.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* Revert "macsec: fix endianness of 'sci' parameter"Beniamino Galvani2016-12-151-2/+2
| | | | | | | | | | The commit changed the API from libnl 3.2.28: restore the old behavior. This reverts commit cd758fbfee07768ff200f46d7090fa8d0e6b300f. Signed-off-by: Beniamino Galvani <bgalvani@redhat.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* utils/trivial: rename internal _nl_offset_plus_sizeof() macro to ↵Thomas Haller2016-12-151-5/+5
| | | | | | | | | _nl_offsetofend() Kernel calls a very similar macro "offsetofend". So use that name as it migth be more familiar to the reader. Signed-off-by: Thomas Haller <thaller@redhat.com>
* link: fix documentation for rtnl_link_get_carrier_changesTobias Klauser2016-12-061-1/+2
| | | | | | | | | | | The doxygen comment of rtnl_link_get_carrier_changes still describes the initially implemented behaviour and was not updated, when the signature was changed as part of #119. Adjust it accordingly. Fixes: 0c4b2ea6d17b ("link: add support for IFLA_CARRIER_CHANGES") Signed-off-by: Tobias Klauser <tklauser@distanz.ch> https://github.com/thom311/libnl/pull/120
* link: add support for IFLA_GSO_MAX_SEGS and IFLA_GSO_MAX_SIZETobias Klauser2016-12-061-0/+52
| | | | Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* link: add support for IFLA_PHYS_SWITCH_IDTobias Klauser2016-12-061-0/+28
| | | | Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* link: add support for IFLA_PHYS_PORT_NAMETobias Klauser2016-12-061-0/+19
| | | | Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* link: add support for IFLA_CARRIER_CHANGESTobias Klauser2016-12-061-2/+30
| | | | | | Also expose the attribute value via link_dump_details() Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* route/act: add gact tc actionSushma Sitaram2016-12-022-0/+184
| | | | | | | Signed-off-by: Sushma Sitaram <sushma.sitaram@intel.com> Signed-off-by: Thomas Haller <thaller@redhat.com> http://lists.infradead.org/pipermail/libnl/2016-November/002249.html
* cache: fix GCC warning and avoid variable shadowingTobias Klauser2016-12-021-2/+2
| | | | | | | | | | | | | | | | | | | Fix the following GCC warning, introduced in commit 66d032ad443a ("cache_mngr: add include callback v2"): cache.c: In function ‘cache_include.isra.3’: cache.c:810:6: warning: ‘diff’ may be used uninitialized in this function [-Wmaybe-uninitialized] cb_v2(cache, clone, obj, diff, ^ Also don't redeclare the uint64_t diff variable, to avoid shadowing. Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Thomas Haller <thaller@redhat.com> Fixes: 66d032ad443a9d67bd26ed3e801cddf9f0e71ae7 http://lists.infradead.org/pipermail/libnl/2016-December/002258.html
* cache_mngr: add include callback v2Tobias Jungel2016-12-013-18/+190
| | | | | | | | | | | | | | | | | | | | | This patch adds change_func_v2_t to add a more detailed callback in case of a cache change. The change function is registered using the new nl_cache_mngr_add_cache_v2. In case the new change function is set, nl_cache_include_v2 and thus cache_include_v2 will be used to perform the cache inclusion. The parameter of change_func_v2_t are the following: * struct nl_cache * => cache * struct nl_object * => the old/deleted nl_object * struct nl_object * => the new nl_object * uint64_t => the result of nl_object_diff64 in case of a change * int => NL_ACT_* * void * => data https://github.com/thom311/libnl/issues/71 http://lists.infradead.org/pipermail/libnl/2016-September/002214.html http://lists.infradead.org/pipermail/libnl/2016-October/002229.html http://lists.infradead.org/pipermail/libnl/2016-November/002250.html