]> granicus.if.org Git - libnl/log
libnl
7 years agobuild: merge src/Makefile.am into top-level makefile
Thomas Haller [Sun, 26 Feb 2017 20:25:28 +0000 (21:25 +0100)]
build: merge src/Makefile.am into top-level makefile

7 years agobuild: merge src/lib/Makefile.am into top-level makefile
Thomas Haller [Sun, 26 Feb 2017 20:25:28 +0000 (21:25 +0100)]
build: merge src/lib/Makefile.am into top-level makefile

7 years agobuild: merge tests/Makefile.am into top-level makefile
Thomas Haller [Sun, 26 Feb 2017 20:25:28 +0000 (21:25 +0100)]
build: merge tests/Makefile.am into top-level makefile

7 years agobuild: merge python/Makefile.am into top-level makefile
Thomas Haller [Sun, 26 Feb 2017 20:05:37 +0000 (21:05 +0100)]
build: merge python/Makefile.am into top-level makefile

7 years agobuild: merge man/Makefile.am into top-level makefile
Thomas Haller [Sun, 26 Feb 2017 19:55:13 +0000 (20:55 +0100)]
build: merge man/Makefile.am into top-level makefile

7 years agobuild: merge lib/Makefile.am into top-level makefile
Thomas Haller [Sun, 26 Feb 2017 19:19:14 +0000 (20:19 +0100)]
build: merge lib/Makefile.am into top-level makefile

7 years agobuild: merge include/Makefile.am into top-level makefile
Thomas Haller [Sun, 26 Feb 2017 18:49:18 +0000 (19:49 +0100)]
build: merge include/Makefile.am into top-level makefile

7 years agobuild: cleanup top-level Makefile.am
Thomas Haller [Sun, 26 Feb 2017 18:47:10 +0000 (19:47 +0100)]
build: cleanup top-level Makefile.am

7 years agolib: check for integer-overflow in nlmsg_reserve()
Thomas Haller [Mon, 6 Feb 2017 21:23:52 +0000 (22:23 +0100)]
lib: check for integer-overflow in nlmsg_reserve()

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.

7 years agolib: fix comment for nl_recv() about return value for non-blocking read
Thomas Haller [Fri, 20 Jan 2017 12:36:28 +0000 (13:36 +0100)]
lib: fix comment for nl_recv() about return value for non-blocking read

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

7 years agoall: merge branch 'tklauser-missing-prototypes'
Thomas Haller [Fri, 20 Jan 2017 11:54:29 +0000 (12:54 +0100)]
all: merge branch 'tklauser-missing-prototypes'

https://github.com/thom311/libnl/pull/125

7 years agobuild: distribute in.h in6.h libc-compat.h
Jeroen Roovers [Fri, 20 Jan 2017 09:41:36 +0000 (10:41 +0100)]
build: distribute in.h in6.h libc-compat.h

https://github.com/thom311/libnl/pull/130
Related: https://github.com/thom311/libnl/pull/127
Related: https://github.com/thom311/libnl/pull/121

7 years agobuild: Add -Wmissing-prototypes to CPPFLAGS
Tobias Klauser [Mon, 16 Jan 2017 14:06:47 +0000 (15:06 +0100)]
build: Add -Wmissing-prototypes to CPPFLAGS

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>
7 years agoematch: Add missing function prototypes
Tobias Klauser [Tue, 17 Jan 2017 08:22:01 +0000 (09:22 +0100)]
ematch: Add missing function prototypes

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>
7 years agopktloc: Add missing function prototypes
Tobias Klauser [Tue, 17 Jan 2017 07:56:03 +0000 (08:56 +0100)]
pktloc: Add missing function prototypes

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>
7 years agoxfrm/template: Include own public header for function prototypes
Tobias Klauser [Mon, 16 Jan 2017 14:38:58 +0000 (15:38 +0100)]
xfrm/template: Include own public header for function prototypes

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>
7 years agoxfrm/selector: Include own public header for function prototypes
Tobias Klauser [Tue, 17 Jan 2017 07:27:20 +0000 (08:27 +0100)]
xfrm/selector: Include own public header for function prototypes

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>
7 years agoxfrm/sa: Include own public header for function prototypes
Tobias Klauser [Tue, 17 Jan 2017 07:26:02 +0000 (08:26 +0100)]
xfrm/sa: Include own public header for function prototypes

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>
7 years agoxfrm/lifetime: Include own public header for function prototypes
Tobias Klauser [Tue, 17 Jan 2017 07:25:30 +0000 (08:25 +0100)]
xfrm/lifetime: Include own public header for function prototypes

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>
7 years agoxfrm/ae: Include own public header for function prototypes
Tobias Klauser [Tue, 17 Jan 2017 07:24:03 +0000 (08:24 +0100)]
xfrm/ae: Include own public header for function prototypes

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>
7 years agoidiag/req: Add missing function prototype
Tobias Klauser [Tue, 17 Jan 2017 07:21:56 +0000 (08:21 +0100)]
idiag/req: Add missing function prototype

