]> granicus.if.org Git - libnl/log
libnl
6 years agoroute: mark data argument for rtnl_netem_set_delay_distribution_data() as const
Thomas Haller [Tue, 16 Jan 2018 06:14:47 +0000 (07:14 +0100)]
route: mark data argument for rtnl_netem_set_delay_distribution_data() as const

6 years agoroute: add rtnl_netem_set_delay_distribution_data() to linker script
Thomas Haller [Tue, 16 Jan 2018 05:56:45 +0000 (06:56 +0100)]
route: add rtnl_netem_set_delay_distribution_data() to linker script

And some style fixes.

7 years agoroute: add separate function to set netem qdisc delay distribution
Steffen Vogel [Wed, 20 Dec 2017 10:09:08 +0000 (11:09 +0100)]
route: add separate function to set netem qdisc delay distribution

A new function rtnl_netem_set_delay_distribution_data() has been added
to allow the user to pass the delay distribution directly without loading
it from a file.

In conjunction with the maketable code (see iproute2 / NISTnet) this can
be used to generate and load custom delay distributions on the fly.

7 years agotests: fix bug in test-create-bridge.c
Chris Grahn [Fri, 1 Dec 2017 19:41:45 +0000 (13:41 -0600)]
tests: fix bug in test-create-bridge.c

The call to rtnl_link_get_master() at the end of the example can
misleadingly fail because the nl_cache isn't refilled after adding the
test interface to the test bridge.

This commit changes the example to refill the cache before calling
rtnl_link_get_master().

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

7 years agoChange rtnl_link_af_ops.ao_override_rtm behavior
Jef Oliver [Tue, 28 Nov 2017 21:10:54 +0000 (13:10 -0800)]
Change rtnl_link_af_ops.ao_override_rtm behavior

rtnl_link_af_ops.ao_override_rtm allows for a link module to
override the change request type being sent to the kernel. More
specifically, the default change request type is RTM_NEWLINK.
Some link change requests require the reqeust type to be set to
RTM_SETLINK. This is the case for IFLA_PROTINFO specific
attributes for a link that is slave to a bridge.

Currently, ao_override_rtm is static to the address family type.
So, all changes submitted to AF_BRIDGE override the link change
request type. The override only needs to happen if IFLA_PROTINFO
attributes are appended to the link change request.

This patch changes ao_override_rtm from a const integer to a
function pointer that allows for a link module to determine if
the override needs to actually happen.

Currently, only the bridge module uses this functionality. If
bridge flags are applied to a link (bdpu blocking, learning,
fast leave, etc...), these flags are nested in IFLA_PROTINFO. If
the flags are present, the link change request type will be
overridden as RTM_SETLINK.

This fixes the ability to set a bridge link up or down by using
the correct RTM_NEWLINK link change request type.

$ sudo src/nl-link-set -n br2 --state=down
Changed bridge br2 ether a6:e6:94:8c:61:ec
    <broadcast,multicast,up,running,lowerup> group 0

$ ip link show
br2: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue
    state DOWN mode DEFAULT group default qlen 1000

$ sudo src/nl-link-set -n br2 --state=up
Changed bridge br2 ether a6:e6:94:8c:61:ec
    <broadcast,multicast> group 0

$ ip link show
br2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue
    state UNKNOWN mode DEFAULT group default qlen 1000

Signed-off-by: Jef Oliver <jef.oliver@intel.com>
Fixes: 55bc931a7272e6ac8f555bcc2a373eb2b6b58377
http://lists.infradead.org/pipermail/libnl/2017-November/002382.html
http://lists.infradead.org/pipermail/libnl/2017-November/002385.html

7 years agoroute: fix handling old_nh in rtnl_route_parse() and avoid leak
Thomas Haller [Mon, 6 Nov 2017 14:04:14 +0000 (15:04 +0100)]
route: fix handling old_nh in rtnl_route_parse() and avoid leak

The previous code would miss to release old_nh in the error
path.

Also, it relied on the present netlink attributes to have old_nh
initialized. Don't do that.

Also, fixup error codes by using "goto errout_nomem" where appropriate
and keep @err as returned from rtnl_route_set_metric().

7 years agoroute/vlan: merge branch 'vlan-fixes-pr155'
Thomas Haller [Mon, 23 Oct 2017 10:11:23 +0000 (12:11 +0200)]
route/vlan: merge branch 'vlan-fixes-pr155'

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

