Netdev List
 help / color / mirror / Atom feed
* [RFC net-next v2 0/7] ipv6: validate dsts against the netns route generation at lookup
@ 2026-11-23 21:26 David Ahern
  2026-11-23 21:26 ` [RFC net-next v2 1/7] ipv6: validate dsts against the netns route generation David Ahern
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: David Ahern @ 2026-11-23 21:26 UTC (permalink / raw)
  To: netdev; +Cc: ralf, David Ahern

From: David Ahern <dahern@nvidia.com>

IPv6 dsts are validated in ip6_dst_check() against a cookie that the holder
(socket, dst_cache, xfrm bundle, ...) samples from rt->from's fib6_node
(fn_sernum) when it stores the dst. That is later than the lookup that
produced the dst, which allows this sequence:

  CPU0                                  CPU1
  ----                                  ----
  lookup returns Dold
                                        add a more-specific route (e.g. a
                                        blackhole /128), bump fn_sernum
  rt6_get_cookie(Dold) reads the new
  fn_sernum
  publish (Dold, new cookie)

The next dst_check() compares the cookie with the same node's current
fn_sernum and accepts Dold, which keeps bypassing the more-specific route
indefinitely. The same late sampling exists in every persistent cache
(socket TX/RX, xfrm, dst_cache users, SCTP, flowtable, IPVS, RXE), so
fixing each user would leave future users exposed. This is the problem
described in the thread where ovpn hit it.

This series moves the validity into the dst, as IPv4 does with rt_genid:

 1. every dst carries the netns route generation it was built under and
    ip6_dst_check() compares it with the current one; holders no longer
    contribute a token.
 2-5. keep invalidation targeted where it was before: ip6_link_failure()
    clears the failing dst's sernum, nexthop group changes bump the
    generation, and PMTU/redirect exceptions invalidate only the pcpu
    dsts of the affected nexthop, as IPv4 does for fnhe.
 6. rt_genid_bump_ipv6() becomes a counter increment like its IPv4
    counterpart instead of walking every tree to rewrite fn_sernum.
 7. the generation is sampled before the FIB is read and carried in
    struct fib6_result, so a dst and the FIB lookup that produced it
    refer to the same point in time. Without this a change landing between
    the lookup and the allocation is folded into the stamp.

Long-lived dsts are never re-stamped: pcpu and exception dsts are shared
by all holders, so re-stamping one would make it valid again for every
socket and dst_cache that already saw it as stale. A stale pcpu dst is
dropped and rebuilt; a stale exception is treated as a miss. This is the
same behaviour as IPv4, where a stale cached route fails rt_cache_valid()
and a new one is allocated.

Known trade-off: any FIB change in a netns now invalidates every cached
IPv6 dst in it, not just those under the affected node; stale dsts are
rebuilt lazily on their next use.

Changes since v1:
 - Do not re-stamp pcpu and exception dsts when a lookup finds them again
   (patch 1); that made stale dsts valid again for other holders.
 - New patch 7: sample the generation before the FIB lookup.
 - Updated the patch 1 commit message to match.

AI assistance: Claude (Sonnet 5.5) helped develop these patches. I have
reviewed them and take responsibility for them.

Ralf: Patch 7 is alternative to your patch that adds the cookie to the
APIs. Instead the result struct contains the genid before the lookup is
done. Adding it to the fib6_result seems simpler and accomplishes the
end goal everywhere.

David Ahern (7):
  ipv6: validate dsts against the netns route generation
  ipv6: invalidate the failing dst in ip6_link_failure()
  nexthop: factor out nh_has_f6i()
  nexthop: bump the IPv6 route generation on group changes
  ipv6: scope exception invalidation to the affected nexthop
  ipv6: make rt_genid_bump_ipv6() a plain counter increment
  ipv6: stamp dsts with the generation sampled before the FIB lookup

 include/net/ip6_fib.h       |  50 +++++------------
 include/net/net_namespace.h |  36 ++++++++++---
 net/ipv4/nexthop.c          |  42 ++++++++++++---
 net/ipv6/addrconf_core.c    |   7 ---
 net/ipv6/ip6_fib.c          |  76 +++++++++++---------------
 net/ipv6/route.c            | 105 ++++++++++++++++++++++++------------
 6 files changed, 178 insertions(+), 138 deletions(-)

-- 
2.43.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [RFC net-next v2 1/7] ipv6: validate dsts against the netns route generation
  2026-11-23 21:26 [RFC net-next v2 0/7] ipv6: validate dsts against the netns route generation at lookup David Ahern
@ 2026-11-23 21:26 ` David Ahern
  2026-11-23 21:26 ` [RFC net-next v2 2/7] ipv6: invalidate the failing dst in ip6_link_failure() David Ahern
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: David Ahern @ 2026-11-23 21:26 UTC (permalink / raw)
  To: netdev; +Cc: ralf, David Ahern

From: David Ahern <dahern@nvidia.com>

An rt6_info never carried the fib6 serial number it was created
under. rt6_get_cookie() read fn->fn_sernum through rt->from at the time a
socket, dst_cache or xfrm bundle stored its cookie, so a change that
landed between route lookup and cookie capture was folded into the
cookie and a stale dst looked valid. Only nexthop-object pcpu routes
were stamped at creation, with the same counter.

net->ipv6.fib6_sernum is already the counter that rt_genid_ipv6()
reads and that every FIB change bumps. Stamp every dst with it in
ip6_dst_alloc() and validate with a plain comparison in
ip6_dst_check(); the remaining checks are that the fib6_info is still
in the tree and not expired. rt6_get_cookie() now returns rt->sernum
and fib6_get_cookie_safe() goes away. fn_sernum stays for route dump
consistency.

Validity lives in the dst, so a long-lived dst is never re-stamped by
a later lookup: pcpu and exception dsts are shared by every socket and
dst_cache that holds them, and re-stamping would make a stale dst valid
again for all of them. IPv4 does the same: a stale cached route fails
rt_cache_valid() and a new one is allocated, while holders of the old
one keep seeing it as stale. Likewise here:

 - a pcpu dst that fails the check is dropped from the pcpu slot and
   rebuilt by rt6_make_pcpu_route().
 - an exception dst that fails the check is treated as a miss by
   rt6_find_cached_rt().

The smp_wmb() in __fib6_update_sernum_upto_root() paired with the
smp_rmb() in fib6_get_cookie_safe(), so that a lockless reader that saw
a new fn_sernum also saw the route inserted before it. That reader is
gone. The remaining fn_sernum readers, the route dumps, take tb6_lock
after reading it and the writers hold it, so drop the barrier.

ip6_link_failure() still writes fn_sernum, which no longer
invalidates anything; that is addressed in the next patch.

Signed-off-by: David Ahern <dahern@nvidia.com>
---
Changes since v1:
- Do not re-stamp pcpu and exception dsts when a lookup finds them
  again (drop rt6_refresh_sernum()); a stale pcpu dst is dropped and
  rebuilt, a stale exception is treated as a miss.
- Commit message updated to match.

 include/net/ip6_fib.h | 42 ++++-----------------------------
 net/ipv6/ip6_fib.c    |  2 --
 net/ipv6/route.c      | 55 ++++++++++++++++++++++---------------------
 3 files changed, 32 insertions(+), 67 deletions(-)

diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 232289b439c3..ecce7ab007a5 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -273,46 +273,12 @@ static inline bool fib6_check_expired(const struct fib6_info *f6i)
 	return false;
 }
 
-/* Function to safely get fn->fn_sernum for passed in rt
- * and store result in passed in cookie.
- * Return true if we can get cookie safely
- * Return false if not
- */
-static inline bool fib6_get_cookie_safe(const struct fib6_info *f6i,
-					u32 *cookie)
-{
-	struct fib6_node *fn;
-	bool status = false;
-
-	fn = rcu_dereference(f6i->fib6_node);
-
-	if (fn) {
-		*cookie = READ_ONCE(fn->fn_sernum);
-		/* pairs with smp_wmb() in __fib6_update_sernum_upto_root() */
-		smp_rmb();
-		status = true;
-	}
-
-	return status;
-}
-
 static inline u32 rt6_get_cookie(const struct rt6_info *rt)
 {
-	struct fib6_info *from;
-	u32 cookie = 0;
-
-	if (rt->sernum)
-		return rt->sernum;
-
-	rcu_read_lock();
-
-	from = rcu_dereference(rt->from);
-	if (from)
-		fib6_get_cookie_safe(from, &cookie);
-
-	rcu_read_unlock();
-
-	return cookie;
+	/* sernum is the netns route generation the dst was created or last
+	 * revalidated under; ip6_dst_check() compares it to the current one.
+	 */
+	return READ_ONCE(rt->sernum);
 }
 
 static inline void ip6_rt_put(struct rt6_info *rt)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index e1d49897d6ab..d465ac6ffbc6 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -1432,8 +1432,6 @@ static void __fib6_update_sernum_upto_root(struct fib6_info *rt,
 	struct fib6_node *fn = rcu_dereference_protected(rt->fib6_node,
 				lockdep_is_held(&rt->fib6_table->tb6_lock));
 
-	/* paired with smp_rmb() in fib6_get_cookie_safe() */
-	smp_wmb();
 	while (fn) {
 		WRITE_ONCE(fn->fn_sernum, sernum);
 		fn = rcu_dereference_protected(fn->parent,
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 4a4c5ace63c5..6fa76c95b1d2 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -367,6 +367,7 @@ struct rt6_info *ip6_dst_alloc(struct net *net, struct net_device *dev,
 
 	if (rt) {
 		rt6_info_init(rt);
+		rt->sernum = rt_genid_ipv6(net);
 		atomic_inc(&net->ipv6.rt6_stats->fib_rt_alloc);
 	}
 
@@ -1458,15 +1459,12 @@ static struct rt6_info *ip6_rt_pcpu_alloc(const struct fib6_result *res)
 	ip6_rt_copy_init(pcpu_rt, res);
 	pcpu_rt->rt6i_flags |= RTF_PCPU;
 
-	if (f6i->nh)
-		pcpu_rt->sernum = rt_genid_ipv6(dev_net(dev));
-
 	return pcpu_rt;
 }
 
 static bool rt6_is_valid(const struct rt6_info *rt6)
 {
-	return rt6->sernum == rt_genid_ipv6(dev_net(rt6->dst.dev));
+	return READ_ONCE(rt6->sernum) == rt_genid_ipv6(dev_net(rt6->dst.dev));
 }
 
 /* It should be called with rcu_read_lock() acquired */
@@ -1476,7 +1474,11 @@ static struct rt6_info *rt6_get_pcpu_route(const struct fib6_result *res)
 
 	pcpu_rt = this_cpu_read(*res->nh->rt6i_pcpu);
 
-	if (pcpu_rt && pcpu_rt->sernum && !rt6_is_valid(pcpu_rt)) {
+	/* A dst stamped with an older genid stays stale for everyone still
+	 * holding it, as in IPv4. Never re-stamp it; drop it and build a
+	 * new one.
+	 */
+	if (pcpu_rt && !rt6_is_valid(pcpu_rt)) {
 		struct rt6_info *prev, **p;
 
 		p = this_cpu_ptr(res->nh->rt6i_pcpu);
@@ -1878,8 +1880,14 @@ static struct rt6_info *rt6_find_cached_rt(const struct fib6_result *res,
 	bucket = fib6_nh_get_excptn_bucket(res->nh, NULL);
 	rt6_ex = __rt6_find_exception_rcu(&bucket, daddr, src_key);
 
-	if (rt6_ex && !rt6_check_expired(rt6_ex->rt6i))
+	if (rt6_ex && !rt6_check_expired(rt6_ex->rt6i)) {
 		ret = rt6_ex->rt6i;
+		/* Do not re-stamp a stale exception: other holders must
+		 * keep seeing it as stale. Treat it as a miss instead.
+		 */
+		if (!rt6_is_valid(ret))
+			ret = NULL;
+	}
 
 #ifdef CONFIG_IPV6_SUBTREES
 	/* Use fib6_src as src_key and redo lookup */
@@ -2767,27 +2775,18 @@ struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_ori
  *	Destination cache support functions
  */
 
-static bool fib6_check(struct fib6_info *f6i, u32 cookie)
+static bool fib6_check(struct fib6_info *f6i)
 {
-	u32 rt_cookie = 0;
-
-	if (!fib6_get_cookie_safe(f6i, &rt_cookie) || rt_cookie != cookie)
-		return false;
-
-	if (fib6_check_expired(f6i))
+	if (!rcu_access_pointer(f6i->fib6_node))
 		return false;
 
-	return true;
+	return !fib6_check_expired(f6i);
 }
 
 static struct dst_entry *rt6_check(struct rt6_info *rt,
-				   struct fib6_info *from,
-				   u32 cookie)
+				   struct fib6_info *from)
 {
-	u32 rt_cookie = 0;
-
-	if (!from || !fib6_get_cookie_safe(from, &rt_cookie) ||
-	    rt_cookie != cookie)
+	if (!from || !rcu_access_pointer(from->fib6_node))
 		return NULL;
 
 	if (rt6_check_expired(rt))
@@ -2797,12 +2796,11 @@ static struct dst_entry *rt6_check(struct rt6_info *rt,
 }
 
 static struct dst_entry *rt6_dst_from_check(struct rt6_info *rt,
-					    struct fib6_info *from,
-					    u32 cookie)
+					    struct fib6_info *from)
 {
 	if (!__rt6_check_expired(rt) &&
 	    READ_ONCE(rt->dst.obsolete) == DST_OBSOLETE_FORCE_CHK &&
-	    fib6_check(from, cookie))
+	    fib6_check(from))
 		return &rt->dst;
 	return NULL;
 }
@@ -2816,8 +2814,11 @@ INDIRECT_CALLABLE_SCOPE struct dst_entry *ip6_dst_check(struct dst_entry *dst,
 
 	rt = dst_rt6_info(dst);
 
-	if (rt->sernum)
-		return rt6_is_valid(rt) ? dst : NULL;
+	/* Any FIB change bumps the netns generation, which invalidates
+	 * every dst created under an older one.
+	 */
+	if (!rt6_is_valid(rt))
+		return NULL;
 
 	rcu_read_lock();
 
@@ -2830,9 +2831,9 @@ INDIRECT_CALLABLE_SCOPE struct dst_entry *ip6_dst_check(struct dst_entry *dst,
 
 	if (from && (rt->rt6i_flags & RTF_PCPU ||
 	    unlikely(rt->dst.rt_uncached_list)))
-		dst_ret = rt6_dst_from_check(rt, from, cookie);
+		dst_ret = rt6_dst_from_check(rt, from);
 	else
-		dst_ret = rt6_check(rt, from, cookie);
+		dst_ret = rt6_check(rt, from);
 
 	rcu_read_unlock();
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC net-next v2 2/7] ipv6: invalidate the failing dst in ip6_link_failure()
  2026-11-23 21:26 [RFC net-next v2 0/7] ipv6: validate dsts against the netns route generation at lookup David Ahern
  2026-11-23 21:26 ` [RFC net-next v2 1/7] ipv6: validate dsts against the netns route generation David Ahern
