Generate netlink notification when default IPv6 route preference changes
authorKalash Nainwal <kalash@arista.com>
Thu, 10 Feb 2022 22:09:35 +0000 (14:09 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 14 Feb 2022 11:15:37 +0000 (11:15 +0000)
Generate RTM_NEWROUTE netlink notification when the route preference
 changes on an existing kernel generated default route in response to
 RA messages. Currently netlink notifications are generated only when
 this route is added or deleted but not when the route preference
 changes, which can cause userspace routing application state to go
 out of sync with kernel.

Signed-off-by: Kalash Nainwal <kalash@arista.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/ndisc.c

index f03b597e4121b5ce1c47418ec73c1a81babd2730..1c06d0cd02f79cba62b671186858bf6ee4f67b4c 100644 (file)
@@ -1337,8 +1337,12 @@ static void ndisc_router_discovery(struct sk_buff *skb)
                        return;
                }
                neigh->flags |= NTF_ROUTER;
-       } else if (rt) {
+       } else if (rt && IPV6_EXTRACT_PREF(rt->fib6_flags) != pref) {
+               struct nl_info nlinfo = {
+                       .nl_net = net,
+               };
                rt->fib6_flags = (rt->fib6_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
+               inet6_rt_notify(RTM_NEWROUTE, rt, &nlinfo, NLM_F_REPLACE);
        }
 
        if (rt)