Add missing function prototype for idiagnl_req_parse() to the public
header.

This fixes the following GCC warning when compiling with
-Wmissing-prototypes:

  idiag/idiag_req_obj.c:189:5: warning: no previous prototype for ‘idiagnl_req_parse’ [-Wmissing-prototypes]

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
7 years agonetfilter/exp: Add missing function prototypes
Tobias Klauser [Mon, 16 Jan 2017 14:43:08 +0000 (15:43 +0100)]
netfilter/exp: Add missing function prototypes

Add missing function prototypes for nfnl_exp_unset_flags(),
nfnl_exp_flags2str() and nfnl_exp_str2flags() to the public header.

This fixes the following GCC warnings when compiling with
-Wmissing-prototypes:

  netfilter/exp_obj.c:458:6: warning: no previous prototype for ‘nfnl_exp_unset_flags’ [-Wmissing-prototypes]
  netfilter/exp_obj.c:475:8: warning: no previous prototype for ‘nfnl_exp_flags2str’ [-Wmissing-prototypes]
  netfilter/exp_obj.c:481:5: warning: no previous prototype for ‘nfnl_exp_str2flags’ [-Wmissing-prototypes]

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
7 years agonetfilter/queue: Add missing prototype for nfnl_queue_msg_build_verdict_batch()
Tobias Klauser [Mon, 16 Jan 2017 14:27:48 +0000 (15:27 +0100)]
netfilter/queue: Add missing prototype for nfnl_queue_msg_build_verdict_batch()

Add the function prototype for nfnl_queue_msg_build_verdict_batch() to
the public header.

This fixes the following GCC warning when building with
-Wmissing-prototypes:

  netfilter/queue_msg.c:190:1: warning: no previous prototype for ‘nfnl_queue_msg_build_verdict_batch’ [-Wmissing-prototypes]

Fixes: d612180cda43 ("netfilter/queue: introduce nfnl_queue_msg_send_verdict_batch()")
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
7 years agolink/ipgre: Add prototype for ABI-preserving wrapper rtnl_link_get_pmtudisc()
Tobias Klauser [Mon, 16 Jan 2017 14:21:35 +0000 (15:21 +0100)]
link/ipgre: Add prototype for ABI-preserving wrapper rtnl_link_get_pmtudisc()

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>
7 years agolink/sit: Add missing prototype for rtnl_link_is_sit()
Tobias Klauser [Mon, 16 Jan 2017 14:10:43 +0000 (15:10 +0100)]
link/sit: Add missing prototype for rtnl_link_is_sit()

Add the function prototype for rtnl_link_is_ipip() to the public header.

This fixes the following GCC warning when compiling with
-Wmissing-prototypes:

  route/link/sit.c:400:5: warning: no previous prototype for ‘rtnl_link_is_sit’ [-Wmissing-prototypes]

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
7 years agolink/macsec: Include own public header for function prototypes
Tobias Klauser [Mon, 16 Jan 2017 14:06:12 +0000 (15:06 +0100)]
link/macsec: Include own public header for function prototypes

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>
7 years agolink/ipvti: Fix and add function prototypes in public header
Tobias Klauser [Mon, 16 Jan 2017 13:58:20 +0000 (14:58 +0100)]
link/ipvti: Fix and add function prototypes in public header

Add missing "_ipvti" part to function prototypes so they match the
exported name. Also add the missing prototype for rtnl_link_is_ipvti().

This fixes the following GCC warnings when compiling with
-Wmissing-prototypes:

  route/link/ipvti.c:281:5: warning: no previous prototype for ‘rtnl_link_is_ipvti’ [-Wmissing-prototypes]
  route/link/ipvti.c:369:10: warning: no previous prototype for ‘rtnl_link_ipvti_get_ikey’ [-Wmissing-prototypes]
  route/link/ipvti.c:403:10: warning: no previous prototype for ‘rtnl_link_ipvti_get_okey’ [-Wmissing-prototypes]
  route/link/ipvti.c:437:10: warning: no previous prototype for ‘rtnl_link_ipvti_get_local’ [-Wmissing-prototypes]
  route/link/ipvti.c:471:10: warning: no previous prototype for ‘rtnl_link_ipvti_get_remote’ [-Wmissing-prototypes]

