Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ipv4: fix nexthop attlen check in fib_nh_match

fib_nh_match does not match nexthops correctly. Example:

ip route add 172.16.10/24 nexthop via 192.168.122.12 dev eth0 \
nexthop via 192.168.122.13 dev eth0
ip route del 172.16.10/24 nexthop via 192.168.122.14 dev eth0 \
nexthop via 192.168.122.15 dev eth0

Del command is successful and route is removed. After this patch
applied, the route is correctly matched and result is:
RTNETLINK answers: No such process

Please consider this for stable trees as well.

Fixes: 4e902c57417c4 ("[IPv4]: FIB configuration using struct fib_config")
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jiri Pirko and committed by
David S. Miller
f76936d0 ad971f61

+1 -1
+1 -1
net/ipv4/fib_semantics.c
··· 537 537 return 1; 538 538 539 539 attrlen = rtnh_attrlen(rtnh); 540 - if (attrlen < 0) { 540 + if (attrlen > 0) { 541 541 struct nlattr *nla, *attrs = rtnh_attrs(rtnh); 542 542 543 543 nla = nla_find(attrs, attrlen, RTA_GATEWAY);