@ 2026-11-23 21:26 ` David Ahern
  2026-11-23 21:26 ` [RFC net-next v2 3/7] nexthop: factor out nh_has_f6i() David Ahern
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: David Ahern @ 2026-11-23 21:26 UTC (permalink / raw)
  To: netdev; +Cc: ralf, David Ahern

From: David Ahern <dahern@nvidia.com>

When a default route's neighbour fails, ip6_link_failure() wrote -1
to the fn_sernum of the route's node so that users of dsts under that
node would look the route up again and let router selection pick
another default router.

dsts are now validated against the netns route generation, so that
write no longer invalidates anything. Clear the sernum of the failing
dst instead; 0 never matches the generation, so its users do the
lookup again. Only that dst is invalidated, which for a pcpu dst is
one CPU's copy, rather than every dst under the node. Bumping the
netns generation here would be much costlier, since a failing router
can trigger this for every packet sent through it.

Signed-off-by: David Ahern <dahern@nvidia.com>
---
Changes since v1:
- None.

 net/ipv6/route.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 6fa76c95b1d2..a132d33259a2 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2874,14 +2874,13 @@ static void ip6_link_failure(struct sk_buff *skb)
 			rt6_remove_exception_rt(rt);
 		} else {
 			struct fib6_info *from;
-			struct fib6_node *fn;
 
+			/* Force sockets using this dst to look the route up
+			 * again; 0 never matches the netns generation.
+			 */
 			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 && (rt->rt6i_flags & RTF_DEFAULT))
