]> granicus.if.org Git - libnl/log
libnl
6 years agolib/qdisc: merge branch 'westermo/qdisc-mqprio'
Thomas Haller [Wed, 10 Oct 2018 08:50:41 +0000 (10:50 +0200)]
lib/qdisc: merge branch 'westermo/qdisc-mqprio'

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

6 years agolib/qdisc: avoid BUG() in "lib/route/qdisc/mqprio.c"
Thomas Haller [Tue, 9 Oct 2018 13:27:01 +0000 (15:27 +0200)]
lib/qdisc: avoid BUG() in "lib/route/qdisc/mqprio.c"

BUG() raises an assertion. It seems overly harsh.

For example, rtnl_tc_data() can fail if we fail to allocate
memory. Asserting against that, makes libnl3 not out-of-memory
safe.

Just return a regular error.

6 years agolib/qdisc: style fixes in "lib/route/qdisc/mqprio.c"
Thomas Haller [Mon, 8 Oct 2018 11:46:19 +0000 (13:46 +0200)]
lib/qdisc: style fixes in "lib/route/qdisc/mqprio.c"

6 years agolib/tc: ensure correct error code in rtnl_tc_msg_build()
Thomas Haller [Mon, 8 Oct 2018 11:41:25 +0000 (13:41 +0200)]
lib/tc: ensure correct error code in rtnl_tc_msg_build()

6 years agobuild: cleanup Makefile.am
Thomas Haller [Mon, 8 Oct 2018 11:11:14 +0000 (13:11 +0200)]
build: cleanup Makefile.am

Sort files asciibetically and add $(NULL) sentinel to
Makefile lines.

6 years agoroute:qdisc: add MQPRIO Qdisc
Volodymyr Bendiuga [Fri, 23 Feb 2018 14:37:07 +0000 (15:37 +0100)]
route:qdisc: add MQPRIO Qdisc

More about Qdisc mqprio can be found at:
http://man7.org/linux/man-pages/man8/tc-mqprio.8.html

Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
6 years agoinclude: import linux header pkt_sched.h
Volodymyr Bendiuga [Wed, 28 Mar 2018 06:48:30 +0000 (08:48 +0200)]
include: import linux header pkt_sched.h

Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
6 years agoroute/ip-tunnels: merge branch 'TummyFish/pr/194' (partial)
Thomas Haller [Mon, 25 Jun 2018 13:17:46 +0000 (15:17 +0200)]
route/ip-tunnels: merge branch 'TummyFish/pr/194' (partial)

Cherry-pick parts of the commits from pr#194.

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

6 years agoinclude/linux: update copy of kernel headers
Thomas Haller [Mon, 25 Jun 2018 13:13:14 +0000 (15:13 +0200)]
include/linux: update copy of kernel headers

Taken from upstream kernel commit 29dcea88779c856c7dc92040a0c01233263101d4
(v4.17).

6 years agoif_tunnel: Update IFLA defines up to FWMARK
Thomas Winter [Fri, 8 Jun 2018 04:17:50 +0000 (16:17 +1200)]
if_tunnel: Update IFLA defines up to FWMARK

This is a new option that was added in Linux v4.12.

Signed-off-by: Thomas Winter <Thomas.Winter@alliedtelesis.co.nz>
6 years agoipvti: Fix wrong array size initialization
Thomas Winter [Fri, 8 Jun 2018 03:45:42 +0000 (15:45 +1200)]
ipvti: Fix wrong array size initialization

IPv4 VTI tunnels use the VTI defines.

Signed-off-by: Thomas Winter <Thomas.Winter@alliedtelesis.co.nz>
Fixes: 8f6301426a00d992d00238c7ddd666e96aa63e28
6 years agoipgre: Fix wrong array size initialization
Thomas Winter [Fri, 8 Jun 2018 03:43:53 +0000 (15:43 +1200)]
ipgre: Fix wrong array size initialization

IPv4 GRE tunnels use the GRE defines.

