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/2026…%40kernel.org