Also fix the corresponding names in documentation.

Fixes: 8f6301426a00 ("ipvti: introduce vti tunnel support")
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
7 years agolink/ipvti: Include own public header for function prototypes
Tobias Klauser [Mon, 16 Jan 2017 13:51:11 +0000 (14:51 +0100)]
link/ipvti: Include own public header for function prototypes

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>
7 years agolink/ipip: Add missing prototype for rtnl_link_is_ipip()
Tobias Klauser [Mon, 16 Jan 2017 13:54:49 +0000 (14:54 +0100)]
link/ipip: Add missing prototype for rtnl_link_is_ipip()

Add the function prototype for rtnl_link_is_ipip() to the public header.

This fixes the following GCC warning when compiling with
-Wmissing-prototypes:

  route/link/ipip.c:296:5: warning: no previous prototype for ‘rtnl_link_is_ipip’ [-Wmissing-prototypes]

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
7 years agolink/ipip: Include own public header for function prototypes
Tobias Klauser [Mon, 16 Jan 2017 13:50:37 +0000 (14:50 +0100)]
link/ipip: Include own public header for function prototypes

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>
7 years agolink/inet6: Include own public header for function prototypes
Tobias Klauser [Mon, 16 Jan 2017 13:49:09 +0000 (14:49 +0100)]
link/inet6: Include own public header for function prototypes

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>
7 years agofib_lookup: Add missing prototypes to public header
Tobias Klauser [Mon, 16 Jan 2017 13:42:57 +0000 (14:42 +0100)]
fib_lookup: Add missing prototypes to public header

Add the function prototypes for the struct flnl_result attribute access
functions to the public header fib_lookup/lookup.h

This fixes the following GCC warnings when compiling with
-Wmissing-prototypes:

  fib_lookup/lookup.c:284:5: warning: no previous prototype for ‘flnl_result_get_table_id’ [-Wmissing-prototypes]
  fib_lookup/lookup.c:289:5: warning: no previous prototype for ‘flnl_result_get_prefixlen’ [-Wmissing-prototypes]
  fib_lookup/lookup.c:294:5: warning: no previous prototype for ‘flnl_result_get_nexthop_sel’ [-Wmissing-prototypes]
  fib_lookup/lookup.c:299:5: warning: no previous prototype for ‘flnl_result_get_type’ [-Wmissing-prototypes]
  fib_lookup/lookup.c:304:5: warning: no previous prototype for ‘flnl_result_get_scope’ [-Wmissing-prototypes]
  fib_lookup/lookup.c:309:5: warning: no previous prototype for ‘flnl_result_get_error’ [-Wmissing-prototypes]

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
7 years agoqdisc/red: Add missing prototypes for rtnl_red_set_limit() and rtnl_red_get_limit()
Tobias Klauser [Mon, 16 Jan 2017 13:35:36 +0000 (14:35 +0100)]
qdisc/red: Add missing prototypes for rtnl_red_set_limit() and rtnl_red_get_limit()

This fixes the following GCC warnings when compiling with
-Wmissing-prototypes:

  route/qdisc/red.c:136:6: warning: no previous prototype for ‘rtnl_red_set_limit’ [-Wmissing-prototypes]
  route/qdisc/red.c:152:5: warning: no previous prototype for ‘rtnl_red_get_limit’ [-Wmissing-prototypes]

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
7 years agosriov: Add missing prototype for rtnl_link_vf_vlan_free()
Tobias Klauser [Mon, 16 Jan 2017 13:09:48 +0000 (14:09 +0100)]
sriov: Add missing prototype for rtnl_link_vf_vlan_free()

Add missing function prototyoe for rtnl_link_vf_vlan_free() to the
public header.

This fixes the following GCC warning when compiling with
-Wmissing-prototypes:

  route/link/sriov.c:1339:6: warning: no previous prototype for ‘rtnl_link_vf_vlan_free’ [-Wmissing-prototypes]

Fixes: 5d6e43ebef12 ("lib/route: SRIOV Parse and Read support")
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
7 years agosit: Fix invalid function prototypes in public header
Tobias Klauser [Mon, 16 Jan 2017 13:03:39 +0000 (14:03 +0100)]
sit: Fix invalid function prototypes in public header

Change rtnl_link_get_sit_local() rtnl_link_sit_get_local() as this is
the function's exported name.

This fixes a GCC -Wmissing-prototypes warning.