7 years agoroute/vlan: add capability to indicate heap overflow fix in rtnl_link_vlan_set_egress...
Thomas Haller [Mon, 23 Oct 2017 08:54:10 +0000 (10:54 +0200)]
route/vlan: add capability to indicate heap overflow fix in rtnl_link_vlan_set_egress_map()

Without this fix/capablity, adding more then 4 mappings in
rtnl_link_vlan_set_egress_map() overflows the heap.

7 years agoroute/vlan: grow buffer exponentially in rtnl_link_vlan_set_egress_map()
Thomas Haller [Mon, 23 Oct 2017 09:25:44 +0000 (11:25 +0200)]
route/vlan: grow buffer exponentially in rtnl_link_vlan_set_egress_map()

By a factor of 1.5 instead of 2, to value wasted storage overhead
higher then the number of operations.

Also, check for integer overflows.

7 years agoroute/vlan: fix cloning vlan link in vlan_clone()
Thomas Haller [Mon, 23 Oct 2017 09:35:32 +0000 (11:35 +0200)]
route/vlan: fix cloning vlan link in vlan_clone()

We need to copy the entire source struct over
from source to destination.

The only thing that needs special handling is
to deep-clone the vi_egress_qos buffer.

Fixes: a7469ce758fac3631df6ce72eb3f89150070e7f8
7 years agoroute/vlan: fix memory corruption in rtnl_link_vlan_set_egress_map
Sebastian Bixl [Sun, 15 Oct 2017 20:34:01 +0000 (22:34 +0200)]
route/vlan: fix memory corruption in rtnl_link_vlan_set_egress_map

If you set more than four entries for the vlan egress map a memory
corruption occurs because the reallocation does not reserve memory
for more than four.

Fixes: a7469ce758fac3631df6ce72eb3f89150070e7f8
https://github.com/thom311/libnl/pull/155

[thaller@redhat.com: squashed commits and updated commit message]

7 years agolink: merge branch 'link-dump-family'
Thomas Haller [Thu, 12 Oct 2017 08:52:19 +0000 (10:52 +0200)]
link: merge branch 'link-dump-family'

7 years agoroute: neigh: print family in neigh dumps
Roopa Prabhu [Wed, 11 Oct 2017 21:21:24 +0000 (14:21 -0700)]
route: neigh: print family in neigh dumps

Since the neigh cache can contain msgs from different families,
print family id to distinguish neigh cache entries in the
dump output

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agoroute: link: add family to dump messages
Roopa Prabhu [Wed, 11 Oct 2017 21:21:23 +0000 (14:21 -0700)]
route: link: add family to dump messages

Since the link cache can contain msgs from different families,
print family id to distinguish link cache entries in the
dump output

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agonl: add "const" specifier for nla_policy argument of parse functions
Thomas Haller [Mon, 9 Oct 2017 11:46:44 +0000 (13:46 +0200)]
nl: add "const" specifier for nla_policy argument of parse functions

Adding const to a function argument is generally not an API break
(at least, if the argument is a struct, like in this case).

Usually we declare the policy as static variables. The user should
be able to mark them as "const", so that the linker makes the policy
array read-only. Adjust the API to allow for that.

Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agolibnl-3.4.0 release libnl3_4_0
Thomas Haller [Mon, 9 Oct 2017 11:14:55 +0000 (13:14 +0200)]
libnl-3.4.0 release

Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agobuild: add missing headers for issue #152
Jeroen Roovers [Thu, 21 Sep 2017 09:16:11 +0000 (11:16 +0200)]
build: add missing headers for issue #152

Also, sort all headers.

https://github.com/thom311/libnl/issues/152
https://github.com/thom311/libnl/pull/153

7 years agonetconf: Put nc reference in msg_parser
David Ahern [Thu, 21 Sep 2017 01:35:04 +0000 (19:35 -0600)]
netconf: Put nc reference in msg_parser

netconf_msg_parser is leaking memory. Add the put in the newly
allocated nc object to release the initial reference.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
http://lists.infradead.org/pipermail/libnl/2017-September/002378.html

7 years agolibnl-3.4.0-rc1 release libnl3_4_0rc1
Thomas Haller [Wed, 20 Sep 2017 08:58:20 +0000 (10:58 +0200)]
libnl-3.4.0-rc1 release

Signed-off-by: Thomas Haller <thaller@redhat.com>
7 years agocli: include sys/select.h for select(2)
Tobias Klauser [Thu, 7 Sep 2017 09:20:58 +0000 (11:20 +0200)]
cli: include sys/select.h for select(2)

Some of the cli tools use select(2) and its man page states:

  /* According to POSIX.1-2001, POSIX.1-2008 */
  #include <sys/select.h>