Signed-off-by: Thomas Winter <Thomas.Winter@alliedtelesis.co.nz>
Fixes: 57bdc4ff4895dd91cc723d22eecadcf48945e87c
6 years agoneigh: update neighbour.h and add missing flags
Tobias Jungel [Fri, 13 Apr 2018 09:10:43 +0000 (11:10 +0200)]
neigh: update neighbour.h and add missing flags

NTF_EXT_LEARNED, NTF_OFFLOADED and NTF_MASTER are added to neigh_flags.

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

6 years agoroute/link/vxlan: Fix IPv4 set_local resetting ce_mask
Tuetuopay [Tue, 15 May 2018 12:11:20 +0000 (14:11 +0200)]
route/link/vxlan: Fix IPv4 set_local resetting ce_mask

rtnl_link_vxlan_set_local() removes the bit for the other IP version in
ce_mask. A missing flag inversion in the v4 part made this removal
reset all bits to 0 except the v6 one, screwing all link configuration.

Fixes: 2e68fb5b02304fa6a3e6429c4fdabb084e61b501
https://github.com/thom311/libnl/pull/192

6 years agoAdd support for cloning cgroup filter object.
d0u9 [Fri, 23 Mar 2018 13:21:11 +0000 (21:21 +0800)]
Add support for cloning cgroup filter object.

In this commit, we implement ematch_tree_clone(), which is basis of
cgroup_clone() interface. The whole ematch tree is deep-copied except
the e_ops filed.

Also, a new unit test is added for testing the interface, which named as
check-ematch-tree-clone.c located in tests directory.

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

6 years agoneigh_dump_line: dump master as well
Tobias Jungel [Fri, 20 Apr 2018 13:11:46 +0000 (15:11 +0200)]
neigh_dump_line: dump master as well

In case NEIGH_ATTR_MASTER is set this dumps as well the master
interface.

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

6 years agoneigh: add get/set functions for NEIGH_ATTR_MASTER
Tobias Jungel [Tue, 17 Apr 2018 10:54:14 +0000 (12:54 +0200)]
neigh: add get/set functions for NEIGH_ATTR_MASTER

Beeing able to set NEIGH_ATTR_MASTER hash based lookups are possible for
AF_BRIDGE neighbours.

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

6 years agoneigh: merge branch 'toanju/bridge-neigh'
Thomas Haller [Mon, 25 Jun 2018 12:24:52 +0000 (14:24 +0200)]
neigh: merge branch 'toanju/bridge-neigh'

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

6 years agonl-neigh-list: free allocated items
Tobias Jungel [Tue, 17 Apr 2018 11:49:23 +0000 (13:49 +0200)]
nl-neigh-list: free allocated items

6 years agowhitespace cleanup
Tobias Jungel [Tue, 17 Apr 2018 11:48:30 +0000 (13:48 +0200)]
whitespace cleanup

6 years agoneigh: cache updates as well query AF_BRIDGE neigh
Tobias Jungel [Tue, 17 Apr 2018 11:40:53 +0000 (13:40 +0200)]
neigh: cache updates as well query AF_BRIDGE neigh

This commit adds the query for AF_BRIDGE neighbours. A cache refresh now
includes these objects as well. The result of `./src/nl-neigh-list
--family=bridge` includes now as well the same entries you would
retrieve from the kernel by calling `bridge fdb show`.

6 years agonl: fix function name in debug msg
Matthieu Baerts [Tue, 8 May 2018 12:32:46 +0000 (14:32 +0200)]
nl: fix function name in debug msg

Just a typo.

Fixes: f545295 (lib: log errors from platform)
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
https://github.com/thom311/libnl/pull/191

6 years agoneigh: correct symbol exposed
Tobias Jungel [Tue, 17 Apr 2018 09:43:57 +0000 (11:43 +0200)]
neigh: correct symbol exposed

instead of exposing rtnl_neigh_ll_get the function
rtnl_neigh_get_by_vlan has to be exposed

Fixes: 3bf503d30c271822158414f63eed620afc9b10cd
https://github.com/thom311/libnl/pull/187

6 years agoroute/class: add new api rtnl_class_get_by_parent()
d0u9 [Sun, 1 Apr 2018 08:48:11 +0000 (16:48 +0800)]
route/class: add new api rtnl_class_get_by_parent()