Fixes: d715b8a5f6ec ("introduce sit tunnel support")
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
7 years agolib/attr.c: check for valid length argument in nla_reserve()
Thomas Haller [Wed, 18 Jan 2017 10:59:23 +0000 (11:59 +0100)]
lib/attr.c: check for valid length argument in nla_reserve()

https://github.com/thom311/libnl/issues/124

7 years agofopen: add O_CLOEXEC
Nick Kralevich [Tue, 17 Jan 2017 18:56:52 +0000 (10:56 -0800)]
fopen: add O_CLOEXEC

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

7 years agolib/utils.c: merge branch 'nickkral-psched_lazy'
Thomas Haller [Tue, 17 Jan 2017 17:55:12 +0000 (18:55 +0100)]
lib/utils.c: merge branch 'nickkral-psched_lazy'

https://github.com/thom311/libnl/pull/123

7 years agolib/utils.c: add mutex to get_psched_settings()
Thomas Haller [Tue, 17 Jan 2017 17:49:42 +0000 (18:49 +0100)]
lib/utils.c: add mutex to get_psched_settings()

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.

7 years agolib/utils.c: ensure calling get_psched_settings() for nl_us2ticks()/nl_ticks2us()
Thomas Haller [Tue, 17 Jan 2017 17:32:08 +0000 (18:32 +0100)]
lib/utils.c: ensure calling get_psched_settings() for nl_us2ticks()/nl_ticks2us()

7 years agolib/utils.c: lazy initialize user_hz and psched_hz
Nick Kralevich [Sat, 14 Jan 2017 19:11:34 +0000 (11:11 -0800)]
lib/utils.c: lazy initialize user_hz and psched_hz

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

7 years agosriov: merge branch 'sriov-crash-issue126'
Thomas Haller [Tue, 17 Jan 2017 17:16:27 +0000 (18:16 +0100)]
sriov: merge branch 'sriov-crash-issue126'

https://github.com/thom311/libnl/issues/126
http://lists.infradead.org/pipermail/libnl/2017-January/002270.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agosriov: avoid buffer overrun in rtnl_link_sriov_parse_vflist()
Thomas Haller [Tue, 17 Jan 2017 17:16:11 +0000 (18:16 +0100)]
sriov: avoid buffer overrun in rtnl_link_sriov_parse_vflist()

Fixes: 5d6e43ebef12deadf31fccfa46c0b34892675d36
Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agosriov: fix crash in rtnl_link_sriov_parse_vflist
Laine Stump [Tue, 17 Jan 2017 15:47:34 +0000 (10:47 -0500)]
sriov: fix crash in rtnl_link_sriov_parse_vflist

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>
7 years agoroute/tc: Remove unused function tca_set_kind()
Tobias Klauser [Fri, 13 Jan 2017 17:18:20 +0000 (18:18 +0100)]
route/tc: Remove unused function tca_set_kind()

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

7 years agolibnl-3.2.29 release libnl3_2_29
Thomas Haller [Fri, 30 Dec 2016 14:57:00 +0000 (15:57 +0100)]
libnl-3.2.29 release

Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agomacsec: merge branch 'macsec-sci-endianness'
Thomas Haller [Fri, 16 Dec 2016 08:29:05 +0000 (09:29 +0100)]
macsec: merge branch 'macsec-sci-endianness'

Revert API change regarding endianness of MACSec's 'sci'
argument. During 3.2.29 development, that was changed. Restore
the released 3.2.28 behavior.

http://lists.infradead.org/pipermail/libnl/2016-December/002264.html

8 years agomacsec: fix endianness of sci during dump()
Thomas Haller [Thu, 15 Dec 2016 18:23:26 +0000 (19:23 +0100)]
macsec: fix endianness of sci during dump()

Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agomacsec: document byte order for the SCI and port attributes
Beniamino Galvani [Thu, 15 Dec 2016 13:41:55 +0000 (14:41 +0100)]
macsec: document byte order for the SCI and port attributes

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>
8 years agoRevert "macsec: fix endianness of 'sci' parameter"
Beniamino Galvani [Thu, 15 Dec 2016 13:41:54 +0000 (14:41 +0100)]
Revert "macsec: fix endianness of 'sci' parameter"

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>
8 years agoutils/trivial: rename internal _nl_offset_plus_sizeof() macro to _nl_offsetofend()
Thomas Haller [Thu, 15 Dec 2016 18:31:21 +0000 (19:31 +0100)]
utils/trivial: rename internal _nl_offset_plus_sizeof() macro to _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>
8 years agolibnl-3.2.29-rc1 release libnl3_2_29rc1
Thomas Haller [Mon, 12 Dec 2016 14:10:21 +0000 (15:10 +0100)]
libnl-3.2.29-rc1 release

Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agolink: fix documentation for rtnl_link_get_carrier_changes
Tobias Klauser [Tue, 6 Dec 2016 14:22:11 +0000 (15:22 +0100)]
link: fix documentation for rtnl_link_get_carrier_changes

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

