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 <dvyu...@google.com>
Cc: David Ahern <d...@cumulusnetworks.com>
Signed-off-by: Cong Wang <xiyou.wangc...@gmail.com>
---
 net/ipv6/route.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index f54f426..df757b2 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3627,6 +3627,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);
-- 
2.5.5

Reply via email to