mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-27 18:43:12 -04:00
ipv6: record the reason for kernel-initiated route deletions
Record why the kernel deletes an IPv6 route on its own: - RT_DEL_REASON_EXPIRED for routes reaped by the FIB6 garbage collector after their RTF_EXPIRES lifetime ran out. - RT_DEL_REASON_RA_WITHDRAWN for default routes, prefix routes and RFC 4191 route information routes withdrawn by a zero-lifetime Router Advertisement. Deleting a default route because its metric changed is not a withdrawal, so it keeps RT_DEL_REASON_UNSPEC. Signed-off-by: Yuyang Huang <sigefriedhyy@gmail.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Link: https://patch.msgid.link/20260808005642.26901-4-sigefriedhyy@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
committed by
Paolo Abeni
parent
352c6732ff
commit
e8636445b7
@@ -2874,7 +2874,8 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)
|
||||
if (rt) {
|
||||
/* Autoconf prefix route */
|
||||
if (valid_lft == 0) {
|
||||
ip6_del_rt(net, rt, false);
|
||||
ip6_del_rt_reason(net, rt,
|
||||
RT_DEL_REASON_RA_WITHDRAWN);
|
||||
rt = NULL;
|
||||
} else {
|
||||
table = rt->fib6_table;
|
||||
|
||||
@@ -2403,7 +2403,7 @@ static void fib6_gc_table(struct net *net,
|
||||
|
||||
hlist_for_each_entry_safe(rt, n, &tb6->tb6_gc_hlist, gc_link)
|
||||
if (fib6_age(rt, gc_args) == -1)
|
||||
fib6_del(rt, &info, RT_DEL_REASON_UNSPEC);
|
||||
fib6_del(rt, &info, RT_DEL_REASON_EXPIRED);
|
||||
}
|
||||
|
||||
static void fib6_gc_all(struct net *net, struct fib6_gc_args *gc_args)
|
||||
|
||||
@@ -1362,7 +1362,9 @@ static enum skb_drop_reason ndisc_router_discovery(struct sk_buff *skb)
|
||||
defrtr_usr_metric = in6_dev->cnf.ra_defrtr_metric;
|
||||
/* delete the route if lifetime is 0 or if metric needs change */
|
||||
if (rt && (lifetime == 0 || rt->fib6_metric != defrtr_usr_metric)) {
|
||||
ip6_del_rt(net, rt, false);
|
||||
ip6_del_rt_reason(net, rt,
|
||||
lifetime == 0 ? RT_DEL_REASON_RA_WITHDRAWN :
|
||||
RT_DEL_REASON_UNSPEC);
|
||||
rt = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -1020,7 +1020,7 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,
|
||||
gwaddr, dev);
|
||||
|
||||
if (rt && !lifetime) {
|
||||
ip6_del_rt(net, rt, false);
|
||||
ip6_del_rt_reason(net, rt, RT_DEL_REASON_RA_WITHDRAWN);
|
||||
rt = NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user