8 years agolink: merge branch 'rtnl-attrs'
Thomas Haller [Tue, 6 Dec 2016 14:14:16 +0000 (15:14 +0100)]
link: merge branch 'rtnl-attrs'

https://github.com/thom311/libnl/pull/119

8 years agolink: add support for IFLA_GSO_MAX_SEGS and IFLA_GSO_MAX_SIZE
Tobias Klauser [Tue, 6 Dec 2016 11:03:16 +0000 (12:03 +0100)]
link: add support for IFLA_GSO_MAX_SEGS and IFLA_GSO_MAX_SIZE

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
8 years agolink: add support for IFLA_PHYS_SWITCH_ID
Tobias Klauser [Tue, 6 Dec 2016 11:03:10 +0000 (12:03 +0100)]
link: add support for IFLA_PHYS_SWITCH_ID

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
8 years agolink: add support for IFLA_PHYS_PORT_NAME
Tobias Klauser [Tue, 6 Dec 2016 11:03:05 +0000 (12:03 +0100)]
link: add support for IFLA_PHYS_PORT_NAME

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
8 years agolink: add support for IFLA_CARRIER_CHANGES
Tobias Klauser [Tue, 6 Dec 2016 11:02:54 +0000 (12:02 +0100)]
link: add support for IFLA_CARRIER_CHANGES

Also expose the attribute value via link_dump_details()

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
8 years agoroute/act: add gact tc action
Sushma Sitaram [Thu, 10 Nov 2016 22:47:53 +0000 (14:47 -0800)]
route/act: add gact tc action

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

8 years agocache: fix GCC warning and avoid variable shadowing
Tobias Klauser [Fri, 2 Dec 2016 10:46:51 +0000 (11:46 +0100)]
cache: fix GCC warning and avoid variable shadowing

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

8 years agocache_mngr: add include callback v2
Tobias Jungel [Sun, 13 Nov 2016 14:21:46 +0000 (15:21 +0100)]
cache_mngr: add include callback v2

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

8 years agolib: use MSG_PEEK by default for nl_recvmsgs()
Thomas Haller [Wed, 30 Nov 2016 14:09:41 +0000 (15:09 +0100)]
lib: use MSG_PEEK by default for nl_recvmsgs()

The MSG_PEEK API of recvmsg() should be avoid because it requires an additional
syscall. But worse is to choose a too small buffer size and failing to receive
the message.

A user who is aware of the issue can avoid MSG_PEEK by either
nl_socket_disable_msg_peek()/nl_socket_enable_msg_peek() or by setting
a buffer size via nl_socket_set_msg_buf_size().

By default however we now use MSG_PEEK. This is more important since commit
90c6ebec9bd7a where the link dump request can be rather large.

Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agolink: set ifi_change flags for rtnl_link_build_add_request()
Thomas Haller [Tue, 29 Nov 2016 21:41:46 +0000 (22:41 +0100)]
link: set ifi_change flags for rtnl_link_build_add_request()

For the add-request, we should set ifi_change flags together with the
ifi_flags. A similar thing is done by rtnl_link_build_change_request()
in commit 34ccb7210f1238f89229c117dc3d28cea7ae00bb.

https://github.com/thom311/libnl/issues/111

8 years agolib/route: merge branch 'link-stats-rxnohandler'
Thomas Haller [Tue, 29 Nov 2016 11:41:42 +0000 (12:41 +0100)]
lib/route: merge branch 'link-stats-rxnohandler'

https://github.com/thom311/libnl/pull/117

8 years agolib/route: pass sizeof() argument to nl_memcpy()
Thomas Haller [Tue, 29 Nov 2016 11:38:03 +0000 (12:38 +0100)]
lib/route: pass sizeof() argument to nl_memcpy()

nl_memcpy() internally already never copies more then
nla_len(tb). The previous code might overflow if the
netlink attribute is longer then the size of the destination.

Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agonl-link-stats: prefer RTNL_LINK_STATS_MAX over __RTNL_LINK_STATS_MAX
Thomas Haller [Tue, 29 Nov 2016 11:33:27 +0000 (12:33 +0100)]
nl-link-stats: prefer RTNL_LINK_STATS_MAX over __RTNL_LINK_STATS_MAX

