]> granicus.if.org Git - libnl/log
libnl
7 years agobuild: allow building cli without dynamic librarires support
Thomas Haller [Fri, 12 May 2017 10:47:19 +0000 (12:47 +0200)]
build: allow building cli without dynamic librarires support

Commit 3cb28534d34392ceec4adead0cfa97039796ccb7 enables building
of cli always as part of `make check`. As cli previously always
included <dlfcn.h>, this broke tests for building with toolchains
that don't support dynamic library loading.

Add a configure check and disable dlopen() based on whether
<dlfcn.h> is available.

Signed-off-by: Thomas Haller <thaller@redhat.com>
https://github.com/thom311/libnl/pull/141

7 years agobuild: don't build cli libraries by default
Thomas Haller [Fri, 12 May 2017 10:40:45 +0000 (12:40 +0200)]
build: don't build cli libraries by default

When configuring with --enable-cli=no, we should not build
the libraries related the cli.

This fixes commit 3cb2853 (build: enable building cli during tests)
which enables building of cli during `make check`. However, during
regular build, these libraries should not get build.

Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agoaddr: add AF_VSOCK to translation table
Tobias Klauser [Fri, 5 May 2017 07:32:44 +0000 (09:32 +0200)]
addr: add AF_VSOCK to translation table

Add AF_VSOCK to the address family translation table.

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

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agorule: merge support for l3mdev in FIB rules
Thomas Haller [Fri, 12 May 2017 09:31:41 +0000 (11:31 +0200)]
rule: merge support for l3mdev in FIB rules

http://lists.infradead.org/pipermail/libnl/2017-May/002321.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agorule: change API for setting/getting l3mdev rule property
Thomas Haller [Fri, 12 May 2017 08:37:53 +0000 (10:37 +0200)]
rule: change API for setting/getting l3mdev rule property

- for rtnl_rule_set_l3mdev(), also allow unsetting the l3mdev field.
  In practice, kernel only allows for two options: either omit
  tb[FRA_L3MDEV] or set it to 1. As such, rtnl_rule_set_l3mdev()
  allows for both of these. In principle the setter could get
  extended to set other values. Such values are reserved.

- for rtnl_rule_get_l3mdev() also return an error code. I think it
  is appropriate to mix value and negative error code, as long as
  the range of values cannot overlap with error codes.
  Arguably, the outcome is a bit awkward, as the function now is
  expected to return -NLE_MISSING_ATTR or 1. So, the best check
  is probably

      if (rtnl_rule_get_l3mdev(r) > 0) { ... }

The reason for this change is that libnl should expose the netlink
API without coercing uint8 to boolean. That way, future changes
in kernel don't require update to libnl3.

Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agorule: Add support for l3mdev in FIB rules
David Ahern [Wed, 3 May 2017 23:21:10 +0000 (16:21 -0700)]
rule: Add support for l3mdev in FIB rules

Add support for the l3mdev option in FIB rules. If l3mdev is set
then the lookup is directed to the table associated with the l3mdev
(e.g., VRF) device.

If the l3mev attribute is set the table id is not, so update the table
id attribute to make sure r_table is non-0.

iproute2 shows the rule as:
    1000: from all lookup [l3mdev-table]

where [l3mdev-table] infers the dynamic nature of the table id. Keep
that notation for libnl.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agoUpdate fib_rules.h to latest kernel
David Ahern [Wed, 3 May 2017 23:21:09 +0000 (16:21 -0700)]
Update fib_rules.h to latest kernel

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agoroute: merge branch 'netconf'
Thomas Haller [Fri, 12 May 2017 08:20:30 +0000 (10:20 +0200)]
route: merge branch 'netconf'

(v1): http://lists.infradead.org/pipermail/libnl/2017-April/002308.html

http://lists.infradead.org/pipermail/libnl/2017-May/002316.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agoroute: Add support for MPLS to netconf
David Ahern [Wed, 3 May 2017 21:05:09 +0000 (14:05 -0700)]
route: Add support for MPLS to netconf

Add support to netconf for MPLS address family.

v2
- change get method to return 0/error and take 'int *val'
  which is set to the value requested
- added rtnl_netconf_get_input to libnl-route-3.sym

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agonl-monitor: Add support for netconf caches
David Ahern [Wed, 3 May 2017 21:05:08 +0000 (14:05 -0700)]
nl-monitor: Add support for netconf caches

Allow user to monitor netconf changes.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agonl-monitor: All user to specify line format
David Ahern [Wed, 3 May 2017 21:05:07 +0000 (14:05 -0700)]
nl-monitor: All user to specify line format

nl-monitor defaults to stats. Allow user to select brief and details.

The known_groups is moved up to a global to allow a proper print_usage
function.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agoroute: Add support for netconf
David Ahern [Wed, 3 May 2017 21:05:06 +0000 (14:05 -0700)]
route: Add support for netconf

Add route/netconf cache type to monitor RTM_*NETCONF messages.