+				WRITE_ONCE(rt->sernum, 0);
 		}
 		rcu_read_unlock();
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC net-next v2 3/7] nexthop: factor out nh_has_f6i()
  2026-11-23 21:26 [RFC net-next v2 0/7] ipv6: validate dsts against the netns route generation at lookup David Ahern
  2026-11-23 21:26 ` [RFC net-next v2 1/7] ipv6: validate dsts against the netns route generation David Ahern
  2026-11-23 21:26 ` [RFC net-next v2 2/7] ipv6: invalidate the failing dst in ip6_link_failure() David Ahern
@ 2026-11-23 21:26 ` David Ahern
  2026-11-23 21:26 ` [RFC net-next v2 4/7] nexthop: bump the IPv6 route generation on group changes David Ahern
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: David Ahern @ 2026-11-23 21:26 UTC (permalink / raw)
  To: netdev; +Cc: ralf, David Ahern

From: David Ahern <dahern@nvidia.com>

nh_rt_cache_flush() open codes a locked check of whether any IPv6
routes use a nexthop. Move it into a helper, placed ahead of
remove_nexthop_from_groups(), so the next patch can use it there as
well.

No functional change.

Signed-off-by: David Ahern <dahern@nvidia.com>
---
Changes since v1:
- None.

 net/ipv4/nexthop.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 42e55b5a755e..53431fe7d328 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -2109,6 +2109,17 @@ remove_nh_grp_entry(struct net *net, struct nh_grp_entry *nhge,
 	return false;
 }
 