This function searches a class cache previously allocated with
rtnl_class_alloc_cache() and searches for a class matching the interface
index and parent qdisc.

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

6 years agolib/route: merge branch 'pr/184'
Thomas Haller [Wed, 11 Apr 2018 10:49:59 +0000 (12:49 +0200)]
lib/route: merge branch 'pr/184'

6 years agonl-msg: explicitly initialize nlmsg_seq and nlmsg_pid field in nlmsg_alloc_simple()
Thomas Haller [Wed, 11 Apr 2018 10:48:16 +0000 (12:48 +0200)]
nl-msg: explicitly initialize nlmsg_seq and nlmsg_pid field in nlmsg_alloc_simple()

This is no change in behavior, because the NL_AUTO_* macros are both
zero.

6 years agoroute/link: assert in rtnl_link_change() that the sequence number is set as expected
Thomas Haller [Wed, 11 Apr 2018 10:40:39 +0000 (12:40 +0200)]
route/link: assert in rtnl_link_change() that the sequence number is set as expected

6 years agoroute/link: fix sequence number handling in rtnl_link_change()
Tuetuopay [Mon, 9 Apr 2018 14:21:41 +0000 (16:21 +0200)]
route/link: fix sequence number handling in rtnl_link_change()

When rtnl_link_change() fails with -NLE_OPNOTSUPP, it retries
with RTM_SETLINK operation. However, it also needs to re-adjust
the sequence number. Otherwise, the second request might fail
with NLE_SEQ_MISMATCH, although it actually succeeded.

[thaller@redhat.com: changed commit message]

https://github.com/thom311/libnl/issues/179
https://github.com/thom311/libnl/pull/184

6 years agoroute/mall: merge branch 'pr/170'
Thomas Haller [Wed, 11 Apr 2018 10:23:39 +0000 (12:23 +0200)]
route/mall: merge branch 'pr/170'

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

6 years agoroute/mall: fix deep cloning mall
Thomas Haller [Fri, 6 Apr 2018 14:42:55 +0000 (16:42 +0200)]
route/mall: fix deep cloning mall

rtnl_act_append() does not clone the object, it takes it over
and thus the source object is destroyed.

6 years agoroute:cls: add matchall classifier
Volodymyr Bendiuga [Tue, 24 Oct 2017 14:40:00 +0000 (16:40 +0200)]
route:cls: add matchall classifier

This simple classifier allows any traffic pass through.
Useful as an example for port mirroring.

Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
6 years agoinclude: copy entire pkt_cls.h from linux
Volodymyr Bendiuga [Fri, 23 Mar 2018 10:00:40 +0000 (11:00 +0100)]
include: copy entire pkt_cls.h from linux

Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
6 years agocache: make "result" output argument for nl_cache_mngr_add() optional
Tuetuopay [Mon, 9 Apr 2018 08:34:31 +0000 (10:34 +0200)]
cache: make "result" output argument for nl_cache_mngr_add() optional

[thaller@redhat.com: rewritten commit message]

https://github.com/thom311/libnl/issues/178
https://github.com/thom311/libnl/pull/183

6 years agoneigh: support bridge entries for vxlan interfaces
Tobias Jungel [Fri, 6 Apr 2018 07:40:27 +0000 (09:40 +0200)]
neigh: support bridge entries for vxlan interfaces

bridge entries used for switching into vxlan interfaces do not include a
vlan. A comparison of such entires currently always fails which leads
to an invalid cache. This patch selectively adds the NEIGH_ATTR_VLAN
flag based on the passed entry.

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

6 years agoneigh: set correct AF for NDA_DST
Tobias Jungel [Thu, 5 Apr 2018 11:24:59 +0000 (13:24 +0200)]
neigh: set correct AF for NDA_DST

In case using a VXLAN interface at a bridge you will set L2 bridging
entries using a IP destination to tunnel the according L2 traffic. The
current behavior for the dst entries for a neighbor is to use the AF of
the neighbor itself thus in this case AF_BRIDGE is set. This is changed
in the PR to update the family of the dst using nl_addr_guess_family.

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