v2
- change get methods to return 0/error and take 'int *val'
  which is set to the value requested

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: Balakrishnan Raman <ramanb@cumulusnetworks.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agoroute: merge branch 'shanmugh-master'
Thomas Haller [Wed, 3 May 2017 11:08:00 +0000 (13:08 +0200)]
route: merge branch 'shanmugh-master'

Related: https://github.com/thom311/libnl/pull/137
Related: http://lists.infradead.org/pipermail/libnl/2017-March/002303.html
Related: http://lists.infradead.org/pipermail/libnl/2017-March/002304.html

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

7 years agoroute: fix symbol versioning
Thomas Haller [Wed, 3 May 2017 11:00:49 +0000 (13:00 +0200)]
route: fix symbol versioning

Once released, an existing symbol version must not be modified.
Move the new symbols to the right section.

7 years agoDo not increment refcount in rtnl_*_get_action APIs.
Santhosh Kumar [Tue, 21 Mar 2017 17:38:36 +0000 (10:38 -0700)]
Do not increment refcount in rtnl_*_get_action APIs.

7 years agoProvide accessors for actions (rtnl_act).
Santhosh Kumar [Mon, 20 Mar 2017 06:47:34 +0000 (23:47 -0700)]
Provide accessors for actions (rtnl_act).

Add accessor functions to retrieve actions on a tc object
and provide additional function to navigate the collection
of actions.

7 years agoroute/link: add accessor API for IPv6 flags
Markus Trapp [Tue, 14 Feb 2017 15:33:04 +0000 (16:33 +0100)]
route/link: add accessor API for IPv6 flags

Add functions to access the IPv6 specific flags of a link object.
Also the functions for IPv6 link flags translation are now exported, similar
to the non IPv6 specific translation functions.

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

7 years agotools: fix building doc in build_release.sh
Thomas Haller [Wed, 3 May 2017 09:35:03 +0000 (11:35 +0200)]
tools: fix building doc in build_release.sh

Fixes: 3b2071e970995a9a22d46457e60a762161b46231
7 years agolibnl-3.3.0 release libnl3_3_0
Thomas Haller [Wed, 3 May 2017 08:36:23 +0000 (10:36 +0200)]
libnl-3.3.0 release

Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agoall: don't use math.h or link with libm.so
Thomas Haller [Thu, 23 Mar 2017 13:27:14 +0000 (14:27 +0100)]
all: don't use math.h or link with libm.so

7 years agolib: escape usage of strerror_l() if it doesn't exist in libc
Alexey Brodkin [Fri, 10 Mar 2017 14:44:22 +0000 (17:44 +0300)]
lib: escape usage of strerror_l() if it doesn't exist in libc

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>
7 years agolibnl-3.3.0-rc1 release libnl3_3_0rc1
Thomas Haller [Mon, 6 Mar 2017 20:28:49 +0000 (21:28 +0100)]
libnl-3.3.0-rc1 release

First release candidate for upcoming libnl 3.3.0 release.

Note that from now on, future libnl3 release will bump the
second version number, instead of the third. So the next
version will be 3.3.0 instead of 3.2.30.
This does not imply a break of API/ABI, it is only a change
of the versioning scheme.

Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agoinclude: merge branch 'include-cleanup'
Thomas Haller [Thu, 2 Mar 2017 00:33:48 +0000 (01:33 +0100)]
include: merge branch 'include-cleanup'

7 years agoinclude: restore linux header includes in public headers
Thomas Haller [Wed, 1 Mar 2017 23:30:17 +0000 (00:30 +0100)]
include: restore linux header includes in public headers

The previous commits reorganized the public headers to drop includes
of linux kernel headers.

Restore the previous situation because otherwise the change might
break compilation for users who rely on certain headers getting dragged
in by libnl3.

7 years agoinclude: don't include kernel headers in public libnl3 headers
Thomas Haller [Wed, 1 Mar 2017 21:00:14 +0000 (22:00 +0100)]
include: don't include kernel headers in public libnl3 headers

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).

7 years agobuild: add tools/build_release.sh script
Thomas Haller [Tue, 28 Feb 2017 11:03:26 +0000 (12:03 +0100)]
build: add tools/build_release.sh script

Add script to do a release.

7 years agobuild: reorder checks in configure.ac
Thomas Haller [Mon, 27 Feb 2017 23:34:46 +0000 (00:34 +0100)]
build: reorder checks in configure.ac

7 years agobuild: style cleanup in doc/Makefile.am
Thomas Haller [Mon, 27 Feb 2017 23:03:16 +0000 (00:03 +0100)]
build: style cleanup in doc/Makefile.am

7 years agobuild: fix creating directories for generated sources
Thomas Haller [Mon, 27 Feb 2017 17:26:14 +0000 (18:26 +0100)]
build: fix creating directories for generated sources

Fixes: a572196366cfc1938596052f8e16121d0d374164
7 years agobuild: pass --disable-dependency-tracking to `make distcheck`
Thomas Haller [Mon, 27 Feb 2017 16:51:07 +0000 (17:51 +0100)]
build: pass --disable-dependency-tracking to `make distcheck`

7 years agobuild: ensure build directory for generated sources exist
Thomas Haller [Mon, 27 Feb 2017 17:02:06 +0000 (18:02 +0100)]
build: ensure build directory for generated sources exist

For out-of-tree builds, we must ensure that the build directory
for the generated sources exists. We do that by adding a dependency
to the .dirstamp file.

7 years agoxfrm: merge branch 'sb/xfrm-sp-fixes' (#133)
Thomas Haller [Mon, 27 Feb 2017 16:43:01 +0000 (17:43 +0100)]
xfrm: merge branch 'sb/xfrm-sp-fixes' (#133)

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

7 years agoxfrm: NUL terminate the ctx_str buffer in xfrmnl_sa_set_sec_ctx()
Thomas Haller [Mon, 27 Feb 2017 16:35:46 +0000 (17:35 +0100)]
xfrm: NUL terminate the ctx_str buffer in xfrmnl_sa_set_sec_ctx()

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.

7 years agoxfrm: allow quering optional arguments from xfrmnl_sp_get_sec_ctx()
Thomas Haller [Mon, 27 Feb 2017 16:32:15 +0000 (17:32 +0100)]
xfrm: allow quering optional arguments from xfrmnl_sp_get_sec_ctx()

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.

7 years agofix of boolean operators
Simon Buttgereit [Wed, 8 Feb 2017 08:14:40 +0000 (09:14 +0100)]
fix of boolean operators

Mixed up boolean operators in commit f38fb7a.
This commit is the appropriate fix.

7 years agoupdate documentation of xfrmnl_sp_get_sec_ctx
Simon Buttgereit [Tue, 7 Feb 2017 16:35:35 +0000 (17:35 +0100)]
update documentation of xfrmnl_sp_get_sec_ctx

7 years agoadd possibity to delete policy without index
Simon Buttgereit [Tue, 7 Feb 2017 16:32:20 +0000 (17:32 +0100)]
add possibity to delete policy without index

security policy can be identified with direction, selector and security context
too. Therefore the code to append approptiate data to delete message is added.

7 years agoupdate sp_attr condition in build_xfrm_sp_message
Simon Buttgereit [Tue, 7 Feb 2017 16:24:55 +0000 (17:24 +0100)]
update sp_attr condition in build_xfrm_sp_message

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.

7 years agolittle style fixes.
Simon Buttgereit [Tue, 7 Feb 2017 07:53:33 +0000 (08:53 +0100)]
little style fixes.

7 years agofix xfrmnl_sp_set_sec_ctx length attributes
Simon Buttgereit [Mon, 6 Feb 2017 17:45:12 +0000 (18:45 +0100)]
fix xfrmnl_sp_set_sec_ctx length attributes

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.

7 years agofix build_xfrm_sp_message index condition
Simon Buttgereit [Mon, 6 Feb 2017 17:43:31 +0000 (18:43 +0100)]
fix build_xfrm_sp_message index condition

Index is not needed and not known if adding a policy. Seems to be copied from
build_xfrm_sp_delete_message.

7 years agoroute: neigh: use NDA_MASTER for neigh->n_master if available
Roopa Prabhu [Fri, 10 Feb 2017 05:15:26 +0000 (21:15 -0800)]
route: neigh: use NDA_MASTER for neigh->n_master if available

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>
7 years agobuild: enable more warnings
Thomas Haller [Mon, 27 Feb 2017 13:04:26 +0000 (14:04 +0100)]
build: enable more warnings

7 years agoall: enable -Wmissing-prototype warning for all components
Thomas Haller [Mon, 27 Feb 2017 11:17:22 +0000 (12:17 +0100)]
all: enable -Wmissing-prototype warning for all components

7 years agobuild: merge branch 'th/non-recursive-make'
Thomas Haller [Mon, 27 Feb 2017 12:49:47 +0000 (13:49 +0100)]
build: merge branch 'th/non-recursive-make'

Refactor makefiles to use one top-level Makefile.am
and don't do recursive make.

Exception is doc/Makefile.am, which is still separate
like before.

7 years agobuild: move compiler warning flags to separate autoconf variable
Thomas Haller [Mon, 27 Feb 2017 11:13:13 +0000 (12:13 +0100)]
build: move compiler warning flags to separate autoconf variable

7 years agobuild: enable building cli during tests
Thomas Haller [Mon, 27 Feb 2017 11:02:43 +0000 (12:02 +0100)]
build: enable building cli during tests

The cli programs don't have any additional external dependencies.
So, during a `make check`, we should always build them, even if
they were disabled during configure and won't be installed.

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.

8 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

8 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

8 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

8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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

8 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

8 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

8 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.

8 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()

8 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

8 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>
8 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>
8 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>
8 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

8 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