+static bool nh_has_f6i(struct nexthop *nh)
+{
+	bool have_f6i;
+
+	spin_lock_bh(&nh->lock);
+	have_f6i = !list_empty(&nh->f6i_list);
+	spin_unlock_bh(&nh->lock);
+
+	return have_f6i;
+}
+
 static bool __must_check
 remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
 			   struct nl_info *nlinfo)
@@ -2248,16 +2259,12 @@ static void nh_rt_cache_flush(struct net *net, struct nexthop *nh,
 			      struct nexthop *replaced_nh)
 {
 	struct nh_group *nhg;
-	bool have_f6i;
 	int i;
 
 	if (!list_empty(&nh->fi_list))
 		rt_cache_flush(net);
 
-	spin_lock_bh(&nh->lock);
-	have_f6i = !list_empty(&nh->f6i_list);
-	spin_unlock_bh(&nh->lock);
-	if (have_f6i)
+	if (nh_has_f6i(nh))
 		rt_genid_bump_ipv6(net);
 
 	/* if an IPv6 group was replaced, we have to release all old
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC net-next v2 4/7] nexthop: bump the IPv6 route generation on group changes
  2026-11-23 21:26 [RFC net-next v2 0/7] ipv6: validate dsts against the netns route generation at lookup David Ahern
                   ` (2 preceding siblings ...)
  2026-11-23 21:26 ` [RFC net-next v2 3/7] nexthop: factor out nh_has_f6i() David Ahern
@ 2026-11-23 21:26 ` David Ahern
  2026-11-23 21:26 ` [RFC net-next v2 5/7] ipv6: scope exception invalidation to the affected nexthop David Ahern
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: David Ahern @ 2026-11-23 21:26 UTC (permalink / raw)
  To: netdev; +Cc: ralf, David Ahern

From: David Ahern <dahern@nvidia.com>

IPv6 dsts are invalidated by bumping the netns route generation, but
two nexthop object changes did not do so:

 - Replacing a nexthop that is a member of a group only bumped if the
   member itself had IPv6 routes, not when routes used a group
   containing it.
 - Removing a member from a group republishes the group array without
   any bump, so dsts built from the old group stayed valid.

Bump in both cases when IPv6 routes use the nexthop, directly or
through a group.

Signed-off-by: David Ahern <dahern@nvidia.com>
---
Changes since v1:
- None.

 net/ipv4/nexthop.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 53431fe7d328..7cf496589f4f 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -2120,6 +2120,21 @@ static bool nh_has_f6i(struct nexthop *nh)
 	return have_f6i;
 }
 
+/* true if IPv6 routes use @nh directly or through a group containing it */
+static bool nh_used_by_f6i(struct nexthop *nh)
+{
+	struct nh_grp_entry *nhge;
+
+	if (nh_has_f6i(nh))
+		return true;
+
+	list_for_each_entry(nhge, &nh->grp_list, nh_list)
+		if (nh_has_f6i(nhge->nh_parent))
+			return true;
+
+	return false;
+}
+
 static bool __must_check
 remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
 			   struct nl_info *nlinfo)
@@ -2127,6 +2142,7 @@ remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
 	struct nh_grp_entry *nhge, *tmp;
 	LIST_HEAD(deferred_free);
 	bool need_flush = false;
+	bool have_f6i = false;
 
 	/* If there is nothing to do, let's avoid the costly call to
 	 * synchronize_net()
@@ -2134,13 +2150,19 @@ remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
 	if (list_empty(&nh->grp_list))
 		return false;
 
-	list_for_each_entry_safe(nhge, tmp, &nh->grp_list, nh_list)
+	list_for_each_entry_safe(nhge, tmp, &nh->grp_list, nh_list) {
+		have_f6i |= nh_has_f6i(nhge->nh_parent);
 		need_flush |= remove_nh_grp_entry(net, nhge, nlinfo,
 						  &deferred_free);
+	}
 
 	/* make sure all see the newly published array before releasing rtnl */
 	synchronize_net();
 
