ipv6: ignore null_entry in inet6_rtm_getroute() too
authorWANG Cong <xiyou.wangcong@gmail.com>
Thu, 2 Mar 2017 04:48:39 +0000 (20:48 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 2 Mar 2017 22:35:31 +0000 (14:35 -0800)
Like commit 1f17e2f2c8a8 ("net: ipv6: ignore null_entry on route dumps"),
we need to ignore null entry in inet6_rtm_getroute() too.

Return -ENETUNREACH here to sync with IPv4 behavior, as suggested by David.

Fixes: a1a22c1206 ("net: ipv6: Keep nexthop of multipath route on admin down")
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/route.c

index 43ca90d50ae9b315fb89e4a3c2a6770087a3566e..229bfcc451ef5004e9e9d14c071937c1b9658711 100644 (file)
@@ -3632,6 +3632,12 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)
                rt = (struct rt6_info *)ip6_route_output(net, NULL, &fl6);
        }
 
+       if (rt == net->ipv6.ip6_null_entry) {
+               err = rt->dst.error;
+               ip6_rt_put(rt);
+               goto errout;
+       }
+
        skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
        if (!skb) {
                ip6_rt_put(rt);