The result is basically the same, but I feel that __RTNL_LINK_STATS_MAX
is an internal variable that shouldn't be used. Thus, let's iterate
instead until <= MAX.

Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agolib/route: add rx_nohandler link stats field
Tobias Klauser [Tue, 29 Nov 2016 07:50:31 +0000 (08:50 +0100)]
lib/route: add rx_nohandler link stats field

A new counter rx_nohandler was added to the link stats in kernel commit
6e7333d315a7 ("net: add rx_nohandler stat counter"). Wire it up in the
libnl link stats as well.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
8 years agosrc: nl-link-stats: use correct rtnl link stats maximum
Tobias Klauser [Tue, 29 Nov 2016 08:13:01 +0000 (09:13 +0100)]
src: nl-link-stats: use correct rtnl link stats maximum

Use __RTNL_LINK_STATS_MAX instead of RTNL_LINK_STATS_MAX when iterating
over all rtnl link stat counters. Otherwise, the last stat counter will
always be missing, as RTNL_LINK_STATS_MAX is the value of the last valid
index.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
8 years agoroute/cls: support setting of selector fields
Sushma Sitaram [Fri, 21 Oct 2016 21:06:39 +0000 (14:06 -0700)]
route/cls: support setting of selector fields

Enables to set the shift, offset, mask and flags of the position to next header

http://lists.infradead.org/pipermail/libnl/2016-September/002227.html
http://lists.infradead.org/pipermail/libnl/2016-October/002232.html

Signed-off-by: Sushma Sitaram <sushma.sitaram@intel.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agolib/ppp: merge branch 'ppp-support'
Thomas Haller [Mon, 28 Nov 2016 21:26:15 +0000 (22:26 +0100)]
lib/ppp: merge branch 'ppp-support'

https://github.com/thom311/libnl/pull/112

Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agoppp: fix API in ppp.h header
Thomas Haller [Mon, 28 Nov 2016 21:24:15 +0000 (22:24 +0100)]
ppp: fix API in ppp.h header

Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agoppp: fix type of file descriptor; uint32_t -> int32_t
Jonas Johansson [Mon, 7 Nov 2016 07:58:03 +0000 (08:58 +0100)]
ppp: fix type of file descriptor; uint32_t -> int32_t

Signed-off-by: Jonas Johansson <jonasj76@gmail.com>
8 years agoppp: rename local struct ppp_info* variables; pi -> info
Jonas Johansson [Mon, 7 Nov 2016 07:43:21 +0000 (08:43 +0100)]
ppp: rename local struct ppp_info* variables; pi -> info

Signed-off-by: Jonas Johansson <jonasj76@gmail.com>
8 years agoppp: update code after review
Jonas Johansson [Mon, 7 Nov 2016 07:25:08 +0000 (08:25 +0100)]
ppp: update code after review

Signed-off-by: Jonas Johansson <jonasj76@gmail.com>
8 years agoAdd PPP support
Jonas Johansson [Wed, 26 Oct 2016 14:30:52 +0000 (16:30 +0200)]
Add PPP support

This patch add support for kernel PPP interfaces.

Signed-off-by: Jonas Johansson <jonasj76@gmail.com>
8 years agolib/router: merge branch 'rtnl-link-policy-minlen'
Thomas Haller [Mon, 28 Nov 2016 20:51:03 +0000 (21:51 +0100)]
lib/router: merge branch 'rtnl-link-policy-minlen'

https://github.com/thom311/libnl/pull/116

Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agolib/route: use _nl_offset_plus_sizeof() macro for minlen field for rtln_link_policy
Thomas Haller [Mon, 28 Nov 2016 20:42:39 +0000 (21:42 +0100)]
lib/route: use _nl_offset_plus_sizeof() macro for minlen field for rtln_link_policy

Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agoutils: add internal _nl_offset_plus_sizeof() macro
Thomas Haller [Mon, 28 Nov 2016 20:39:34 +0000 (21:39 +0100)]
utils: add internal _nl_offset_plus_sizeof() macro

Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agolib/route: keep link stats minlen compatible with kernel < 4.6
Tobias Klauser [Tue, 15 Nov 2016 15:35:48 +0000 (16:35 +0100)]
lib/route: keep link stats minlen compatible with kernel < 4.6

Since linux/if_link.h was synced in libnl commit d533736e2258 ("vxlan:
add support for additional VXLAN attributes."), the minlen check in
validate_nla() fails on kernels < 4.6 - or more precisely, on kernels
not containing kernel commit 6e7333d315a7 ("net: add rx_nohandler stat
counter"). The check fails because rtnl_link_stats and rtnl_link_stats64
sent by the kernel don't have the rx_nohandler member yet, but libnl
expects them to have it.

Account for this by decreasing the minlen by one member and add an
explanatory comment.

https://github.com/thom311/libnl/pull/116

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agolib/sriov: merge branch 'sriov'
Thomas Haller [Mon, 28 Nov 2016 20:21:27 +0000 (21:21 +0100)]
lib/sriov: merge branch 'sriov'

http://lists.infradead.org/pipermail/libnl/2016-November/002234.html
http://lists.infradead.org/pipermail/libnl/2016-November/002243.html

8 years agoroute: remove symbols of internal API from ABI
Thomas Haller [Thu, 24 Nov 2016 12:32:20 +0000 (13:32 +0100)]
route: remove symbols of internal API from ABI

Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agolib/route: SRIOV Set Functionality
Jef Oliver [Mon, 7 Nov 2016 21:33:58 +0000 (13:33 -0800)]
lib/route: SRIOV Set Functionality

* This patch adds functionality to set attributes on an SRIOV
  VF object.
* This patch adds functionality to append attributes to the
  link change request sent to the kernel.

Signed-off-by: Jef Oliver <jef.oliver@intel.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agolib/route: SRIOV Info Dump Functions
Jef Oliver [Mon, 7 Nov 2016 21:33:57 +0000 (13:33 -0800)]
lib/route: SRIOV Info Dump Functions

This patch adds functions to dump information and stats for each
SRIOV VF.

Signed-off-by: Jef Oliver <jef.oliver@intel.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agolib/route: SRIOV Utility Functions
Jef Oliver [Mon, 7 Nov 2016 21:33:56 +0000 (13:33 -0800)]
lib/route: SRIOV Utility Functions

This patch adds utility functions for translating link state and
VLAN protocols for SRIOV VFs.

Signed-off-by: Jef Oliver <jef.oliver@intel.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agolib/route: SRIOV Clone Support
Jef Oliver [Mon, 7 Nov 2016 21:33:55 +0000 (13:33 -0800)]
lib/route: SRIOV Clone Support

This patch adds support for cloning SRIOV VF specific data in the
link object.

Signed-off-by: Jef Oliver <jef.oliver@intel.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agolib/route: SRIOV Parse and Read support
Jef Oliver [Mon, 7 Nov 2016 21:33:54 +0000 (13:33 -0800)]
lib/route: SRIOV Parse and Read support

* This patch adds support for parsing SRIOV VF specific
  information on a link.
  * Adds LINK_ATTR_VF_LIST to add to link->ce_mask.
  * Extends the rtnl_link object to include 'l_vf_list', a member
    to carry information for SRIOV VFs.
  * Adds rtnl_link_sriov, a private structure to fill link->l_vf_list.

* This patch adds support for reading parsed SRIOV VF specific
  informatino on a link.

* This patch adds support for freeing stored SRIOV VF specific
  information on a link.

Signed-off-by: Jef Oliver <jef.oliver@intel.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
8 years agoxfrm: merge branch 'spellingmistake-fix_xfrm_sec_ctx'
Thomas Haller [Sun, 6 Nov 2016 21:22:42 +0000 (22:22 +0100)]
xfrm: merge branch 'spellingmistake-fix_xfrm_sec_ctx'

https://github.com/thom311/libnl/pull/113
https://github.com/thom311/libnl/pull/114

8 years agoxfrm: remove unused struct xfrmnl_sec_ctx from header files
Thomas Haller [Sun, 6 Nov 2016 21:07:11 +0000 (22:07 +0100)]
xfrm: remove unused struct xfrmnl_sec_ctx from header files

8 years agoxfrm: add capability reference to xfrmnl_sa_set_*
Thomas Egerer [Sun, 6 Nov 2016 20:34:50 +0000 (21:34 +0100)]
xfrm: add capability reference to xfrmnl_sa_set_*

Just for consistency(tm)'s sake: add the reference to what capability
introduced the modified API.

Signed-off-by: Thomas Egerer <hakke_007@gmx.de>
8 years agoxfrm: fix xfrm security context management
Thomas Egerer [Tue, 25 Oct 2016 15:38:19 +0000 (17:38 +0200)]
xfrm: fix xfrm security context management

The data structure of choice when adding/processing a security context
for xfrm is struct xfrm(nl)_user_sec_ctx. The previous code did however
use the (also exported) struct xfrm(nl)_sec_ctx. While sizeof(struct
xfrm(nl)_*sec_ctx) yields the same result, the interpretation of one of
the data structures as the other one messes up the contents.
With this fix, the wrong data structure has been replaced with the
correct one. Also -- since the size of the context string is not known
-- one can now call xfrmnl_sa_get_sec_ctx with ctx_str being NULL, thus
retrieving the length of the context string.
A new capability has been introduced, to test whether libnl3 supports
the modified semantics of this function.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
8 years agoroute/ipgre: merge branch 'route_ipgre_api'
Thomas Haller [Sat, 5 Nov 2016 17:14:23 +0000 (18:14 +0100)]
route/ipgre: merge branch 'route_ipgre_api'

http://lists.infradead.org/pipermail/libnl/2016-October/002228.html

8 years agolib/route: preserve old ABI for rtnl_link_get_pmtudisc()
Thomas Haller [Sat, 5 Nov 2016 17:08:02 +0000 (18:08 +0100)]
lib/route: preserve old ABI for rtnl_link_get_pmtudisc()

Yes, rtnl_link_get_pmtudisc() was not in a public header.
But dropping it from ABI results in warnings of ABI checkers.

Just avoid that.

8 years agolib/route: Export correct ipgre functionality
Jef Oliver [Wed, 5 Oct 2016 20:20:35 +0000 (13:20 -0700)]
lib/route: Export correct ipgre functionality

* Rename rtnl_link_get_pmtudisc to rtnl_link_ipgre_get_pmtudisc
  in ipgre.c, making the function correctly match the exported
  functionality in ipgre.h. This fixes an error when trying to
  use the function, returning an incorrect type usage due to the
  link module already having a function of the same name.

* Export rtnl_link_is_[ipgre/ipgretap] allowing for usage per
  documentation.

Reported-by: Sharada Shiddibhavi <sharada.shiddibhavi@intel.com>
Signed-off-by: Jef Oliver <jef.oliver@intel.com>
8 years agovxlan: merge branch 'hashstat-vxlan-attributes'
Thomas Haller [Sat, 5 Nov 2016 16:36:12 +0000 (17:36 +0100)]
vxlan: merge branch 'hashstat-vxlan-attributes'

https://github.com/thom311/libnl/pull/110

8 years agovxlan: fix error code for missing attribute
Thomas Haller [Sat, 5 Nov 2016 16:32:02 +0000 (17:32 +0100)]
vxlan: fix error code for missing attribute

Other VXLAN getters wrongly fail with -NLE_AGAIN.
That maybe should be fixed, but would be an API change.

New API should use the correct error code.

8 years agovxlan: refactor setting/getting vxlan flags
Thomas Haller [Sat, 5 Nov 2016 16:12:03 +0000 (17:12 +0100)]
vxlan: refactor setting/getting vxlan flags

As these properties are FLAG types in the netlink
API, we should also expose them as such in the
libnl API.

It is less code and require less code to support a new
flag.

The point is really to keep the API smaller instead of
wasting a getter and setter for each flag.

8 years agovxlan: don't store vxlan flags as ce_mask
Thomas Haller [Sat, 5 Nov 2016 16:00:53 +0000 (17:00 +0100)]
vxlan: don't store vxlan flags as ce_mask

The ce_mask is there to indicate whether a certain attribute is
set or not. The VXLAN flags are different, because the flag is
either set or not. It cannot have the meaning of being missing.

Therefore, it should not be stored as a VXLAN_ATTR in ce_mask.

8 years agovxlan: restore previous VXLAN_ATTR flag values
Thomas Haller [Sat, 5 Nov 2016 15:41:20 +0000 (16:41 +0100)]
vxlan: restore previous VXLAN_ATTR flag values

The VXLAN_ATTR flags are internal and not public API.
Still, they are exposed as part of nl_object_diff().
There is no reason to change previous behavior, restore
the previous numeric values.

8 years agovxlan: remove redundant enable/disable API from vxlan
Thomas Haller [Sat, 5 Nov 2016 15:31:24 +0000 (16:31 +0100)]
vxlan: remove redundant enable/disable API from vxlan

The enable/disable API is redundant and increases the library
in binary size and documentation. There should be one sensible way
to do something, not several.

Yes, there is prior act to that like rtnl_link_vxlan_disable_proxy().
That doesn't mean it should be repeated.

8 years agovxlan: fix exporting new symbols
Thomas Haller [Sat, 5 Nov 2016 15:23:57 +0000 (16:23 +0100)]
vxlan: fix exporting new symbols

Once a version is released, the existing symbol version
must not be extended.

Fixes: d533736e2258457c090d396586da5c2ea32e5836