+	/* a group lost a member: dsts built from the old group are stale */
+	if (have_f6i)
+		rt_genid_bump_ipv6(net);
+
 	/* Now safe to free percpu stats — all RCU readers have finished */
 	list_for_each_entry_safe(nhge, tmp, &deferred_free, nh_list) {
 		list_del(&nhge->nh_list);
@@ -2264,7 +2286,8 @@ static void nh_rt_cache_flush(struct net *net, struct nexthop *nh,
 	if (!list_empty(&nh->fi_list))
 		rt_cache_flush(net);
 
-	if (nh_has_f6i(nh))
+	/* dsts are validated against the netns route generation */
+	if (nh_used_by_f6i(nh))
 		rt_genid_bump_ipv6(net);
 
 	/* if an IPv6 group was replaced, we have to release all old
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC net-next v2 5/7] ipv6: scope exception invalidation to the affected nexthop
  2026-11-23 21:26 [RFC net-next v2 0/7] ipv6: validate dsts against the netns route generation at lookup David Ahern
                   ` (3 preceding siblings ...)
  2026-11-23 21:26 ` [RFC net-next v2 4/7] nexthop: bump the IPv6 route generation on group changes David Ahern
@ 2026-11-23 21:26 ` David Ahern
  2026-11-23 21:26 ` [RFC net-next v2 6/7] ipv6: make rt_genid_bump_ipv6() a plain counter increment David Ahern
  2026-11-23 21:26 ` [RFC net-next v2 7/7] ipv6: stamp dsts with the generation sampled before the FIB lookup David Ahern
  6 siblings, 0 replies; 8+ messages in thread
From: David Ahern @ 2026-11-23 21:26 UTC (permalink / raw)
  To: netdev; +Cc: ralf, David Ahern

From: David Ahern <dahern@nvidia.com>

rt6_insert_exception() bumped the netns route generation, which with
generation-based dst validation invalidates every dst in the
namespace each time a PMTU or redirect exception is created. A burst
of packet-too-big messages would make all sockets and dst_caches look
their routes up again.

IPv4 limits this to the nexthop: update_or_create_fnhe() marks only
that nexthop's cached dsts stale. Do the same here by clearing the
sernum of the fib6_nh's pcpu dsts, so their users look the route up
once and find the exception.

Route dumps notice a changed tree through the root node's fn_sernum,
and the exception dump relies on that changing when an exception is
inserted on the root. A fresh fn_sernum can only come from the netns
counter, which must not be bumped here, and a locally made-up value
could later be issued by the counter to the same node and go
unnoticed. Add a per-table tb6_excp_seq, bumped for exceptions on the
root node, and have fib6_dump_table() restart when either it or the
root's fn_sernum has changed.

Signed-off-by: David Ahern <dahern@nvidia.com>
---
Changes since v1:
- None.

 include/net/ip6_fib.h |  3 +++
 net/ipv6/ip6_fib.c    | 25 ++++++++++++++++++++++++-
 net/ipv6/route.c      | 27 +++++++++++++++++++++++++--
 3 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index ecce7ab007a5..92fed30a7418 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -329,6 +329,7 @@ struct fib6_walker {
 	unsigned int skip;
 	unsigned int count;
 	unsigned int skip_in_node;
+	unsigned int excp_seq;	/* tb6_excp_seq seen by a partial dump */
 	int (*func)(struct fib6_walker *);
 	void *args;
 };
@@ -362,6 +363,7 @@ struct fib6_table {
 	struct inet_peer_base	tb6_peers;
 	unsigned int		flags;
 	unsigned int		fib_seq; /* writes protected by rtnl_mutex */
+	unsigned int		tb6_excp_seq;	/* writes under tb6_lock */
 	struct hlist_head       tb6_gc_hlist;	/* GC candidates */
 #define RT6_TABLE_HAS_DFLT_ROUTER	BIT(0)
 };
@@ -583,6 +585,7 @@ int fib6_tables_dump(struct net *net, struct notifier_block *nb,
 		     struct netlink_ext_ack *extack);
 
 void fib6_update_sernum(struct net *net, struct fib6_info *rt);
+void fib6_update_excp_seq(struct fib6_info *rt);
 #if IS_ENABLED(CONFIG_IPV6)
 void fib6_update_sernum_upto_root(struct net *net, struct fib6_info *rt);
 #else
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index d465ac6ffbc6..266370e15774 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -148,6 +148,25 @@ void fib6_update_sernum(struct net *net, struct fib6_info *f6i)
 		WRITE_ONCE(fn->fn_sernum, fib6_new_sernum(net));
 }
 
+/* Tell route dumps that an exception was added under @f6i without
+ * invalidating cached dsts: those follow the netns generation, which this
+ * leaves alone. A dump notices a changed tree through the root node, so
+ * only an exception on the root needs to be visible. Fresh fn_sernum values
+ * can only come from the netns counter, so use a table sequence rather than
+ * a made-up fn_sernum that the counter could later issue again.
+ * Caller holds tb6_lock.
+ */
+void fib6_update_excp_seq(struct fib6_info *f6i)
+{
+	struct fib6_table *table = f6i->fib6_table;
+	struct fib6_node *fn;
+
+	fn = rcu_dereference_protected(f6i->fib6_node,
+				       lockdep_is_held(&table->tb6_lock));
+	if (fn == &table->tb6_root)
+		WRITE_ONCE(table->tb6_excp_seq, table->tb6_excp_seq + 1);
+}
+
 /*
  *	Auxiliary address test functions for the radix tree.
  *
@@ -637,12 +656,16 @@ static int fib6_dump_table(struct fib6_table *table, struct sk_buff *skb,
 		if (res > 0) {
 			cb->args[4] = 1;
 			cb->args[5] = READ_ONCE(w->root->fn_sernum);
+			w->excp_seq = READ_ONCE(table->tb6_excp_seq);
 		}
 	} else {
 		int sernum = READ_ONCE(w->root->fn_sernum);
-		if (cb->args[5] != sernum) {
+		unsigned int excp_seq = READ_ONCE(table->tb6_excp_seq);
+
+		if (cb->args[5] != sernum || w->excp_seq != excp_seq) {
 			/* Begin at the root if the tree changed */
 			cb->args[5] = sernum;
+			w->excp_seq = excp_seq;
 			w->state = FWS_INIT;
 			w->node = w->root;
 			w->skip = w->count;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index a132d33259a2..38d5f3bc85bb 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1717,6 +1717,28 @@ struct rt6_exception_bucket *fib6_nh_get_excptn_bucket(const struct fib6_nh *nh,
 	return bucket;
 }
 