6 years agobuild: indent libnl-route-3.sym with tabs
Thomas Haller [Fri, 6 Apr 2018 17:35:36 +0000 (19:35 +0200)]
build: indent libnl-route-3.sym with tabs

6 years agobuild: sort entries in Makefile.am and .gitignore by name
Thomas Haller [Fri, 6 Apr 2018 17:34:33 +0000 (19:34 +0200)]
build: sort entries in Makefile.am and .gitignore by name

6 years agotests: merge branch 'pr/172'
Thomas Haller [Fri, 6 Apr 2018 17:42:16 +0000 (19:42 +0200)]
tests: merge branch 'pr/172'

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

6 years agonf-ct-add typo
Lukáš Karas [Fri, 23 Feb 2018 18:20:38 +0000 (19:20 +0100)]
nf-ct-add typo

6 years agoadd demo program for listen conntrack events
Lukáš Karas [Fri, 23 Feb 2018 18:20:08 +0000 (19:20 +0100)]
add demo program for listen conntrack events

6 years agoroute/rule: merge branch 'rule-proto-and-port-range'
Thomas Haller [Fri, 6 Apr 2018 14:02:09 +0000 (16:02 +0200)]
route/rule: merge branch 'rule-proto-and-port-range'

http://lists.infradead.org/pipermail/libnl/2018-March/002398.html

6 years agorule: Add support for protocol and port ranges
David Ahern [Wed, 14 Mar 2018 00:17:25 +0000 (17:17 -0700)]
rule: Add support for protocol and port ranges

Add support for recent fib rule features - specifying a protocol
that installed a rule and an IP protocol plus port range for rules.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
6 years agoUpdate fib_rules.h to latest kernel
David Ahern [Wed, 14 Mar 2018 00:17:24 +0000 (17:17 -0700)]
Update fib_rules.h to latest kernel

Update fib_rules.h to kernel as of bfff4862653b
("net: fib_rules: support for match on ip_proto, sport and dport")

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
6 years agoroute/vrf: initalize clone destination with NULL in vrf_clone()
Jonas Johansson [Mon, 12 Mar 2018 12:51:36 +0000 (13:51 +0100)]
route/vrf: initalize clone destination with NULL in vrf_clone()

Signed-off-by: Jonas Johansson <jonasj76@gmail.com>
6 years agolib: route: rule: add rule_groups to cache ops
Roopa Prabhu [Wed, 14 Feb 2018 22:29:09 +0000 (14:29 -0800)]
lib: route: rule: add rule_groups to cache ops

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Acked-by: David Ahern <dsa@cumulusnetworks.com>
6 years agolib: merge branch 'rtnl-geneve'
Thomas Haller [Mon, 12 Feb 2018 14:23:22 +0000 (15:23 +0100)]
lib: merge branch 'rtnl-geneve'

http://lists.infradead.org/pipermail/libnl/2018-February/002393.html

6 years agolib/rtnl: rename public define RTNL_GENEVE_ID_MAX
Thomas Haller [Mon, 12 Feb 2018 14:19:54 +0000 (15:19 +0100)]
lib/rtnl: rename public define RTNL_GENEVE_ID_MAX

Public defines must have a libnl3 related prefix. Rename
GENEVE_ID_MAX to RTNL_GENEVE_ID_MAX.

6 years agolink: add Geneve support.
Wang Jian [Sat, 3 Feb 2018 10:59:29 +0000 (10:59 +0000)]
link: add Geneve support.

Signed-off-by: Wang Jian <jianjian.wang1@gmail.com>
6 years agolib: merge branch 'pr/167'
Thomas Haller [Mon, 12 Feb 2018 13:20:42 +0000 (14:20 +0100)]
lib: merge branch 'pr/167'

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

6 years agolib: merge implementations of nl_attr_end() and nl_attr_keep_empty()
Thomas Haller [Mon, 12 Feb 2018 13:10:18 +0000 (14:10 +0100)]
lib: merge implementations of nl_attr_end() and nl_attr_keep_empty()

Both functions are almost identical. Merge them into a common helper
function with an @keep_empty argument, so it is clear at which point
they differ.

