Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@nvidia.com>
To: Leonard Lausen <leonard@lausen.nl>
Cc: netdev@vger.kernel.org, David Ahern <dsahern@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Florian Westphal <fw@strlen.de>, Phil Sutter <phil@nwl.cc>,
	Shuah Khan <shuah@kernel.org>,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next 1/2] ipv6: Use the FIB prefix length when suppressing cached routes
Date: Thu, 3 Dec 2026 11:02:36 +0200	[thread overview]
Message-ID: <20261203090236.GA2961542@shredder> (raw)
In-Reply-To: <20261202173023.17220-2-leonard@lausen.nl>

On Wed, Dec 02, 2026 at 05:30:21PM +0000, Leonard Lausen wrote:
> fib6_rule_suppress() compares suppress_prefixlen with rt6i_dst.plen.
> PMTU and redirect exception routes have a /128 destination prefix even
> when their parent FIB route is a default route. Consequently, a cached
> exception bypasses suppress_prefixlength 0 and stops the rule lookup
> instead of continuing to a later table.
> 
> Use the parent FIB entry's destination prefix length when available.
> The rule lookup already holds the RCU read lock needed to read rt->from.
> Retain the existing prefix check if the destination has lost its parent.
> Interface-group checks and destination reference handling are unchanged.
> 
> Identified during maintainer review and reproduced using an ICMPv6
> Packet Too Big in network namespaces, without kernel instrumentation
> or error injection. The reproducer and nft_fib.sh pass on a rebuilt
> net-next-based kernel.
> 
> Fixes: 7764a45a8f1f ("fib_rules: add .suppress operation")

No need for a Fixes tag. This was always broken.

> Link: https://lore.kernel.org/netdev/20261117091340.GA581197@shredder/
> Signed-off-by: Leonard Lausen <leonard@lausen.nl>
> ---
> Previously included in v3 of the prefix-suppression series, then removed
> at review to be sent separately to net-next after the prerequisite fix.
> The implementation is unchanged; the message records current validation.
> 
> Review:
> https://lore.kernel.org/netdev/20261117091340.GA581197@shredder/
> 
>  net/ipv6/fib6_rules.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
> index 7efb0515b5c8..2f43e4e48e0d 100644
> --- a/net/ipv6/fib6_rules.c
> +++ b/net/ipv6/fib6_rules.c
> @@ -285,6 +285,8 @@ INDIRECT_CALLABLE_SCOPE bool fib6_rule_suppress(struct fib_rule *rule,
>  	struct fib6_result *res = arg->result;
>  	struct rt6_info *rt = res->rt6;
>  	struct net_device *dev = NULL;
> +	struct fib6_info *from;
> +	int plen;
>  
>  	if (arg->lookup_ptr == fib6_table_lookup) {
>  		/* fib6_table_lookup() returns 0 for reject routes. */
> @@ -298,10 +300,13 @@ INDIRECT_CALLABLE_SCOPE bool fib6_rule_suppress(struct fib_rule *rule,
>  	if (rt->rt6i_idev)
>  		dev = rt->rt6i_idev->dev;
>  
> +	from = rcu_dereference(rt->from);
> +	plen = from ? from->fib6_dst.plen : rt->rt6i_dst.plen;

This scheme of deriving the FIB entry from the dst entry doesn't work
correctly with nexthop objects. The dst entry is cached in the nexthop
and it can be shared by multiple FIB entries with nexthop objects.
Therefore, the FIB entry that created a returned cached dst entry (i.e.,
rt->from) is not necessarily the FIB entry that the lookup matched [1].

I have a patchset that fixes the current users of this scheme
(RTM_GETROUTE + source address selection) and I would prefer if your set
came as a follow-up.

My solution is to align the IPv6 route lookup API with IPv4 and add a
result argument that encodes the matched FIB entry. Therefore, there's
no longer a need to derive it from rt->from.

Note that while fib6_rule_suppress() already has the FIB result
available ('res'), it doesn't have the FIB entry filled (i.e., res->f6i
is NULL). My patchset fills it for input and output route lookups, but
ip6_pol_route_lookup() and __ip6_route_redirect() will need to fill it
as well before fib6_rule_suppress() can use res->f6i->fib6_dst.plen.

> +
>  	/* do not accept result if the route does
>  	 * not meet the required prefix length
>  	 */
> -	if (rt->rt6i_dst.plen <= rule->suppress_prefixlen)
> +	if (plen <= rule->suppress_prefixlen)
>  		goto suppress_route;
>  
>  	/* do not accept result if the route uses a device

[1]
# ip link add name dummy1 up type dummy
# ip nexthop add id 1 via fe80::1 dev dummy1
# ip -6 route add 2001:db8:1::/64 nhid 1 metric 100
# ip -6 route add 2001:db8:2::/64 nhid 1 metric 200
# taskset -c 0 ip -6 route get 2001:db8:1::1
2001:db8:1::1 via fe80::1 dev dummy1 src fe80::b8a6:3fff:fea5:f139 metric 100 pref medium
# taskset -c 0 ip -6 route get 2001:db8:2::1
2001:db8:2::1 via fe80::1 dev dummy1 src fe80::b8a6:3fff:fea5:f139 metric 100 pref medium
# taskset -c 0 ip -6 route get fibmatch 2001:db8:2::1
2001:db8:1::/64 nhid 1 via fe80::1 dev dummy1 metric 100 pref medium

  reply	other threads:[~2026-12-03  9:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 17:30 [PATCH net-next 0/2] ipv6: Use the FIB prefix length to suppress cached routes Leonard Lausen
2026-12-02 17:30 ` [PATCH net-next 1/2] ipv6: Use the FIB prefix length when suppressing " Leonard Lausen
2026-12-03  9:02   ` Ido Schimmel [this message]
2026-12-02 17:30 ` [PATCH net-next 2/2] selftests: netfilter: cover IPv6 prefix suppression with a PMTU exception Leonard Lausen

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=20261203090236.GA2961542@shredder \
    --to=idosch@nvidia.com \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=leonard@lausen.nl \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=phil@nwl.cc \
    --cc=shuah@kernel.org \
    --cc=willemb@google.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