+/* A new exception may apply to dsts already cached on @nh. Make them fail
+ * ip6_dst_check() once so their users look the route up again and find it;
+ * dsts of other routes are left alone.
+ */
+static void fib6_nh_invalidate_pcpu(const struct fib6_nh *nh)
+{
+	int cpu;
+
+	if (!nh->rt6i_pcpu)
+		return;
+
+	rcu_read_lock();
+	for_each_possible_cpu(cpu) {
+		struct rt6_info *pcpu_rt;
+
+		pcpu_rt = READ_ONCE(*per_cpu_ptr(nh->rt6i_pcpu, cpu));
+		if (pcpu_rt)
+			WRITE_ONCE(pcpu_rt->sernum, 0);
+	}
+	rcu_read_unlock();
+}
+
 static int rt6_insert_exception(struct rt6_info *nrt,
 				const struct fib6_result *res)
 {
@@ -1791,10 +1813,11 @@ static int rt6_insert_exception(struct rt6_info *nrt,
 out:
 	spin_unlock_bh(&rt6_exception_lock);
 
-	/* Update fn->fn_sernum to invalidate all cached dst */
 	if (!err) {
+		fib6_nh_invalidate_pcpu(nh);
+
 		spin_lock_bh(&f6i->fib6_table->tb6_lock);
-		fib6_update_sernum(net, f6i);
+		fib6_update_excp_seq(f6i);
 		fib6_add_gc_list(f6i);
 		spin_unlock_bh(&f6i->fib6_table->tb6_lock);
 		fib6_force_start_gc(net);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC net-next v2 6/7] ipv6: make rt_genid_bump_ipv6() a plain counter increment
  2026-11-23 21:26 [RFC net-next v2 0/7] ipv6: validate dsts against the netns route generation at lookup David Ahern
                   ` (4 preceding siblings ...)
  2026-11-23 21:26 ` [RFC net-next v2 5/7] ipv6: scope exception invalidation to the affected nexthop David Ahern
@ 2026-11-23 21:26 ` David Ahern
  2026-11-23 21:26 ` [RFC net-next v2 7/7] ipv6: stamp dsts with the generation sampled before the FIB lookup David Ahern
  6 siblings, 0 replies; 8+ messages in thread
From: David Ahern @ 2026-11-23 21:26 UTC (permalink / raw)
  To: netdev; +Cc: ralf, David Ahern

From: David Ahern <dahern@nvidia.com>

rt_genid_bump_ipv6() called fib6_flush_trees() through a function
pointer. That walked every node of every table to write a new
fn_sernum, so that cookies derived from fn_sernum would mismatch.

Cached dsts are now validated against net->ipv6.fib6_sernum itself,
so the walk no longer invalidates anything. Do what
rt_genid_bump_ipv4() does and increment the counter, keeping
fib6_new_sernum()'s wrap to 1 so the value is never 0.

This makes nexthop, address and FIB rule changes cheap, and stops
them from touching fn_sernum, which route dumps use to detect that a
tree changed: a dump is no longer restarted by events that do not
change the tree.

With the walk gone, drop the __fib6_flush_trees pointer and its
export, fib6_new_sernum() in favour of the new helper, and the sernum
handling in fib6_cleaner that only the walk used.

Signed-off-by: David Ahern <dahern@nvidia.com>
---
Changes since v1:
- None.

 include/net/net_namespace.h | 26 ++++++++++++++-----
 net/ipv6/addrconf_core.c    |  7 -----
 net/ipv6/ip6_fib.c          | 51 ++++++-------------------------------
 3 files changed, 27 insertions(+), 57 deletions(-)

diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 4a4d72080acd..f39baf51bcc5 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -556,18 +556,30 @@ static inline int rt_genid_ipv6(const struct net *net)
 {
 	return atomic_read(&net->ipv6.fib6_sernum);
 }
-#endif
 
-static inline void rt_genid_bump_ipv4(struct net *net)
+/* Invalidate every cached IPv6 dst in @net. Returns the new generation,
+ * which is never 0.
+ */
+static inline int rt_genid_bump_ipv6(struct net *net)
 {
-	atomic_inc(&net->ipv4.rt_genid);
+	int new, old = atomic_read(&net->ipv6.fib6_sernum);
+
+	do {
+		new = old < INT_MAX ? old + 1 : 1;
+	} while (!atomic_try_cmpxchg(&net->ipv6.fib6_sernum, &old, new));
+
+	return new;
 }
+#else
+static inline int rt_genid_bump_ipv6(struct net *net)
+{
+	return 0;
+}
+#endif
 
-extern void (*__fib6_flush_trees)(struct net *net);
-static inline void rt_genid_bump_ipv6(struct net *net)
+static inline void rt_genid_bump_ipv4(struct net *net)
 {
-	if (__fib6_flush_trees)
-		__fib6_flush_trees(net);
+	atomic_inc(&net->ipv4.rt_genid);
 }
 
 #if IS_ENABLED(CONFIG_IEEE802154_6LOWPAN)
diff --git a/net/ipv6/addrconf_core.c b/net/ipv6/addrconf_core.c
index 29095c90aa16..e7ee5f98327d 100644
--- a/net/ipv6/addrconf_core.c
+++ b/net/ipv6/addrconf_core.c
@@ -9,13 +9,6 @@
 #include <net/addrconf.h>
 #include <net/ip.h>
 
-/* if ipv6 module registers this function is used by xfrm to force all
- * sockets to relookup their nodes - this is fairly expensive, be
- * careful
- */
-void (*__fib6_flush_trees)(struct net *);
-EXPORT_SYMBOL(__fib6_flush_trees);
-
 #define IPV6_ADDR_SCOPE_TYPE(scope)	((scope) << 16)
 
 static inline unsigned int ipv6_addr_scope2type(unsigned int scope)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 266370e15774..75512fbcb945 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -43,7 +43,6 @@ struct fib6_cleaner {
 	struct fib6_walker w;
 	struct net *net;
 	int (*func)(struct fib6_info *, void *arg);
-	int sernum;
 	void *arg;
 	bool skip_notify;
 };
@@ -123,21 +122,6 @@ static void fib6_walkers_skip_rt(struct net *net, struct fib6_info *rt)
 	fib6_walkers_replace_leaf(net, rt, next);
 }
 
-static int fib6_new_sernum(struct net *net)
-{
-	int new, old = atomic_read(&net->ipv6.fib6_sernum);
-
-	do {
-		new = old < INT_MAX ? old + 1 : 1;
-	} while (!atomic_try_cmpxchg(&net->ipv6.fib6_sernum, &old, new));
-
-	return new;
-}
-
-enum {
-	FIB6_NO_SERNUM_CHANGE = 0,
-};
-
 void fib6_update_sernum(struct net *net, struct fib6_info *f6i)
 {
 	struct fib6_node *fn;
@@ -145,7 +129,7 @@ void fib6_update_sernum(struct net *net, struct fib6_info *f6i)
 	fn = rcu_dereference_protected(f6i->fib6_node,
 			lockdep_is_held(&f6i->fib6_table->tb6_lock));
 	if (fn)
-		WRITE_ONCE(fn->fn_sernum, fib6_new_sernum(net));
+		WRITE_ONCE(fn->fn_sernum, rt_genid_bump_ipv6(net));
 }
 
 /* Tell route dumps that an exception was added under @f6i without
@@ -1464,7 +1448,7 @@ static void __fib6_update_sernum_upto_root(struct fib6_info *rt,
 
 void fib6_update_sernum_upto_root(struct net *net, struct fib6_info *rt)
 {
-	__fib6_update_sernum_upto_root(rt, fib6_new_sernum(net));
+	__fib6_update_sernum_upto_root(rt, rt_genid_bump_ipv6(net));
 }
 
 /*
@@ -1595,7 +1579,7 @@ int fib6_add(struct fib6_node *root, struct fib6_info *rt,
 			fib6_info_release(iter);
 		}
 
-		__fib6_update_sernum_upto_root(rt, fib6_new_sernum(info->nl_net));
+		__fib6_update_sernum_upto_root(rt, rt_genid_bump_ipv6(info->nl_net));
 
 		if (rt->fib6_flags & RTF_EXPIRES)
 			fib6_add_gc_list(rt);
@@ -2282,16 +2266,6 @@ static int fib6_clean_node(struct fib6_walker *w)
 		.skip_notify = c->skip_notify,
 	};
 
-	if (c->sernum != FIB6_NO_SERNUM_CHANGE &&
-	    READ_ONCE(w->node->fn_sernum) != c->sernum)
-		WRITE_ONCE(w->node->fn_sernum, c->sernum);
-
-	if (!c->func) {
-		WARN_ON_ONCE(c->sernum == FIB6_NO_SERNUM_CHANGE);
-		w->leaf = NULL;
-		return 0;
-	}
-
 	for_each_fib6_walker_rt(w) {
 		res = c->func(rt, c->arg);
 		if (res == -1) {
@@ -2331,7 +2305,7 @@ static int fib6_clean_node(struct fib6_walker *w)
 
 static void fib6_clean_tree(struct net *net, struct fib6_node *root,
 			    int (*func)(struct fib6_info *, void *arg),
-			    int sernum, void *arg, bool skip_notify)
+			    void *arg, bool skip_notify)
 {
 	struct fib6_cleaner c;
 
@@ -2341,7 +2315,6 @@ static void fib6_clean_tree(struct net *net, struct fib6_node *root,
 	c.w.skip = 0;
 	c.w.skip_in_node = 0;
 	c.func = func;
-	c.sernum = sernum;
 	c.arg = arg;
 	c.net = net;
 	c.skip_notify = skip_notify;
@@ -2351,7 +2324,7 @@ static void fib6_clean_tree(struct net *net, struct fib6_node *root,
 
 static void __fib6_clean_all(struct net *net,
 			     int (*func)(struct fib6_info *, void *),
-			     int sernum, void *arg, bool skip_notify)
+			     void *arg, bool skip_notify)
 {
 	struct fib6_table *table;
 	struct hlist_head *head;
@@ -2363,7 +2336,7 @@ static void __fib6_clean_all(struct net *net,
 		hlist_for_each_entry_rcu(table, head, tb6_hlist) {
 			spin_lock_bh(&table->tb6_lock);
 			fib6_clean_tree(net, &table->tb6_root,
-					func, sernum, arg, skip_notify);
+					func, arg, skip_notify);
 			spin_unlock_bh(&table->tb6_lock);
 		}
 	}
@@ -2373,21 +2346,14 @@ static void __fib6_clean_all(struct net *net,
 void fib6_clean_all(struct net *net, int (*func)(struct fib6_info *, void *),
 		    void *arg)
 {
-	__fib6_clean_all(net, func, FIB6_NO_SERNUM_CHANGE, arg, false);
+	__fib6_clean_all(net, func, arg, false);
 }
 
 void fib6_clean_all_skip_notify(struct net *net,
 				int (*func)(struct fib6_info *, void *),
 				void *arg)
 {
-	__fib6_clean_all(net, func, FIB6_NO_SERNUM_CHANGE, arg, true);
-}
-
-static void fib6_flush_trees(struct net *net)
-{
-	int new_sernum = fib6_new_sernum(net);
-
-	__fib6_clean_all(net, NULL, new_sernum, NULL, false);
+	__fib6_clean_all(net, func, arg, true);
 }
 
 /*
@@ -2624,7 +2590,6 @@ int __init fib6_init(void)
 	if (ret)
 		goto out_unregister_subsys;
 
-	__fib6_flush_trees = fib6_flush_trees;
 out:
 	return ret;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC net-next v2 7/7] ipv6: stamp dsts with the generation sampled before the FIB lookup
  2026-11-23 21:26 [RFC net-next v2 0/7] ipv6: validate dsts against the netns route generation at lookup David Ahern
                   ` (5 preceding siblings ...)
  2026-11-23 21:26 ` [RFC net-next v2 6/7] ipv6: make rt_genid_bump_ipv6() a plain counter increment David Ahern
@ 2026-11-23 21:26 ` David Ahern
  6 siblings, 0 replies; 8+ messages in thread
From: David Ahern @ 2026-11-23 21:26 UTC (permalink / raw)
  To: netdev; +Cc: ralf, David Ahern

From: David Ahern <dahern@nvidia.com>

A dst is stamped with the netns route generation in ip6_dst_alloc(),
which runs after the FIB has been read. A route change that lands
between the lookup and the allocation is folded into the stamp: the
dst was built from the old tree but carries the new generation, so
ip6_dst_check() accepts it and it can keep bypassing the new route
indefinitely.

Sample the generation before the FIB is walked, carry it in
struct fib6_result and stamp every dst built from that result with it.
Writers bump the generation after the route change is visible, so a
lookup that read the old tree cannot have sampled the new generation;
the resulting dst fails ip6_dst_check() as soon as the change is
published. Use an acquire read for the sample so the FIB reads are not
reordered before it.

The sample is taken in fib6_table_lookup(), ip6_pol_route_lookup() and
__ip6_route_redirect(). Exceptions created from an existing dst in
__ip6_rt_update_pmtu() and rt6_do_redirect() inherit that dst's stamp
instead of the current generation. Dsts allocated without a lookup
result keep the stamp taken in ip6_dst_alloc().

Signed-off-by: David Ahern <dahern@nvidia.com>
---
Changes since v1:
- New patch.

 include/net/ip6_fib.h       |  5 +++++
 include/net/net_namespace.h | 10 ++++++++++
 net/ipv6/route.c            | 12 ++++++++++++
 3 files changed, 27 insertions(+)

diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 92fed30a7418..a11c4a556b5d 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -225,6 +225,11 @@ struct fib6_result {
 	u32			fib6_flags;
 	u8			fib6_type;
 	struct rt6_info		*rt6;
+	/* Route generation sampled before the FIB was read. Dsts built
+	 * from this result are stamped with it, not with the generation
+	 * at allocation time. 0 means not sampled.
+	 */
+	int			sernum;
 };
 
 #define for_each_fib6_node_rt_rcu(fn)					\
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index f39baf51bcc5..31ffac7baf73 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -557,6 +557,16 @@ static inline int rt_genid_ipv6(const struct net *net)
 	return atomic_read(&net->ipv6.fib6_sernum);
 }
 
