From: Ralf Lici <ralf@mandelbit.com>
To: netdev@vger.kernel.org
Cc: David Ahern <dsahern@kernel.org>,
Ido Schimmel <idosch@nvidia.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
Simon Horman <horms@kernel.org>,
linux-kernel@vger.kernel.org,
Antonio Quartulli <antonio@mandelbit.com>
Subject: [PATCH net-next 1/2] ipv6: stamp the default route node with a fresh serial on link failure
Date: Fri, 4 Dec 2026 12:28:03 +0100 [thread overview]
Message-ID: <9b0213020e4e2965acea95513181eba738a54a38.1796382778.git.ralf@mandelbit.com> (raw)
In-Reply-To: <cover.1796382778.git.ralf@mandelbit.com>
ip6_link_failure invalidates the cached dsts of an RTF_DEFAULT route by
writing -1 into the node's fn_sernum. Once the node already holds -1,
another link failure leaves the serial unchanged, so dsts cached with
that cookie can survive subsequent failures. The assignment also leaves
net->ipv6.fib6_sernum unchanged, and -1 is outside the range that
fib6_new_sernum allocates from, so the serial cannot be ordered against
the namespace generation.
Use fib6_update_sernum under tb6_lock to allocate and stamp a fresh
serial instead.
Advancing the namespace generation also invalidates unrelated dsts using
nexthop objects, which are validated against that generation. This
happens once per ip6_link_failure call: once per queued skb when the
neighbour of the default router fails, and once per packet on the
tunnel transmit error paths that call dst_link_failure, some of which a
remote host can trigger with ICMP errors. These are error paths and add
no cost to the fast path.
This is a preparation for validating dsts by comparing serials by age,
which needs every node serial to come from fib6_new_sernum.
Signed-off-by: Ralf Lici <ralf@mandelbit.com>
---
net/ipv6/route.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index d3c77941d2cf..b641df277483 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1532,9 +1532,11 @@ static struct rt6_info *rt6_make_pcpu_route(struct net *net,
*/
static DEFINE_SPINLOCK(rt6_exception_lock);
-/* Exceptions are accounted to the netns their dst was allocated in.
- * Unlike dev_net(dst->dev), it does not change when the device moves to
- * another netns or when dst_dev_put() points the dst to blackhole_netdev.
+/* Return the netns the dst was allocated in, which owns the fib6 table of
+ * its route. Exceptions are accounted to it, and ip6_link_failure advances
+ * its generation. Unlike dev_net(dst->dev), it does not change when the
+ * device moves to another netns or when dst_dev_put() points the dst to
+ * blackhole_netdev.
*/
static struct net *rt6_exception_net(const struct rt6_info *rt)
{
@@ -2874,13 +2876,13 @@ static void ip6_link_failure(struct sk_buff *skb)
rt6_remove_exception_rt(rt);
} else {
struct fib6_info *from;
- struct fib6_node *fn;
from = rcu_dereference(rt->from);
- if (from) {
- fn = rcu_dereference(from->fib6_node);
- if (fn && (rt->rt6i_flags & RTF_DEFAULT))
- WRITE_ONCE(fn->fn_sernum, -1);
+ if (from && from->fib6_table &&
+ (rt->rt6i_flags & RTF_DEFAULT)) {
+ spin_lock_bh(&from->fib6_table->tb6_lock);
+ fib6_update_sernum(rt6_exception_net(rt), from);
+ spin_unlock_bh(&from->fib6_table->tb6_lock);
}
}
rcu_read_unlock();
--
2.56.1
next prev parent reply other threads:[~2026-12-04 11:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 11:28 [PATCH net-next 0/2] ipv6: keep fib6 node serials from going backwards Ralf Lici
2026-12-04 11:28 ` Ralf Lici [this message]
2026-12-05 11:47 ` [PATCH net-next 1/2] ipv6: stamp the default route node with a fresh serial on link failure netdev-bot+sashiko
2026-12-06 10:22 ` Ralf Lici
2026-12-04 11:28 ` [PATCH net-next 2/2] ipv6: allocate the flush serial under each table's lock Ralf Lici
2026-12-05 11:47 ` netdev-bot+sashiko
2026-12-06 10:25 ` Ralf Lici
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=9b0213020e4e2965acea95513181eba738a54a38.1796382778.git.ralf@mandelbit.com \
--to=ralf@mandelbit.com \
--cc=antonio@mandelbit.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--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
all inboxes | Powered by JetHome®