All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <dsahern@kernel.org>
To: netdev@vger.kernel.org
Cc: ralf@mandelbit.com, David Ahern <dahern@nvidia.com>,
	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>,
	Simon Horman <horms@kernel.org>
Subject: [RFC net-next 0/6] ipv6: validate dsts against the netns route generation
Date: Sun, 22 Nov 2026 15:26:58 -0700	[thread overview]
Message-ID: <20261122222717.126333-2-dsahern@kernel.org> (raw)
In-Reply-To: <20261122222717.126333-1-dsahern@kernel.org>

From: David Ahern <dahern@nvidia.com>

An IPv6 dst has never carried the fib6 serial number it was created
under. rt6_get_cookie() reads fn->fn_sernum through rt->from when a
socket, dst_cache or xfrm bundle stores its cookie, so a FIB change
that lands between the route lookup and the cookie capture is folded
into the cookie and a stale dst looks valid. The only dsts stamped at
creation are pcpu dsts of nexthop-object routes, which store the netns
genid in rt->sernum.

Looking at this I found that rt_genid_ipv6() and the fib6 serial
number are already the same counter: net->ipv6.fib6_sernum, which
fib6_new_sernum() advances on every FIB change. fn_sernum is a per-node
copy of it. So this series moves dst validation onto that counter, the
way IPv4 uses rt_genid, instead of adding another one:

 1. Stamp every dst with the counter in ip6_dst_alloc() and validate by
    comparison in ip6_dst_check(). Long-lived dsts (pcpu dsts of routes
    with an embedded fib6_nh, and exception dsts) are re-stamped when a
    lookup finds them again, otherwise they would stay invalid.

 2. ip6_link_failure() forced a new lookup by writing -1 to fn_sernum.
    That no longer invalidates anything, so clear the failing dst's
    sernum instead.

 3-4. Nexthop objects: factor out nh_has_f6i(), then bump the counter
    when a nexthop used through a group is replaced, and when a member
    is removed from a group.

 5. A new PMTU or redirect exception used to bump the counter, which
    with (1) would invalidate every dst in the namespace. Do what IPv4
    does in update_or_create_fnhe() and invalidate only the pcpu dsts
    of the affected fib6_nh. Route dumps still need to see that an
    exception was added to the root node, so add a per-table sequence
    for that rather than inventing fn_sernum values the counter could
    later issue again.

 6. Since nothing validates against fn_sernum any more,
    rt_genid_bump_ipv6() no longer needs to walk every node of every
    table. Make it an atomic increment like rt_genid_bump_ipv4(), and
    drop the __fib6_flush_trees pointer. fn_sernum remains only for
    route dump consistency, so nexthop, address and rule changes no
    longer restart in-progress dumps.

David Ahern (6):
  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

 include/net/ip6_fib.h       |  45 +++-------------
 include/net/net_namespace.h |  26 ++++++---
 net/ipv4/nexthop.c          |  42 ++++++++++++---
 net/ipv6/addrconf_core.c    |   7 ---
 net/ipv6/ip6_fib.c          |  76 +++++++++++---------------
 net/ipv6/route.c            | 104 ++++++++++++++++++++++++------------
 6 files changed, 162 insertions(+), 138 deletions(-)

-- 
2.43.0


  reply	other threads:[~2026-11-22 22:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22 22:26 David Ahern
2026-11-22 22:26 ` David Ahern [this message]
2026-11-22 22:30   ` [RFC net-next 0/6] ipv6: validate dsts against the netns route generation David Ahern
2026-11-23 12:38     ` Ralf Lici
2026-11-23 18:36       ` David Ahern
2026-11-23 12:34   ` Ralf Lici
2026-11-22 22:26 ` [RFC net-next 1/6] " David Ahern
2026-11-22 22:27 ` [RFC net-next 2/6] ipv6: invalidate the failing dst in ip6_link_failure() David Ahern
2026-11-22 22:27 ` [RFC net-next 3/6] nexthop: factor out nh_has_f6i() David Ahern
2026-11-22 22:27 ` [RFC net-next 4/6] nexthop: bump the IPv6 route generation on group changes David Ahern
2026-11-22 22:27 ` [RFC net-next 5/6] ipv6: scope exception invalidation to the affected nexthop David Ahern
2026-11-22 22:27 ` [RFC net-next 6/6] ipv6: make rt_genid_bump_ipv6() a plain counter increment David Ahern

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=20261122222717.126333-2-dsahern@kernel.org \
    --to=dsahern@kernel.org \
    --cc=dahern@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.