Also, fix symbols versioning for nl_attr_keep_empty(). For symbol
versioning, once released a version cannot be modifified/extended.

6 years agoFix for cgroup filter addition problem.
d0u9 [Tue, 23 Jan 2018 06:13:43 +0000 (14:13 +0800)]
Fix for cgroup filter addition problem.

Currently, due to the incomplete netlink datagram sent by libnl, cgroup
filter addition is not fully functional. The datagram generated by `tc`
command includes an empty attribute section, which is stripped off
in the libnl counterpart.

In this commit, a new `interface nla_nest_end_keep_empty()` is added.
This function closes attribute without stripping off empty attribute.

6 years agoroute: merge branch 'rtnl-cls-cache-params'
Thomas Haller [Thu, 18 Jan 2018 06:54:51 +0000 (07:54 +0100)]
route: merge branch 'rtnl-cls-cache-params'

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

6 years agoroute: rename rtnl_cls_cache_set_tcm_params() and fix symbol versioning
Thomas Haller [Thu, 18 Jan 2018 06:54:27 +0000 (07:54 +0100)]
route: rename rtnl_cls_cache_set_tcm_params() and fix symbol versioning

After rethinking, "tcm_params" doesn't seem like a good name. Change it to
"tc_params".

Also, an already released section in the linker file must never be
modified. It defeats the purpose of symbol versioning. Move the symbol
to the right section.

6 years agoAdd new function for setting ifindex and parent of a classifier cache.
d0u9 [Mon, 15 Jan 2018 08:35:50 +0000 (16:35 +0800)]
Add new function for setting ifindex and parent of a classifier cache.

It is not good to give classifier cache users only one chance to
set interface index and parent handle when allocte new cache.
Sometimes we want to reuse classifier cache to reduce the overhead
of allocating new memory everytime a new cache is created.

6 years agoCoding style format
d0u9 [Mon, 15 Jan 2018 08:04:54 +0000 (16:04 +0800)]
Coding style format

Fix incorrect code indent.

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

6 years agolib/veth.c: Disassociate link name of peer name
Marcos Paulo de Souza [Thu, 4 Jan 2018 22:24:55 +0000 (20:24 -0200)]
lib/veth.c: Disassociate link name of peer name

Based in the function documentation, peer name could be set regardless
of the link name being informed of not. These parameters should be
checked independently.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
https://github.com/thom311/libnl/pull/162

6 years agotests: Add test to {de}activate loopback interface
Marcos Paulo de Souza [Wed, 3 Jan 2018 01:20:44 +0000 (23:20 -0200)]
tests: Add test to {de}activate loopback interface

This tests is much more like an example of how to do it, and also works
as a test to check if rtnl_link_change is working as expected when it
comes to loopback interface.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
https://github.com/thom311/libnl/pull/161

6 years agotravis: enable more warnings during build
Thomas Haller [Tue, 16 Jan 2018 07:35:54 +0000 (08:35 +0100)]
travis: enable more warnings during build

6 years agoroute/netem: merge branch 'pr/159'
Thomas Haller [Tue, 16 Jan 2018 06:09:14 +0000 (07:09 +0100)]
route/netem: merge branch 'pr/159'

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

6 years agoroute: free previous data in rtnl_netem_set_delay_distribution_data()
Thomas Haller [Tue, 16 Jan 2018 06:23:51 +0000 (07:23 +0100)]
route: free previous data in rtnl_netem_set_delay_distribution_data()

Otherwise, calling rtnl_netem_set_delay_distribution_data() will
leak memory, and that should just be supported.

Also, handle failure to allocate memory.

6 years agoroute: fix memleak in rtnl_netem_set_delay_distribution_data()
Thomas Haller [Tue, 16 Jan 2018 06:18:19 +0000 (07:18 +0100)]
route: fix memleak in rtnl_netem_set_delay_distribution_data()

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.

6 years agoall: declare all variables at the beginning of scope (-Wdeclaration-after-statement)
Thomas Haller [Tue, 16 Jan 2018 05:45:23 +0000 (06:45 +0100)]
all: declare all variables at the beginning of scope (-Wdeclaration-after-statement)

Avoid gcc warning:

  error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]

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.