The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: leonard@lausen.nl
Cc: netdev@vger.kernel.org, dsahern@kernel.org, idosch@nvidia.com,
	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 v4 1/2] ipv6: Honor suppress_prefixlength in fib6_lookup()
Date: Fri, 20 Nov 2026 11:10:50 +0000	[thread overview]
Message-ID: <179517305064.3136.1004033364873817896@kernel.org> (raw)
In-Reply-To: <20261117110813.9894-3-leonard@lausen.nl>

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() is
  justified in the commit message by "Do not suppress such routes so…
- [Low] The commit message names only the nftables FIB expression as
  affected.

--

ipv6: Honor suppress_prefixlength in fib6_lookup()

This patch makes fib6_rule_suppress() check suppress_prefixlength against
the prefix length of the FIB entry when the lookup goes through
fib6_lookup(). On that path res->rt6 is not populated. Routes with
RTF_REJECT set in the result are not suppressed, so they still end the
lookup.

Link: https://github.com/firewalld/firewalld/issues/1600

> diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
> index 0ffd7b47a0460..7efb0515b5c8b 100644
> --- a/net/ipv6/fib6_rules.c
> +++ b/net/ipv6/fib6_rules.c
> @@ -286,6 +286,12 @@ INDIRECT_CALLABLE_SCOPE bool fib6_rule_suppress(struct fib_rule *rule,
>  	struct rt6_info *rt = res->rt6;
>  	struct net_device *dev = NULL;
>  
> +	if (arg->lookup_ptr == fib6_table_lookup) {

[Severity: Low]

The commit message only mentions the nftables FIB expression. However,
every fib6_lookup() caller takes this branch once
net->ipv6.fib6_has_custom_rules is set. Should the changelog also mention
the other callers whose results change?

For example, bpf_ipv6_fib_lookup() in net/core/filter.c calls
fib6_lookup() when BPF_FIB_LOOKUP_DIRECT is not set:

    err = fib6_lookup(net, oif, &fl6, &res, strict);

So XDP and tc programs that call bpf_fib_lookup() for AF_INET6 will now
get the route from a later table, not the suppressed default route in the
main table.

Gateway validation in ip6_route_check_nh() in net/ipv6/route.c also goes
through fib6_lookup():

    err = fib6_lookup(net, cfg->fc_ifindex, &fl6, &res, flags);

This path is used for IPv6 nexthop objects. Outside a VRF,
nh_create_ipv6() sets fc_table from l3mdev_fib_table(dev), which is 0. It
is also used for route adds when the gateway is not found in
cfg->fc_table.

A gateway that used to resolve through a no-gateway route such as
"default dev X" can now resolve to a different device once that route is
suppressed. If no later rule finds a route on the requested device, the
add fails with -EHOSTUNREACH.

This probably brings IPv6 closer to the ip6_route_output() and IPv4
fib4_rule_suppress() behaviour, which is likely what you want. Since the
Fixes: tag will take this to stable, could the changelog mention the
user-visible changes to bpf_fib_lookup() and to route and nexthop
validation?

> +		/* fib6_table_lookup() returns 0 for reject routes. */
> +		return !(res->fib6_flags & RTF_REJECT) &&
> +		       res->f6i->fib6_dst.plen <= rule->suppress_prefixlen;

[Severity: Medium]

Does the RTF_REJECT exemption also catch 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.

But rtm_to_fib6_config() sets RTF_REJECT for throw routes as well:

    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;

On the fib6_lookup() path, fib6_rule_action_alt() returns 0 for any
matched entry other than 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 fib_rules_lookup() calls fib6_rule_suppress(). This branch returns
false because RTF_REJECT is set, and the rule walk stops with an
RTN_THROW result.

On the ip6_route_output() path, __fib6_rule_action() returns
rt->dst.error, which comes from fib6_prop[RTN_THROW] = -EAGAIN. IPv4
fib_table_lookup() returns fib_props[RTN_THROW].error = -EAGAIN. In both
cases fib_rules_lookup() goes on to the next rule, so a throw route never
ends the lookup there.

For example, take "throw default" in the main table with a "table main
suppress_prefixlength 0" rule. ip6_route_output() would continue to the
next rule, but fib6_lookup() stops at the throw route.

nft_fib6_eval_type() then reports RTN_THROW, and nft_fib6_eval() returns
no oif:

    if (ret || res.fib6_flags & (RTF_REJECT | RTF_ANYCAST | RTF_LOCAL))
            return;

That can lead to strict RPF drops. bpf_ipv6_fib_lookup() also returns
BPF_FIB_LKUP_RET_NOT_FWDED even though a later rule would match.

The throw handling in fib6_rule_action_alt() predates this patch.
However, before 1c32b24c234b the nft code used ip6_route_lookup() and
nf_ip6_route(), which handled throw routes correctly. The reject-route
checks described in the notes seem to cover only blackhole, unreachable
and prohibit routes.

Could fib6_rule_action_alt() return -EAGAIN when res->fib6_type ==
RTN_THROW? The RTF_REJECT exemption here would then cover only routes
that really end the lookup.

> +	}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117110813.9894-2-leonard%40lausen.nl

  parent reply	other threads:[~2026-11-20 11:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 11:08 [PATCH net v4 0/2] ipv6: Honor suppress_prefixlength in fib6_lookup() Leonard Lausen
2026-11-17 11:08 ` [PATCH net v4 1/2] " Leonard Lausen
2026-11-17 16:12   ` Ido Schimmel
2026-11-20 11:10   ` netdev-bot+sashiko [this message]
2026-11-20 15:35     ` Ido Schimmel
2026-11-17 11:08 ` [PATCH net v4 2/2] selftests: netfilter: cover IPv6 FIB prefix suppression Leonard Lausen
2026-11-20 11:10   ` netdev-bot+sashiko
2026-11-17 12:56 ` [PATCH net v4 0/2] ipv6: Honor suppress_prefixlength in fib6_lookup() Pablo Neira Ayuso
2026-11-17 13:01   ` Leonard Lausen
2026-11-17 13:07     ` Pablo Neira Ayuso
2026-11-17 15:24       ` Ido Schimmel
2026-11-17 16:30         ` Paolo Abeni

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=179517305064.3136.1004033364873817896@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --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=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=leonard@lausen.nl \
    --cc=linux-kernel@vger.kernel.org \
    --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 \
    /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