Do so and explicitly #include <sys/select.h> in <netlink/cli/utils.h>
instead of relying of getting select(2) via implicit includes. This is
also needed to make libnl compile for Android.

Based on a previous patch by Fredrik Fornwall.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
https://github.com/thom311/libnl/pull/151

7 years agoPotential memory leak becaue of wrong variable check.
Amit Khatri [Wed, 23 Aug 2017 06:34:50 +0000 (23:34 -0700)]
Potential memory leak becaue of wrong variable check.

in rtnl_link_vf_vlan_alloc() function allocating memory to
vlans while checking NULL or not vf_vlans.
it can cause memory leak.

Signed-off-by: Amit Khatri <amit.khatri@samsung.com>
Signed-off-by: Rohit Pratap Singh <rohit.s@samsung.com>
Fixes: 5d6e43ebef12deadf31fccfa46c0b34892675d36
http://lists.infradead.org/pipermail/libnl/2017-August/002373.html

7 years agoroute: merge branch 'route-mpls'
Thomas Haller [Fri, 18 Aug 2017 13:09:44 +0000 (15:09 +0200)]
route: merge branch 'route-mpls'

http://lists.infradead.org/pipermail/libnl/2017-June/002338.html
http://lists.infradead.org/pipermail/libnl/2017-August/002363.html