+/* Sample the generation before walking the FIB. Writers bump it after the
+ * route change is visible, so a lookup that sees the old tree cannot sample
+ * the new generation: whatever dst it builds carries a generation that
+ * fails ip6_dst_check() once the change lands.
+ */
+static inline int rt_genid_ipv6_sample(const struct net *net)
+{
+	return atomic_read_acquire(&net->ipv6.fib6_sernum);
+}
+
 /* Invalidate every cached IPv6 dst in @net. Returns the new generation,
  * which is never 0.
  */
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 38d5f3bc85bb..deedb5fb62ca 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1210,6 +1210,12 @@ static void ip6_rt_copy_init(struct rt6_info *rt, const struct fib6_result *res)
 	rt->rt6i_idev = dev ? in6_dev_get(dev) : NULL;
 	ip6_rt_init_dst(rt, res);
 
+	/* Pair the dst with the generation the FIB was read under, so a
+	 * change between the lookup and this allocation is not folded in.
+	 */
+	if (res->sernum)
+		rt->sernum = res->sernum;
+
 	rt->rt6i_dst = f6i->fib6_dst;
 	rt->rt6i_flags = res->fib6_flags;
 	if (nh->fib_nh_gw_family) {
@@ -1294,6 +1300,7 @@ INDIRECT_CALLABLE_SCOPE struct rt6_info *ip6_pol_route_lookup(struct net *net,
 	struct rt6_info *rt;
 
 	rcu_read_lock();
+	res.sernum = rt_genid_ipv6_sample(net);
 	fn = fib6_node_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr);
 restart:
 	res.f6i = rcu_dereference(fn->leaf);
@@ -2277,6 +2284,7 @@ int fib6_table_lookup(struct net *net, struct fib6_table *table, int oif,
 {
 	struct fib6_node *fn, *saved_fn;
 
+	res->sernum = rt_genid_ipv6_sample(net);
 	fn = fib6_node_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr);
 	saved_fn = fn;
 
@@ -2987,6 +2995,8 @@ static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk,
 
 		res.fib6_flags = res.f6i->fib6_flags;
 		res.fib6_type = res.f6i->fib6_type;
+		/* derived from @rt6: it is only as current as that dst */
+		res.sernum = READ_ONCE(rt6->sernum);
 
 		if (res.f6i->nh) {
 			struct fib6_nh_match_arg arg = {
@@ -3166,6 +3176,7 @@ INDIRECT_CALLABLE_SCOPE struct rt6_info *__ip6_route_redirect(struct net *net,
 	 */
 
 	rcu_read_lock();
+	res.sernum = rt_genid_ipv6_sample(net);
 	fn = fib6_node_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr);
 restart:
 	for_each_fib6_node_rt_rcu(fn) {
@@ -4383,6 +4394,7 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
 
 	res.fib6_flags = res.f6i->fib6_flags;
 	res.fib6_type = res.f6i->fib6_type;
+	res.sernum = READ_ONCE(rt->sernum);
 	nrt = ip6_rt_cache_alloc(&res, &msg->dest, NULL);
 	if (!nrt)
 		goto out;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-23 21:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 21:26 [RFC net-next v2 0/7] ipv6: validate dsts against the netns route generation at lookup David Ahern
2026-11-23 21:26 ` [RFC net-next v2 1/7] ipv6: validate dsts against the netns route generation David Ahern
2026-11-23 21:26 ` [RFC net-next v2 2/7] ipv6: invalidate the failing dst in ip6_link_failure() David Ahern
2026-11-23 21:26 ` [RFC net-next v2 3/7] nexthop: factor out nh_has_f6i() David Ahern
2026-11-23 21:26 ` [RFC net-next v2 4/7] nexthop: bump the IPv6 route generation on group changes David Ahern
2026-11-23 21:26 ` [RFC net-next v2 5/7] ipv6: scope exception invalidation to the affected nexthop David Ahern
2026-11-23 21:26 ` [RFC net-next v2 6/7] ipv6: make rt_genid_bump_ipv6() a plain counter increment David Ahern
2026-11-23 21:26 ` [RFC net-next v2 7/7] ipv6: stamp dsts with the generation sampled before the FIB lookup David Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox