From: Yuyang Huang <sigefriedhyy@gmail.com>
To: Yuyang Huang <sigefriedhyy@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Chris J Arges <carges@cloudflare.com>,
Daniel Zahka <daniel.zahka@gmail.com>,
David Ahern <dsahern@kernel.org>, David Wei <dw@davidwei.uk>,
Dimitri Daskalakis <dimitri.daskalakis1@gmail.com>,
Donald Hunter <donald.hunter@gmail.com>,
Eric Dumazet <edumazet@google.com>,
Ido Schimmel <idosch@nvidia.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Shuah Khan <shuah@kernel.org>, Simon Horman <horms@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>,
Willem de Bruijn <willemb@google.com>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
netdev@vger.kernel.org
Subject: [PATCH net-next v6 03/10] ipv6: record the reason for kernel-initiated route deletions
Date: Sat, 8 Aug 2026 09:56:35 +0900 [thread overview]
Message-ID: <20260808005642.26901-4-sigefriedhyy@gmail.com> (raw)
In-Reply-To: <20260808005642.26901-1-sigefriedhyy@gmail.com>
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>
---
net/ipv6/addrconf.c | 3 ++-
net/ipv6/ip6_fib.c | 2 +-
net/ipv6/ndisc.c | 4 +++-
net/ipv6/route.c | 2 +-
4 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index f6fa2715b450..9d89be7e0544 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -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;
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 1f6f6f33ded1..f8a9ec7fa616 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -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)
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index fe36b3f51285..1111c4ebc61d 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1361,7 +1361,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;
}
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 252f1825a199..bb14d7f7bad4 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -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;
}
--
2.43.0
next prev parent reply other threads:[~2026-08-08 0:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-08 0:56 [PATCH net-next v6 00/10] ipv6: report why a route was deleted in RTM_DELROUTE Yuyang Huang
2026-08-08 0:56 ` [PATCH net-next v6 01/10] ipv6: add ip6_del_rt_reason() Yuyang Huang
2026-08-09 8:50 ` Ido Schimmel
2026-08-09 12:30 ` Yuyang Huang
2026-08-08 0:56 ` [PATCH net-next v6 02/10] ipv6: propagate the route deletion reason to fib6_del_route() Yuyang Huang
2026-08-08 0:56 ` Yuyang Huang [this message]
2026-08-08 0:56 ` [PATCH net-next v6 04/10] ipv6: add a deletion reason argument to rt6_fill_node() Yuyang Huang
2026-08-08 0:56 ` [PATCH net-next v6 05/10] ipv6: expose the route deletion reason in RTM_DELROUTE Yuyang Huang
2026-08-08 0:56 ` [PATCH net-next v6 06/10] ipv6: add inet6_rt_del_notify() Yuyang Huang
2026-08-08 0:56 ` [PATCH net-next v6 07/10] netlink: specs: rt-route: add route notifications Yuyang Huang
2026-08-08 0:56 ` [PATCH net-next v6 08/10] netlink: specs: rt-route: split out the request attribute list Yuyang Huang
2026-08-08 0:56 ` [PATCH net-next v6 09/10] netlink: specs: rt-route: add the route deletion reason Yuyang Huang
2026-08-08 0:56 ` [PATCH net-next v6 10/10] selftests: net: verify RTA_DEL_REASON on route deletion Yuyang Huang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260808005642.26901-4-sigefriedhyy@gmail.com \
--to=sigefriedhyy@gmail.com \
--cc=carges@cloudflare.com \
--cc=daniel.zahka@gmail.com \
--cc=davem@davemloft.net \
--cc=dimitri.daskalakis1@gmail.com \
--cc=donald.hunter@gmail.com \
--cc=dsahern@kernel.org \
--cc=dw@davidwei.uk \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox