From: Yuyang Huang <sigefriedhyy@gmail.com>
To: Yuyang Huang <sigefriedhyy@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Bobby Eshleman <bobbyeshleman@meta.com>,
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>, Gal Pressman <gal@nvidia.com>,
Ido Schimmel <idosch@nvidia.com>,
Jakub Kicinski <kuba@kernel.org>, Nimrod Oren <noren@nvidia.com>,
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 v5 01/10] ipv6: add ip6_del_rt_reason()
Date: Tue, 4 Aug 2026 10:47:05 +0900 [thread overview]
Message-ID: <20260804014714.4362-2-sigefriedhyy@gmail.com> (raw)
In-Reply-To: <20260804014714.4362-1-sigefriedhyy@gmail.com>
Add RTA_DEL_REASON and enum rt_del_reason to the rtnetlink uAPI, and
add ip6_del_rt_reason(), which takes the reason a route is being
deleted. It has no skip_notify argument: a caller that records a
deletion reason wants the notification that carries it.
The reason is unused for now. Subsequent patches propagate it to the
deletion path and report it on RTM_DELROUTE.
Signed-off-by: Yuyang Huang <sigefriedhyy@gmail.com>
---
include/net/ip6_route.h | 2 ++
include/uapi/linux/rtnetlink.h | 22 ++++++++++++++++++++++
net/ipv6/route.c | 8 ++++++++
3 files changed, 32 insertions(+)
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 09ffe0f13ce7..7bcf0e5bd887 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -128,6 +128,8 @@ int ip6_route_add(struct fib6_config *cfg, gfp_t gfp_flags,
int ip6_ins_rt(struct net *net, struct fib6_info *f6i);
#if IS_ENABLED(CONFIG_IPV6)
int ip6_del_rt(struct net *net, struct fib6_info *f6i, bool skip_notify);
+int ip6_del_rt_reason(struct net *net, struct fib6_info *f6i,
+ enum rt_del_reason del_reason);
#else
static inline int ip6_del_rt(struct net *net, struct fib6_info *f6i,
bool skip_notify)
diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h
index 27265fd31e5f..66cfc17ede0e 100644
--- a/include/uapi/linux/rtnetlink.h
+++ b/include/uapi/linux/rtnetlink.h
@@ -399,6 +399,7 @@ enum rtattr_type_t {
RTA_DPORT,
RTA_NH_ID,
RTA_FLOWLABEL,
+ RTA_DEL_REASON,
__RTA_MAX
};
@@ -407,6 +408,27 @@ enum rtattr_type_t {
#define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
#define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
+/* RTA_DEL_REASON: why the kernel deleted the route. u32.
+ * Emitted only on RTM_DELROUTE notifications, and only when the deletion
+ * path records a cause. Absence means either an older kernel or a
+ * deletion path that does not (yet) record its cause - consumers must
+ * treat "absent" and "unspec" identically. New causes may be appended.
+ * Currently only IPv6 deletion paths record a cause.
+ *
+ * The value space is family-agnostic: a value must never be
+ * reinterpreted per address family. A cause that only one family can
+ * produce still gets its own value rather than reusing another
+ * family's.
+ */
+enum rt_del_reason {
+ RT_DEL_REASON_UNSPEC, /* cause not recorded */
+ RT_DEL_REASON_EXPIRED, /* RTF_EXPIRES lifetime ran out (GC) */
+ RT_DEL_REASON_RA_WITHDRAWN, /* zero-lifetime RA / PIO / RIO */
+ __RT_DEL_REASON_MAX
+};
+
+#define RT_DEL_REASON_MAX (__RT_DEL_REASON_MAX - 1)
+
/* RTM_MULTIPATH --- array of struct rtnexthop.
*
* "struct rtnexthop" describes all necessary nexthop information,
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index fc42d67e5822..ca374b056f5a 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -4004,6 +4004,14 @@ int ip6_del_rt(struct net *net, struct fib6_info *rt, bool skip_notify)
return __ip6_del_rt(rt, &info);
}
+int ip6_del_rt_reason(struct net *net, struct fib6_info *rt,
+ enum rt_del_reason del_reason)
+{
+ struct nl_info info = { .nl_net = net };
+
+ return __ip6_del_rt(rt, &info);
+}
+
static int __ip6_del_rt_siblings(struct fib6_info *rt, struct fib6_config *cfg)
{
struct nl_info *info = &cfg->fc_nlinfo;
--
2.43.0
next prev parent reply other threads:[~2026-08-04 1:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 1:47 [PATCH net-next v5 00/10] ipv6: report why a route was deleted in RTM_DELROUTE Yuyang Huang
2026-08-04 1:47 ` Yuyang Huang [this message]
2026-08-07 16:21 ` [PATCH net-next v5 01/10] ipv6: add ip6_del_rt_reason() Ido Schimmel
2026-08-08 0:37 ` Yuyang Huang
2026-08-04 1:47 ` [PATCH net-next v5 02/10] ipv6: propagate the route deletion reason to fib6_del_route() Yuyang Huang
2026-08-07 16:22 ` Ido Schimmel
2026-08-04 1:47 ` [PATCH net-next v5 03/10] ipv6: record the reason for kernel-initiated route deletions Yuyang Huang
2026-08-07 16:22 ` Ido Schimmel
2026-08-04 1:47 ` [PATCH net-next v5 04/10] ipv6: add a deletion reason argument to rt6_fill_node() Yuyang Huang
2026-08-07 16:22 ` Ido Schimmel
2026-08-04 1:47 ` [PATCH net-next v5 05/10] ipv6: expose the route deletion reason in RTM_DELROUTE Yuyang Huang
2026-08-07 16:23 ` Ido Schimmel
2026-08-04 1:47 ` [PATCH net-next v5 06/10] ipv6: add inet6_rt_del_notify() Yuyang Huang
2026-08-07 16:23 ` Ido Schimmel
2026-08-04 1:47 ` [PATCH net-next v5 07/10] netlink: specs: rt-route: add route notifications Yuyang Huang
2026-08-04 1:47 ` [PATCH net-next v5 08/10] netlink: specs: rt-route: split out the request attribute list Yuyang Huang
2026-08-04 1:47 ` [PATCH net-next v5 09/10] netlink: specs: rt-route: add the route deletion reason Yuyang Huang
2026-08-04 1:47 ` [PATCH net-next v5 10/10] selftests: net: verify RTA_DEL_REASON on route deletion Yuyang Huang
2026-08-05 10:41 ` [PATCH net-next v5 00/10] ipv6: report why a route was deleted in RTM_DELROUTE Yuyang Huang
2026-08-07 10:11 ` Yuyang Huang
2026-08-07 15:52 ` Ido Schimmel
2026-08-08 0:36 ` 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=20260804014714.4362-2-sigefriedhyy@gmail.com \
--to=sigefriedhyy@gmail.com \
--cc=bobbyeshleman@meta.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=gal@nvidia.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=noren@nvidia.com \
--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