Commit 37391cc8 authored by David S. Miller's avatar David S. Miller

Merge branch 'nexthop-route-deletye-warning'

Nikolay Aleksandrov says:

====================
net: ipv4: fix nexthop route delete warning

The first patch fixes a warning that can be triggered by deleting a
nexthop route and specifying a device (more info in its commit msg).
And the second patch adds a selftest for that case.

Chose this way to fix it because we should match when deleting without
nh spec and should fail when deleting a nexthop route with old-style nh
spec because nexthop objects are managed separately, e.g.:
$ ip r show 1.2.3.4/32
1.2.3.4 nhid 12 via 192.168.11.2 dev dummy0

$ ip r del 1.2.3.4/32
$ ip r del 1.2.3.4/32 nhid 12
<both should work>

$ ip r del 1.2.3.4/32 dev dummy0
<should fail with ESRCH>

v2: addded more to patch 01's commit message
    adjusted the test comment in patch 02
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents c3efcedd 392baa33
......@@ -889,8 +889,13 @@ int fib_nh_match(struct net *net, struct fib_config *cfg, struct fib_info *fi,
}
if (cfg->fc_oif || cfg->fc_gw_family) {
struct fib_nh *nh = fib_info_nh(fi, 0);
struct fib_nh *nh;
/* cannot match on nexthop object attributes */
if (fi->nh)
return 1;
nh = fib_info_nh(fi, 0);
if (cfg->fc_encap) {
if (fib_encap_match(net, cfg->fc_encap_type,
cfg->fc_encap, nh, cfg, extack))
......
......@@ -1208,6 +1208,20 @@ ipv4_fcnal()
set +e
check_nexthop "dev veth1" ""
log_test $? 0 "Nexthops removed on admin down"
# nexthop route delete warning: route add with nhid and delete
# using device
run_cmd "$IP li set dev veth1 up"
run_cmd "$IP nexthop add id 12 via 172.16.1.3 dev veth1"
out1=`dmesg | grep "WARNING:.*fib_nh_match.*" | wc -l`
run_cmd "$IP route add 172.16.101.1/32 nhid 12"
run_cmd "$IP route delete 172.16.101.1/32 dev veth1"
out2=`dmesg | grep "WARNING:.*fib_nh_match.*" | wc -l`
[ $out1 -eq $out2 ]
rc=$?
log_test $rc 0 "Delete nexthop route warning"
run_cmd "$IP ip route delete 172.16.101.1/32 nhid 12"
run_cmd "$IP ip nexthop del id 12"
}
ipv4_grp_fcnal()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment