From: Ido Schimmel <idosch@nvidia.com>
To: netdev-bot+sashiko@kernel.org
Cc: leonard@lausen.nl, netdev@vger.kernel.org, dsahern@kernel.org,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, pablo@netfilter.org,
fw@strlen.de, phil@nwl.cc, shuah@kernel.org,
daniel@iogearbox.net, netfilter-devel@vger.kernel.org,
coreteam@netfilter.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v3 2/3] ipv6: Honor suppress_prefixlength in fib6_lookup()
Date: Thu, 19 Nov 2026 18:57:58 +0200 [thread overview]
Message-ID: <20261119165758.GA2050378@shredder> (raw)
In-Reply-To: <179506821413.3136.16876288075711504414@kernel.org>
On Thu, Nov 19, 2026 at 06:03:34AM +0000, netdev-bot+sashiko@kernel.org wrote:
> 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] The new RTF_REJECT exemption in fib6_rule_suppress() and the
> commit message's reason for it ("Do not suppress such routes so that…
> - [Low] The commit message and Fixes: tag present this as a fix for the
> nftables regression from commit 1c32b24c234b, but the code change has…
>
> --
>
> ipv6: Honor suppress_prefixlength in fib6_lookup()
>
> This patch makes fib6_rule_suppress() honour suppress_prefixlength when
> the lookup goes through fib6_lookup(). That path uses
> fib6_rule_action_alt(), which never populates res->rt6. The new code
> compares the FIB entry prefix length against suppress_prefixlen, and it
> does not suppress results that carry RTF_REJECT.
>
> Link: https://github.com/firewalld/firewalld/issues/1600
>
> > Fixes: 1c32b24c234b ("netfilter: nft_fib_ipv6: switch to fib6_lookup")
>
> [Severity: Low]
>
> This isn't a code bug, but should the changelog and Fixes: tag cover the
> other fib6_lookup() callers too?
>
> The new branch in fib6_rule_suppress() runs for every fib6_lookup() call
> while custom IPv6 rules exist, not only for nft_fib6_lookup(). At least
> two other callers change behaviour.
>
> The first is bpf_ipv6_fib_lookup() in net/core/filter.c. This is the
> bpf_fib_lookup() helper without BPF_FIB_LOOKUP_DIRECT:
>
> err = fib6_lookup(net, oif, &fl6, &res, strict);
>
> The second is ip6_route_check_nh() in net/ipv6/route.c, which validates
> the gateway when a route is added:
>
> err = fib6_lookup(net, cfg->fc_ifindex, &fl6, &res, flags);
>
> With a WireGuard-style "ip -6 rule add table main suppress_prefixlength 0",
> bpf_fib_lookup() now returns the VPN table route. Before this patch it
> returned the main table default route.
>
> For the BPF helper, the missing suppression is older than 1c32b24c234b.
> The custom rules path of fib6_lookup() came from 138118ec96cb (2018). It
> was converted to fib6_result in effda4dd97e878 (2019).
> fib6_rule_action_alt() has never set res->rt6, so the old suppress code
> always returned false on this path.
>
> The v3 notes say this message and Fixes tag were suggested in review.
> Even so, stable backports that follow the 1c32b24c234b tag won't reach
> older kernels where BPF users are affected.
>
> Would it make sense to mention the BPF and route-add callers in the
> changelog? Should there also be a Fixes: tag for the older commit?
>
> > diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
> > index 5e2a79a81bf35..2f43e4e48e0d0 100644
> > --- a/net/ipv6/fib6_rules.c
> > +++ b/net/ipv6/fib6_rules.c
> > @@ -288,6 +288,12 @@ INDIRECT_CALLABLE_SCOPE bool fib6_rule_suppress(struct fib_rule *rule,
> > struct fib6_info *from;
> > int plen;
> >
> > + if (arg->lookup_ptr == fib6_table_lookup) {
> > + /* fib6_table_lookup() returns 0 for reject routes. */
> > + return !(res->fib6_flags & RTF_REJECT) &&
> > + res->f6i->fib6_dst.plen <= rule->suppress_prefixlen;
> > + }
>
> [Severity: Medium]
>
> Is the RTF_REJECT exemption correct for RTN_THROW routes? The commit
> message says:
>
> Do not suppress such routes so that they continue to terminate the
> lookup, as with ip6_route_output() and IPv4.
>
> rtm_to_fib6_config() also sets RTF_REJECT on throw routes:
>
> if (rtm->rtm_type == RTN_UNREACHABLE ||
> rtm->rtm_type == RTN_BLACKHOLE ||
> rtm->rtm_type == RTN_PROHIBIT ||
> rtm->rtm_type == RTN_THROW)
> cfg->fc_flags |= RTF_REJECT;
>
> A throw route doesn't end the lookup in ip6_route_output(). This is what
> __fib6_rule_action() does:
>
> err = rt->dst.error;
> if (err != -EAGAIN)
> goto out;
>
> fib6_prop[RTN_THROW] is -EAGAIN, so fib_rules_lookup() goes on to the
> next rule. IPv4 does the same through fib_props[RTN_THROW].error.
>
> In the fib6_lookup() path, fib6_rule_action_alt() only checks for
> fib6_null_entry:
>
> err = fib6_table_lookup(net, table, *oif, flp6, res, flags);
> if (!err && res->f6i != net->ipv6.fib6_null_entry)
> err = fib6_rule_saddr(net, rule, flags, flp6,
> res->nh->fib_nh_dev);
> else
> err = -EAGAIN;
>
> So a throw route gives err == 0. fib6_rule_suppress() then returns false
> because of RTF_REJECT, and the rule walk stops with the throw route as
> the result.
>
> The callers then see:
>
> __nft_fib6_eval_type() returns RTN_THROW
> nft_fib6_eval() returns without setting an oif
> bpf_ipv6_fib_lookup() returns BPF_FIB_LKUP_RET_NOT_FWDED
> ip6_route_check_nh() returns -EHOSTUNREACH
>
> In the same case, ip6_route_output() would use a later rule. An nft fib
> rpfilter rule such as firewalld's "fib saddr . mark . iif oif missing
> drop" can then drop legitimate packets.
>
> The lookup already stopped at throw routes before this patch, because the
> old suppress code always returned false here. For a throw route with
> plen <= suppress_prefixlen, though, ip6_route_output() moves on to the
> next rule. The new branch makes fib6_lookup() stop instead.
>
> Would it be better for fib6_rule_action_alt() to return -EAGAIN when
> res->fib6_type == RTN_THROW, as __fib6_rule_action() does?
The patch under review doesn't introduce a regression for throw routes
(which I suspect are rarely used). fib6_rule_action_alt() never handled
them correctly and always returned 0 instead of -EAGAIN, unlike its
__fib6_rule_action() counterpart.
I can follow up with [1]. Regardless, I don't think we need to hold up
v4 because of this, as the patch is fixing an actual regression.
[1]
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 0ffd7b47a046..adfaf2b8884c 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -191,7 +191,8 @@ static int fib6_rule_action_alt(struct fib_rule *rule, struct flowi *flp,
oif = (int *)arg->lookup_data;
err = fib6_table_lookup(net, table, *oif, flp6, res, flags);
- if (!err && res->f6i != net->ipv6.fib6_null_entry)
+ if (!err && res->f6i != net->ipv6.fib6_null_entry &&
+ res->fib6_type != RTN_THROW)
err = fib6_rule_saddr(net, rule, flags, flp6,
res->nh->fib_nh_dev);
else
next prev parent reply other threads:[~2026-11-19 16:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 15:01 [PATCH net v3 0/3] ipv6: Honor prefix suppression for FIB lookups and cached routes Leonard Lausen
2026-11-16 15:01 ` [PATCH net v3 1/3] ipv6: Use the FIB prefix length when suppressing " Leonard Lausen
2026-11-16 15:01 ` [PATCH net v3 2/3] ipv6: Honor suppress_prefixlength in fib6_lookup() Leonard Lausen
2026-11-19 6:03 ` netdev-bot+sashiko
2026-11-19 16:57 ` Ido Schimmel [this message]
2026-11-16 15:01 ` [PATCH net v3 3/3] selftests: netfilter: cover IPv6 FIB prefix suppression Leonard Lausen
2026-11-19 6:03 ` netdev-bot+sashiko
2026-11-17 9:13 ` [PATCH net v3 0/3] ipv6: Honor prefix suppression for FIB lookups and cached routes Ido Schimmel
2026-11-17 11:10 ` 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=20261119165758.GA2050378@shredder \
--to=idosch@nvidia.com \
--cc=coreteam@netfilter.org \
--cc=daniel@iogearbox.net \
--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-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev-bot+sashiko@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 \
/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
all inboxes | Powered by JetHome®