Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: dsahern@kernel.org
Cc: netdev@vger.kernel.org, idosch@nvidia.com, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org, ralf@mandelbit.com, ja@ssi.bg,
	dahern@nvidia.com, noreply@anthropic.com
Subject: Re: [PATCH net-next v3 04/13] ipv6: invalidate the failing dst in ip6_link_failure()
Date: Sat, 05 Dec 2026 19:20:53 +0000	[thread overview]
Message-ID: <179649845377.3148.17926604674199917416@kernel.org> (raw)
In-Reply-To: <20261201174021.7211-5-dsahern@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] ip6_link_failure() in net/ipv6/route.c now invalidates only
  the dst attached to the failing skb, through rt6_dst_invalidate(rt).
- [Low] Verified, then discarded under the series rule (baseline
  decision: false).

--

ipv6: invalidate the failing dst in ip6_link_failure()

This patch changes ip6_link_failure() so it no longer writes -1 to the
fn_sernum of the default route's fib6_node. It marks only the failing dst
as stale, by setting the top bit of its sernum. Readers of rt->sernum now
use READ_ONCE(), because the value can change on a published dst.

> diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
> index 232289b439c3c..bfc1895e85915 100644
> --- a/include/net/ip6_fib.h
> +++ b/include/net/ip6_fib.h

[ ... ]

> @@ -315,6 +320,24 @@ static inline u32 rt6_get_cookie(const struct rt6_info *rt)
>  	return cookie;
>  }
>  
> +/* An invalidated dst keeps the generation it was built under in the low
> + * bits, so state derived from it (exceptions) can be stamped with the FIB
> + * state it actually came from. The top bit makes it fail rt6_is_valid():
> + * the netns generation is always positive.
> + */
> +#define RT6_SERNUM_STALE	INT_MIN

[Severity: Low]
This isn't a bug, but does this comment match the code at this point in
the series?

At this commit, ip6_rt_pcpu_alloc() is the only place that writes a
non-zero sernum:

	if (f6i->nh)
		pcpu_rt->sernum = rt_genid_ipv6(dev_net(dev));

Legacy dsts (no nexthop object) still have sernum == 0 when
ip6_link_failure() marks them. So there is no generation in the low bits
to keep. Nothing in this commit reads the low bits or stamps exceptions
from them either.

Marking a legacy pcpu dst also makes its sernum non-zero for the first
time, so the dst now takes the drop path in rt6_get_pcpu_route():

	if (pcpu_rt && READ_ONCE(pcpu_rt->sernum) && !rt6_is_valid(pcpu_rt)) {

Later patches in the series fix this: "ipv6: validate dsts against the
netns route generation" and "ipv6: stamp dsts with the generation
sampled before the FIB lookup". They make ip6_dst_alloc() stamp every
dst, add rt6_dst_sernum() and stamp exceptions from it, so the comment
is accurate at the end of the series.

Could the comment and commit message be reworded here, or this patch be
moved after those, so that each commit describes what it actually does?

[ ... ]

> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 06afb9d5dc2b1..5af0f26332ffa 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c

[ ... ]

> @@ -2912,14 +2912,14 @@ 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; a stale-marked sernum 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))
> +				rt6_dst_invalidate(rt);

[Severity: Medium]
Does this leave the pcpu copies of the same failing default route on
other CPUs valid?

Before this patch, writing -1 to fn_sernum made every dst under the ::/0
node fail the cookie check:

ip6_dst_check()
  rt6_dst_from_check()
    fib6_check(from, cookie)

Sockets on any CPU then looked the route up again. rt6_check_neigh()
returned RT6_NUD_FAIL_PROBE for the NUD_FAILED gateway, and router
selection moved those sockets to another default router.

Now only the skb's dst is marked. Take a connected socket on CPU1 that
holds CPU1's pcpu copy of the same RA-learned (legacy fib6_nh) default
route. Its sernum is still 0 and fn_sernum is no longer touched. So in
ip6_dst_check() this branch is skipped:

	if (READ_ONCE(rt->sernum))
		return rt6_is_valid(rt) ? dst : NULL;

The fn_sernum/cookie check still passes, and the socket keeps sending to
the dead router.

Each of those packets goes through __neigh_event_send(). That moves the
neighbour from NUD_FAILED back to NUD_INCOMPLETE, queues the skb for a
full probe cycle and then drops it. Only after that does the path
error_report -> ip6_link_failure() mark CPU1's copy. Flows whose skbs
were dropped because the neighbour queue was over its length limit never
reach ip6_link_failure() at all.

Is this intended? The commit message says invalidating the node is "far
more than needed" and that the new scope is "one CPU's copy". It doesn't
mention that flows through the same failing router on other CPUs now
fail over later, each after its own probe timeout and packet loss.

This is unchanged at the end of the series. The exception-insert code
added later in the series walks nh->rt6i_pcpu_dirty / rt6i_pcpu and calls
rt6_dst_invalidate() on each copy.

Could ip6_link_failure() do the same for the failing fib6_nh? That would
leave other routers' dsts alone but invalidate every copy of this
router's dst.

>  		}
>  		rcu_read_unlock();
>  	}

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201174021.7211-1-dsahern%40kernel.org

  reply	other threads:[~2026-12-05 19:20 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 17:40 [PATCH net-next v3 00/13] ipv6: validate cached dsts against the netns route generation David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 01/13] ipv6: allocate the exception entry before removing the one it replaces David Ahern
2026-12-02 16:02   ` Ido Schimmel
2026-12-01 17:40 ` [PATCH net-next v3 02/13] ipv6: keep a superseded pcpu dst working until its holders notice David Ahern
2026-12-02 16:19   ` Ido Schimmel
2026-12-05 19:20   ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 03/13] ipv6: don't insert a PMTU exception whose MTU could not be stored David Ahern
2026-12-05 19:20   ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 04/13] ipv6: invalidate the failing dst in ip6_link_failure() David Ahern
2026-12-05 19:20   ` netdev-bot+sashiko [this message]
2026-12-01 17:40 ` [PATCH net-next v3 05/13] ipv6: tell route dumps about exception inserts with a table sequence David Ahern
2026-12-05 19:20   ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 06/13] ipv6: validate dsts against the netns route generation David Ahern
2026-12-05 19:20   ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 07/13] ipv6: make rt_genid_bump_ipv6() a plain counter increment David Ahern
2026-12-05 19:20   ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 08/13] nexthop: factor out nh_has_f6i() David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 09/13] nexthop: bump the IPv6 route generation on group changes David Ahern
2026-12-05 19:20   ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 10/13] ipv6: stamp dsts with the generation sampled before the FIB lookup David Ahern
2026-12-05 19:21   ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 11/13] selftests: net: pmtu: check that a deleted cached exception stays deleted David Ahern
2026-12-01 17:40 ` [PATCH net-next v3 12/13] selftests: net: fib_tests: Add stale pcpu test David Ahern
2026-12-05 19:21   ` netdev-bot+sashiko
2026-12-01 17:40 ` [PATCH net-next v3 13/13] selftests: net: ipvs: check a PMTU learned after the DR route was cached David Ahern
2026-12-05 19:21   ` netdev-bot+sashiko
2026-12-01 17:43 ` [PATCH net-next v3 00/13] ipv6: validate cached dsts against the netns route generation netdev-bot+sinfo
2026-12-02  9:45 ` Ralf Lici
2026-12-03 15:34 ` Ido Schimmel
2026-12-03 16:55   ` Ralf Lici
2026-12-03 17:16     ` Ido Schimmel

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=179649845377.3148.17926604674199917416@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=dahern@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=ja@ssi.bg \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=noreply@anthropic.com \
    --cc=pabeni@redhat.com \
    --cc=ralf@mandelbit.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