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 09/13] nexthop: bump the IPv6 route generation on group changes
Date: Sat, 05 Dec 2026 19:20:58 +0000	[thread overview]
Message-ID: <179649845889.3148.6654332243642584580@kernel.org> (raw)
In-Reply-To: <20261201174021.7211-10-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] remove_nexthop_from_groups() in net/ipv4/nexthop.c decides
  whether to bump the IPv6 generation too early.
- [Low] The commit fixes two user-visible bugs: stale IPv6 dsts after
  replacing a member used only through a group, and after removing a…

--

nexthop: bump the IPv6 route generation on group changes

This commit bumps the netns IPv6 route generation in two more cases: when
a group member is replaced and IPv6 routes use it only through a group,
and when a member is removed from a group. The aim is that dsts built
from the old group no longer pass validation.

> diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
> index 53431fe7d3281..7cf496589f4f4 100644
> --- a/net/ipv4/nexthop.c
> +++ b/net/ipv4/nexthop.c

[ ... ]

> @@ -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);
> +

[Severity: Medium]
Can the bump be skipped if an IPv6 route is added to the group while the
member is being removed?

have_f6i is read from the parent's f6i_list before remove_nh_grp_entry()
publishes the new array with rcu_assign_pointer(nhp->nh_grp, newg). It is
then used after synchronize_net().

IPv6 route insertion does not hold RTNL. RTM_NEWROUTE is registered with
RTNL_FLAG_DOIT_UNLOCKED, and ip6_route_info_create_nh() looks up the
nexthop under rcu_read_lock(). fib6_add_rt2node_nh() then links the route
into the group's f6i_list while holding only the group's nh->lock:

net/ipv6/ip6_fib.c:fib6_add_rt2node_nh() {
    ...
	list_add(&rt->nh_list, &rt->nh->f6i_list);
    ...
}

So with member X being deleted from group G, this sequence looks possible:

CPU0 (holds RTNL, deleting X)
remove_nexthop_from_groups()
    nh_has_f6i(G) returns false, have_f6i stays false

CPU1 (RTM_NEWROUTE with nhid=G)
fib6_add_rt2node_nh()
    route R is linked into G->f6i_list

CPU2
ip6_pol_route()
    finds R, selects a path from the old G->nh_grp, and builds a dst
    stamped with the current generation

CPU0
remove_nh_grp_entry()
    rcu_assign_pointer(nhp->nh_grp, newg);
synchronize_net()
    have_f6i is false, so rt_genid_bump_ipv6() is not called

The later "ipv6: stamp dsts with the generation sampled before the FIB
lookup" change does not help here. No bump follows the publish, so the
sampled generation is still current. rt6_is_valid() keeps passing until
some unrelated FIB change. This looks like the "dsts built from the old
group stayed valid" case that the commit message says it closes.

Two kinds of dst would stay valid:

- pcpu dsts through surviving members, built under the old
  hash-threshold or resilient mapping
- uncached FLOWI_FLAG_KNOWN_NH clones through the deleted member, which
  fib6_nh_release_dsts() does not reach

Pcpu dsts held in the deleted member's own rt6i_pcpu are released with
dst_dev_put() when X is freed, so they are not affected.

Could the decision be made after synchronize_net(), using the surviving
parents (the nh_parent of the entries on deferred_free)? Another option
is to bump every time a group loses a member, since rt_genid_bump_ipv6()
is now a plain counter update.

[ ... ]

> @@ -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);

[Severity: Low]
This isn't a bug, but should this commit carry a Fixes: tag?

Both gaps predate this series. The check in nh_rt_cache_flush() that
looks only at the member's own f6i_list goes back to the original
nh_rt_cache_flush() in commit 7bf4796dd09984 ("nexthops: add support for
replace"). Blame also points at 4787a6d2629b4e. The baseline
remove_nexthop_from_groups() never bumps the IPv6 generation after
republishing a group.

Other fixes in this series have Fixes: tags. Examples are "ipv6: keep a
superseded pcpu dst working until its holders notice" and "ipv6: allocate
the exception entry before removing the one it replaces". Without a tag
here, stable maintainers cannot tell which kernels need this change.

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

  reply	other threads:[~2026-12-05 19:21 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
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 [this message]
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=179649845889.3148.6654332243642584580@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