ipv6/route: Don't match on fc_nh_id if not set in ip6_route_del()
authorStefano Brivio <sbrivio@redhat.com>
Fri, 21 Jun 2019 15:45:25 +0000 (17:45 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 24 Jun 2019 17:18:49 +0000 (10:18 -0700)
If fc_nh_id isn't set, we shouldn't try to match against it. This
actually matters just for the RTF_CACHE below (where this case is
already handled): if iproute2 gets a route exception and tries to
delete it, it won't reference it by fc_nh_id, even if a nexthop
object might be associated to the originating route.

Fixes: 5b98324ebe29 ("ipv6: Allow routes to use nexthop objects")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/route.c

index 3975ae8e2440b816c1b198b8e788bffa4ee1dcf6..0a7c21ac0b95fecb2c2f07cff1dbe187e3f79b09 100644 (file)
@@ -3840,7 +3840,8 @@ static int ip6_route_del(struct fib6_config *cfg,
                for_each_fib6_node_rt_rcu(fn) {
                        struct fib6_nh *nh;
 
-                       if (rt->nh && rt->nh->id != cfg->fc_nh_id)
+                       if (rt->nh && cfg->fc_nh_id &&
+                           rt->nh->id != cfg->fc_nh_id)
                                continue;
 
                        if (cfg->fc_flags & RTF_CACHE) {