7 years agobuild: add new include/netlink-private/route/*.h files to Makefile.am
Thomas Haller [Fri, 18 Aug 2017 12:58:32 +0000 (14:58 +0200)]
build: add new include/netlink-private/route/*.h files to Makefile.am

7 years agoroute: Add support for MPLS encap
David Ahern [Thu, 17 Aug 2017 22:59:37 +0000 (15:59 -0700)]
route: Add support for MPLS encap

Add support for MPLS lwtunnel encapsulation.

Signed-off-by: David Ahern <dsahern@gmail.com>
7 years agoroute: Add support for lwtunnel encapsulations
David Ahern [Thu, 17 Aug 2017 22:59:36 +0000 (15:59 -0700)]
route: Add support for lwtunnel encapsulations

Add framework to support lwtunnel encapsulations per nexthop.

Encapsulations types are expected to fill in the nh_encap_ops for
building and parsing messages, compare encapsulations in routes,
dumping the encapsulations and freeing memory.

Signed-off-by: David Ahern <dsahern@gmail.com>
7 years agoImport lwtunnel encap files from kernel
David Ahern [Thu, 17 Aug 2017 22:59:35 +0000 (15:59 -0700)]
Import lwtunnel encap files from kernel

Import lwtunnel and mpls_iptunnel.h from net-next tree as of commit
b217566a525ff24334d17635a865f44b68c2c583

Signed-off-by: David Ahern <dsahern@gmail.com>
7 years agoAdd support for label stack in nl-route commands
David Ahern [Thu, 17 Aug 2017 22:59:34 +0000 (15:59 -0700)]
Add support for label stack in nl-route commands

Add support for MPLS labels in nexthop specification. Specifically, the
'as' keyword specifies the MPLS label stack and if the route address
family is MPLS then the nexthop via is added as a route via instead of
a gateway (subtle differences introduced for MPLS).

Signed-off-by: David Ahern <dsahern@gmail.com>
7 years agoroute: Add support for ttl propagation in MPLS routes
David Ahern [Thu, 17 Aug 2017 22:59:33 +0000 (15:59 -0700)]
route: Add support for ttl propagation in MPLS routes

Add support for RTA_TTL_PROPAGATE attribute on a per-route basis.
Used to enable/disable TTL propagation at LSP egress.

Signed-off-by: David Ahern <dsahern@gmail.com>
7 years agoroute: Add support for MPLS address family
David Ahern [Thu, 17 Aug 2017 22:59:32 +0000 (15:59 -0700)]
route: Add support for MPLS address family

Add support for route in MPLS family. New attributes:
- RTA_NEWDST - label stack for a nexthop
- RTA_VIA - nexthop address (e.g., IPv4 or IPv6)

Other changes required:
- scope has to be universe for MPLS routes so fixup rtnl_route_guess_scope
- priority attribute can not be set for MPLS. Change rtnl_route_parse to
  not set the attribute by default for AF_MPLS.
- table attribute should not be set unless something other than the default
  table. For MPLS this attribute can not be set.

'/' is the separator in label stacks for consistency with iproute2.

Signed-off-by: David Ahern <dsahern@gmail.com>
7 years agoaddr: Add support for AF_MPLS
David Ahern [Thu, 17 Aug 2017 22:59:31 +0000 (15:59 -0700)]
addr: Add support for AF_MPLS

MPLS 'addresses' are 4-byte labels with a prefix length of 20.

Signed-off-by: David Ahern <dsahern@gmail.com>
7 years agoaddr: Add implementations for mpls_ntop and mpls_pton
David Ahern [Thu, 17 Aug 2017 22:59:30 +0000 (15:59 -0700)]
addr: Add implementations for mpls_ntop and mpls_pton

Implementations of mpls_ntop and mpls_pton taken from iproute2.

Signed-off-by: David Ahern <dsahern@gmail.com>
7 years agobuild: add include/linux-private/linux/mpls.h to Makefile.am
Thomas Haller [Fri, 18 Aug 2017 13:00:05 +0000 (15:00 +0200)]
build: add include/linux-private/linux/mpls.h to Makefile.am

7 years agoImport mpls header from kernel tree
David Ahern [Thu, 17 Aug 2017 22:59:29 +0000 (15:59 -0700)]
Import mpls header from kernel tree

Add include/uapi/linux/mpls.h from net-next tree as of commit
b217566a525ff24334d17635a865f44b68c2c583

Signed-off-by: David Ahern <dsahern@gmail.com>
7 years agoUpdate rtnetlink.h from kernel tree
David Ahern [Thu, 17 Aug 2017 22:59:28 +0000 (15:59 -0700)]
Update rtnetlink.h from kernel tree

Update to rtnetlink.h to top of net-next tree as of commit
b217566a525ff24334d17635a865f44b68c2c583

Signed-off-by: David Ahern <dsahern@gmail.com>
7 years agolib/route: add /usr/lib64/tc/ search path for netem dist file
Thomas Haller [Mon, 14 Aug 2017 08:10:18 +0000 (10:10 +0200)]
lib/route: add /usr/lib64/tc/ search path for netem dist file

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

7 years agoall: avoid compiler warnings -Wimplicit-fallthrough
Thomas Haller [Thu, 15 Jun 2017 16:09:49 +0000 (18:09 +0200)]
all: avoid compiler warnings -Wimplicit-fallthrough

7 years agoall: merge branch 'villemoes-memcpy' (#146)
Thomas Haller [Thu, 15 Jun 2017 16:00:21 +0000 (18:00 +0200)]
all: merge branch 'villemoes-memcpy' (#146)

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

7 years agolib/genl/family.c: fix if (x) y; else y;
Rasmus Villemoes [Thu, 8 Jun 2017 10:56:46 +0000 (12:56 +0200)]
lib/genl/family.c: fix if (x) y; else y;

I'm not 100% sure this is the correct fix; maybe this really is supposed
to return family->gf_maxattr, but this is an odd way of writing
that. Anyway, comparing to the other genl_family_[gs]et functions, I
suppose this is what was really meant.

7 years agolib/xfrm/ae.c: fix memcpy(dst, dst) bug
Rasmus Villemoes [Thu, 8 Jun 2017 10:43:48 +0000 (12:43 +0200)]
lib/xfrm/ae.c: fix memcpy(dst, dst) bug

This is clearly not what was intended. While at it, drop the pointless
cast of the allocator's return value, and use plain malloc since we're
explicitly populating all len bytes immediately afterwards.

7 years agolib: merge branch 'villemoes-realloc' (#145)
Thomas Haller [Thu, 15 Jun 2017 15:51:23 +0000 (17:51 +0200)]
lib: merge branch 'villemoes-realloc' (#145)

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

7 years agolib/route/qdisc/netem.c/trivial: don't use braces for one-line blocks
Thomas Haller [Thu, 15 Jun 2017 15:49:25 +0000 (17:49 +0200)]
lib/route/qdisc/netem.c/trivial: don't use braces for one-line blocks

7 years agolib/route/qdisc/netem.c/trivial: fix whitespace and indentation in netem_msg_fill_raw()
Thomas Haller [Thu, 15 Jun 2017 15:44:05 +0000 (17:44 +0200)]
lib/route/qdisc/netem.c/trivial: fix whitespace and indentation in netem_msg_fill_raw()

The indentation around

  if (netem->qnm_dist.dist_data && netem->qnm_dist.dist_size) {

looked very wrong. Don't change the behavior, only the indentation.
See also commit 861901c55bd9e2f84e7c8de0da5ea6179867907d which
introduced the ill indentation.

7 years agolib/route/cls/u32.c: use UCHAR_MAX define instead of numeric 255
Thomas Haller [Thu, 15 Jun 2017 15:32:40 +0000 (17:32 +0200)]
lib/route/cls/u32.c: use UCHAR_MAX define instead of numeric 255

7 years agolib/route/qdisc/netem.c: avoid memory leak if realloc fails
Rasmus Villemoes [Thu, 8 Jun 2017 08:59:28 +0000 (10:59 +0200)]
lib/route/qdisc/netem.c: avoid memory leak if realloc fails

PS: There's some serious whitespace damage in this vicinity (starting
around line 269), making one wonder if the ifs and elses are matched as
they should be.

7 years agolib/route/cls/u32.c: remove bogus comment
Rasmus Villemoes [Thu, 8 Jun 2017 08:59:27 +0000 (10:59 +0200)]
lib/route/cls/u32.c: remove bogus comment

7 years agolib/route/cls/u32.c: let the compiler do pointer arithmetic
Rasmus Villemoes [Thu, 8 Jun 2017 08:59:25 +0000 (10:59 +0200)]
lib/route/cls/u32.c: let the compiler do pointer arithmetic

This is what ->, [] and & are for.

7 years agolib/route/cls/u32.c: avoid overflowing an unsigned char
Rasmus Villemoes [Thu, 8 Jun 2017 08:59:24 +0000 (10:59 +0200)]
lib/route/cls/u32.c: avoid overflowing an unsigned char

If rtnl_u32_add_key is called too many times, sel->nkeys will wrap from
255 to 0, effectively killing all the previous rtnl_u32_add_key
calls (while having an inaccessible chunk of memory sitting beyond the
accessible part of the ->keys array). Not sure NOMEM is the best error
code, but that's at least something users would already have to be
prepared to handle.

7 years agolib/route/cls/u32.c: remove pointless nl_data_append calls
Rasmus Villemoes [Thu, 8 Jun 2017 08:59:22 +0000 (10:59 +0200)]
lib/route/cls/u32.c: remove pointless nl_data_append calls

Increasing the size of the u->cu_selector item by the size of a struct
tc_u32_key (i.e., making the flexible array member sel->keys one element
bigger) is pointless when one doesn't update sel->nkeys or otherwise
records the increased size, so these are effectively memory leaks.

7 years agolib/data.c: avoid memleak if realloc fails
Rasmus Villemoes [Thu, 8 Jun 2017 08:59:21 +0000 (10:59 +0200)]
lib/data.c: avoid memleak if realloc fails

7 years agolib/cache_mgr.c: remove pointless goto
Rasmus Villemoes [Thu, 8 Jun 2017 08:59:20 +0000 (10:59 +0200)]
lib/cache_mgr.c: remove pointless goto

The only way we can enter the block containing this goto is if i is
equal to (the old value of) mngr->cm_nassocs, and that slot is now
guaranteed to exist and be vacant after the succesful realloc call,
while no earlier slots can have become available [there's no locking
involved, so I assume that avoiding concurrent operations on a struct
nl_cache_mngr is up to the caller].

7 years agolib/cache_mngr.c: avoid memleak if realloc fails
Rasmus Villemoes [Thu, 8 Jun 2017 08:59:12 +0000 (10:59 +0200)]
lib/cache_mngr.c: avoid memleak if realloc fails

foo = realloc(foo, ...) is almost always a bug - the only exceptions
being if (a) one just exits the process in case of failure or (b) if one
has made a copy of the foo pointer before the realloc call, and takes
care to either reinstate it afterwards or free() it and make sure that
the data structure is updated to handle foo now being NULL (in this case
for example setting ->cm_nassocs to 0). (a) is not an option in
libraries, and (b) is more cumbersome than just doing it the canonical
way: use local variables for the new pointer and size, and only install
them when realloc succeeds.

7 years agogenl: drop usage of GENL_ID_GENERATE
Tobias Klauser [Tue, 23 May 2017 07:20:43 +0000 (09:20 +0200)]
genl: drop usage of GENL_ID_GENERATE

After kernel commit a07ea4d9941a ("genetlink: no longer support using
static family IDs"), GENL_ID_GENERATE is no longer exposed to userspace
(and actually should never have been). Update the private header copy of
linux/genetlink.h accordingly. And replace the two occurences of
GENL_ID_GENERATE.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
https://github.com/thom311/libnl/pull/144

7 years agobuild: merge branch 'cli-no-dlfcn-h'
Thomas Haller [Mon, 15 May 2017 09:53:49 +0000 (11:53 +0200)]
build: merge branch 'cli-no-dlfcn-h'

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

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.