* [PATCH net v3 0/3] ipv6: Honor prefix suppression for FIB lookups and cached routes
@ 2026-11-16 15:01 Leonard Lausen
2026-11-16 15:01 ` [PATCH net v3 1/3] ipv6: Use the FIB prefix length when suppressing " Leonard Lausen
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Leonard Lausen @ 2026-11-16 15:01 UTC (permalink / raw)
To: netdev
Cc: leonard, David Ahern, Ido Schimmel, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Pablo Neira Ayuso, Florian Westphal, Phil Sutter, Shuah Khan,
Daniel Borkmann, netfilter-devel, coreteam, linux-kselftest,
linux-kernel
This revision also takes a stab at addressing the cached-exception disagreement
identified in review. The fix remains small and is a separate patch so it can
be picked up or discarded independently of the fib6_lookup() change.
Patch 1 uses the parent FIB entry's prefix length for dst-based
suppression. PMTU and redirect exceptions have /128 prefixes even when
their parent is a default route. Reading rt->from under the existing RCU
read lock fixes that comparison; a detached destination retains its old
behavior. Interface-group checks and reference handling are unchanged.
Patch 2 adds the fib6_lookup() prefix-suppression check from v2, with the
reviewer's requested message, Fixes tag, original initializer and comment.
It preserves reject results, including blackhole nexthop objects. Support
for interface-group suppression in fib6_lookup() remains deferred.
Patch 3 reuses nft_fib.sh's fixture. Besides the six existing suppression
checks it seeds a real PMTU exception via ICMPv6 Packet Too Big and checks
that the parent default route is suppressed. The extra case uses the
existing peer namespace and adds no new devices or dependencies.
Changes since v2:
- Add the separate cached-exception fix and PMTU regression case.
- Adopt the maintainer's terminology, message, Fixes tag and comment.
- Remove Assisted-by and retain the original rt initializer.
- Run the checks after the default-table tests, preserving coverage before
custom IPv6 rules are configured and avoiding logging RPF during probes.
- Label ruleset-load failures, skip unsupported optional features, and
check ordinary rejection errors using the C locale.
V2: https://lore.kernel.org/netdev/20261115114434.10343-2-leonard@lausen.nl/
Verified on the rebuilt v7.4-rc2-based kernel: all seven added checks
pass and the complete nft_fib.sh run exits 0. A run with an eight-second
delay also exits 0. The PMTU reproducer creates a real mtu-1280 exception,
then confirms that both ordinary and nftables lookups continue to the
later table when the parent default is suppressed. Twelve reject-route
probes, including blackhole nexthop objects, remain terminal.
The source compiles without warnings and passes focused callback tests.
Automated kernel-log checks were unavailable in the namespace test
session. Target-net runtime and full W=1 allyesconfig/allmodconfig builds
remain unchecked. The series is based on v7.4-rc2 (7475ea8b5861).
OpenAI Codex assisted with investigation, reproduction, implementation,
tests and descriptions. The prompts asked it to investigate the VPN
failure, simplify the series and address review feedback.
Leonard Lausen (3):
ipv6: Use the FIB prefix length when suppressing cached routes
ipv6: Honor suppress_prefixlength in fib6_lookup()
selftests: netfilter: cover IPv6 FIB prefix suppression
net/ipv6/fib6_rules.c | 13 ++-
tools/testing/selftests/net/netfilter/nft_fib.sh | 109 +++++++++++++++++++++++
2 files changed, 121 insertions(+), 1 deletion(-)
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
--
2.55.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net v3 1/3] ipv6: Use the FIB prefix length when suppressing cached routes
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 ` Leonard Lausen
2026-11-16 15:01 ` [PATCH net v3 2/3] ipv6: Honor suppress_prefixlength in fib6_lookup() Leonard Lausen
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Leonard Lausen @ 2026-11-16 15:01 UTC (permalink / raw)
To: netdev
Cc: leonard, David Ahern, Ido Schimmel, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Pablo Neira Ayuso, Florian Westphal, Phil Sutter, Shuah Khan,
Daniel Borkmann, netfilter-devel, coreteam, linux-kselftest,
linux-kernel
fib6_rule_suppress() compares suppress_prefixlen with rt6i_dst.plen.
PMTU and redirect exceptions 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.
Reproduced with a PMTU exception created by an ICMPv6 Packet Too Big,
without kernel instrumentation. Verified with the namespace reproducer
and nft_fib.sh on the rebuilt v7.4-rc2-based kernel.
Fixes: 7764a45a8f1f ("fib_rules: add .suppress operation")
Signed-off-by: Leonard Lausen <leonard@lausen.nl>
---
v3:
- New separate fix for the cached-exception issue identified in review.
- Reproduced with ICMPv6 Packet Too Big and verified on the rebuilt
kernel with the reproducer and all seven nft_fib.sh cases.
v2: https://lore.kernel.org/netdev/20261115114434.10343-2-leonard@lausen.nl/
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 0ffd7b47a046..5e2a79a81bf3 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 (!rt)
return false;
@@ -292,10 +294,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;
+
/* 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
--
2.55.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net v3 2/3] ipv6: Honor suppress_prefixlength in fib6_lookup()
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 ` Leonard Lausen
2026-11-19 6:03 ` netdev-bot+sashiko
2026-11-16 15:01 ` [PATCH net v3 3/3] selftests: netfilter: cover IPv6 FIB prefix suppression Leonard Lausen
2026-11-17 9:13 ` [PATCH net v3 0/3] ipv6: Honor prefix suppression for FIB lookups and cached routes Ido Schimmel
3 siblings, 1 reply; 9+ messages in thread
From: Leonard Lausen @ 2026-11-16 15:01 UTC (permalink / raw)
To: netdev
Cc: leonard, David Ahern, Ido Schimmel, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Pablo Neira Ayuso, Florian Westphal, Phil Sutter, Shuah Khan,
Daniel Borkmann, netfilter-devel, coreteam, linux-kselftest,
linux-kernel
When custom FIB rules are configured, fib6_lookup() performs the lookup
via fib6_rule_action_alt() which calls fib6_table_lookup() and only
populates the f6i, nh, fib6_flags and fib6_type fields of the FIB
result. However, fib6_rule_suppress() only examines the rt6 field, which
is only populated when the lookup is performed via one of the callers of
fib6_rule_lookup() such as ip6_route_output(). As a result,
fib6_lookup() ignores suppress_prefixlength.
This was not a problem for nftables until commit 1c32b24c234b
("netfilter: nft_fib_ipv6: switch to fib6_lookup") switched the FIB
expression from ip6_route_lookup() / nf_ip6_route() to fib6_lookup().
Since then, with a rule that suppresses the default route in the main
table before looking up a VPN table (as commonly configured for
WireGuard), the FIB expression returns the suppressed default route
instead of the VPN route. Strict reverse path filtering then drops
replies received over the VPN.
Fix by evaluating suppress_prefixlength against the prefix length of
the FIB entry when the lookup is performed via fib6_lookup().
fib_rules_lookup() only invokes the suppress callback when the rule
action returns 0. Unlike __fib6_rule_action(), fib6_rule_action_alt()
returns 0 for reject routes and instead sets RTF_REJECT in the result.
Do not suppress such routes so that they continue to terminate the
lookup, as with ip6_route_output() and IPv4. Check the flags in the
result rather than in the FIB entry so that blackhole nexthop objects
are also covered.
suppress_ifgroup is not handled since fib6_table_lookup() does not
perform multipath selection and the nexthop it returns might not be the
one that is eventually used.
Observed during WireGuard use and reproduced on unmodified v7.4-rc2,
without instrumentation or error injection. Verified with namespace
probes and nft_fib.sh on the rebuilt v7.4-rc2-based kernel.
Fixes: 1c32b24c234b ("netfilter: nft_fib_ipv6: switch to fib6_lookup")
Link: https://github.com/firewalld/firewalld/issues/1600
Signed-off-by: Leonard Lausen <leonard@lausen.nl>
---
v3:
- Use the suggested message and Fixes tag for the nftables regression.
- Remove Assisted-by, keep the original initializer, update the comment.
- The cached-exception issue is fixed independently in patch 1.
v2: https://lore.kernel.org/netdev/20261115114434.10343-2-leonard@lausen.nl/
net/ipv6/fib6_rules.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 5e2a79a81bf3..2f43e4e48e0d 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;
+ }
+
if (!rt)
return false;
--
2.55.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net v3 3/3] selftests: netfilter: cover IPv6 FIB prefix suppression
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-16 15:01 ` 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
3 siblings, 1 reply; 9+ messages in thread
From: Leonard Lausen @ 2026-11-16 15:01 UTC (permalink / raw)
To: netdev
Cc: leonard, David Ahern, Ido Schimmel, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Pablo Neira Ayuso, Florian Westphal, Phil Sutter, Shuah Khan,
Daniel Borkmann, netfilter-devel, coreteam, linux-kselftest,
linux-kernel
Extend nft_fib.sh using its existing namespaces and counter helper to
check that suppress_prefixlength 0 suppresses a default route while
retaining a more-specific route. Check that blackhole, unreachable and
prohibit routes remain terminal despite a usable route in a later table.
Include a blackhole nexthop object to distinguish result reject flags
from flags on the FIB entry.
Require a positive counter for the expected nftables FIB result. Compare
it with the output device or rejection error from an ordinary lookup.
Create a PMTU exception through the existing peer namespace and check
that its parent default route is still suppressed.
Label ruleset-load failures and skip the affected checks when IPv6 prefix
suppression or nexthop objects are unavailable.
Run these checks after the existing default-table tests so that adding
policy rules does not remove coverage of the path without custom IPv6
rules. The router's logging RPF rules have already been removed by then,
allowing neighbour discovery during intentionally different reverse-route
states.
Signed-off-by: Leonard Lausen <leonard@lausen.nl>
---
v3:
- Add a cached-default PMTU case using the existing peer namespace.
- Run after default-table tests; label load failures, skip unavailable
optional features and match ordinary rejection errors exactly.
- Remove Assisted-by.
v2: https://lore.kernel.org/netdev/20261115114434.10343-2-leonard@lausen.nl/
.../selftests/net/netfilter/nft_fib.sh | 109 ++++++++++++++++++
1 file changed, 109 insertions(+)
diff --git a/tools/testing/selftests/net/netfilter/nft_fib.sh b/tools/testing/selftests/net/netfilter/nft_fib.sh
index 04544905c216..175bdfa825c9 100755
--- a/tools/testing/selftests/net/netfilter/nft_fib.sh
+++ b/tools/testing/selftests/net/netfilter/nft_fib.sh
@@ -202,6 +202,50 @@ check_fib_counter() {
return 0
}
+# Count probes matching the expected FIB result, then drop them.
+test_fib_suppress() {
+ local label="$1" expected="$2"
+ local result="${3:-oifname}" error err=0
+
+ if ! ip netns exec "$nsrouter" nft -f /dev/stdin <<EOF
+flush table ip6 filter
+table ip6 filter {
+ chain prerouting {
+ type filter hook prerouting priority -1;
+ ip6 saddr dead:1::99 icmpv6 type echo-request \
+ fib saddr . mark $result "$expected" counter drop
+ }
+}
+EOF
+ then
+ echo "FAIL: $label (could not load ruleset)"
+ return 1
+ fi
+ ip netns exec "$ns1" ping -6 -c 1 -W 0.1 -q dead:1::1 > /dev/null 2>&1
+ if [ "$result" = type ]; then
+ case "$expected" in
+ blackhole) error="Invalid argument" ;;
+ unreachable) error="No route to host" ;;
+ prohibit) error="Permission denied" ;;
+ esac
+ LC_ALL=C ip -net "$nsrouter" -6 route get dead:1::99 \
+ from dead:1::1 2>&1 |
+ grep -Fxq "RTNETLINK answers: $error" || err=1
+ else
+ ip -net "$nsrouter" -6 route get dead:1::99 from dead:1::1 |
+ grep -q "dev $expected " || err=1
+ fi
+ if check_fib_type_counter_family ip6 1 "$nsrouter" prerouting \
+ "$result" "$label" &&
+ [ "$err" -eq 0 ]; then
+ echo "PASS: $label"
+ else
+ echo "FAIL: $label"
+ ret=1
+ return 1
+ fi
+}
+
load_ruleset "$nsrouter"
load_ruleset "$ns1"
load_ruleset "$ns2"
@@ -845,6 +889,71 @@ test_fib_type "default table"
ip netns exec "$nsrouter" nft delete table ip filter
ip netns exec "$nsrouter" nft delete table ip6 filter
+# Keep the earlier IPv6 checks on the path without custom rules.
+# The router's logging RPF rules have already been removed here.
+if ip -net "$nsrouter" -6 rule add pref 100 to dead:1::99 table 128 \
+ suppress_prefixlength 0; then
+ ip -net "$nsrouter" -6 route add table 128 default \
+ via dead:2::99 dev veth1 || exit 1
+ ip -net "$nsrouter" -6 route add table 129 dead:1::/64 \
+ dev veth0 || exit 1
+ ip -net "$nsrouter" -6 rule add pref 101 to dead:1::99 \
+ table 129 || exit 1
+ ip netns exec "$nsrouter" nft add table ip6 filter || exit 1
+
+ test_fib_suppress "suppress default route" veth0 || ret=1
+ ip -net "$nsrouter" -6 route add table 128 dead:1::/64 \
+ dev veth1 || exit 1
+ test_fib_suppress "retain non-default route" veth1 || ret=1
+ ip -net "$nsrouter" -6 route del table 128 dead:1::/64 \
+ dev veth1 || exit 1
+
+ # Seed a PMTU exception while bypassing suppression of its parent route.
+ ip -net "$ns2" -6 route add dead:1::99/128 via dead:2::1 \
+ dev eth0 mtu 1280 || exit 1
+ ip netns exec "$ns2" sysctl -qw net.ipv6.conf.all.forwarding=1
+ ip -net "$nsrouter" -6 rule add pref 99 to dead:1::99 \
+ table 128 || exit 1
+ ip netns exec "$nsrouter" ping -6 -I dead:2::1 -M do -s 1400 -c 1 -W 1 \
+ dead:1::99 > /dev/null 2>&1
+ if ! ip -net "$nsrouter" -6 route get dead:1::99 from dead:1::1 |
+ grep -q 'mtu 1280'; then
+ echo "FAIL: could not create PMTU exception"
+ exit 1
+ fi
+ ip -net "$nsrouter" -6 rule del pref 99
+ test_fib_suppress "suppress cached default route" veth0 || ret=1
+ ip -net "$ns2" -6 route del dead:1::99/128
+ ip netns exec "$ns2" sysctl -qw net.ipv6.conf.all.forwarding=0
+
+ for type in blackhole unreachable prohibit; do
+ ip -net "$nsrouter" -6 route replace "$type" default \
+ table 128 || exit 1
+ test_fib_suppress "retain $type" "$type" type || ret=1
+ done
+
+ if ip -net "$nsrouter" -6 nexthop add id 1 blackhole; then
+ ip -net "$nsrouter" -6 route replace default nhid 1 \
+ table 128 || exit 1
+ test_fib_suppress "retain blackhole nexthop" \
+ blackhole type || ret=1
+ ip -net "$nsrouter" -6 route del table 128 default
+ ip -net "$nsrouter" -6 nexthop del id 1
+ else
+ echo "SKIP: blackhole nexthop objects unavailable"
+ [ "$ret" -eq 0 ] && ret=$ksft_skip
+ ip -net "$nsrouter" -6 route del table 128 default
+ fi
+
+ ip -net "$nsrouter" -6 rule del pref 100
+ ip -net "$nsrouter" -6 rule del pref 101
+ ip -net "$nsrouter" -6 route flush table 129
+ ip netns exec "$nsrouter" nft delete table ip6 filter
+else
+ echo "SKIP: IPv6 prefix suppression unavailable"
+ [ "$ret" -eq 0 ] && ret=$ksft_skip
+fi
+
test_fib_vrf
exit $ret
--
2.55.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net v3 0/3] ipv6: Honor prefix suppression for FIB lookups and cached routes
2026-11-16 15:01 [PATCH net v3 0/3] ipv6: Honor prefix suppression for FIB lookups and cached routes Leonard Lausen
` (2 preceding siblings ...)
2026-11-16 15:01 ` [PATCH net v3 3/3] selftests: netfilter: cover IPv6 FIB prefix suppression Leonard Lausen
@ 2026-11-17 9:13 ` Ido Schimmel
2026-11-17 11:10 ` Leonard Lausen
3 siblings, 1 reply; 9+ messages in thread
From: Ido Schimmel @ 2026-11-17 9:13 UTC (permalink / raw)
To: Leonard Lausen
Cc: netdev, David Ahern, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Pablo Neira Ayuso,
Florian Westphal, Phil Sutter, Shuah Khan, Daniel Borkmann,
netfilter-devel, coreteam, linux-kselftest, linux-kernel
On Mon, Nov 16, 2026 at 03:01:27PM +0000, Leonard Lausen wrote:
> Changes since v2:
> - Add the separate cached-exception fix and PMTU regression case.
Why?
I said (twice) that I will take care of it. It's not net material
(always broken) and should be routed via net-next. Please send v4
without the exception "fix" and the related test case.
Given you already have a patch for this, send it to net-next *after* the
fix is present there.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net v3 0/3] ipv6: Honor prefix suppression for FIB lookups and cached routes
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
0 siblings, 0 replies; 9+ messages in thread
From: Leonard Lausen @ 2026-11-17 11:10 UTC (permalink / raw)
To: Ido Schimmel
Cc: netdev, David Ahern, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Pablo Neira Ayuso,
Florian Westphal, Phil Sutter, Shuah Khan, Daniel Borkmann,
netfilter-devel, coreteam, linux-kselftest, linux-kernel
Hi Ido,
didn't realize it needs to be separated due to net-next and had included
it in v3 as it seemed straightforward enough. Will resend to net-next
after this series made it there. Apologies.
Best regards
Leonard
Am 17.11.26 um 10:13 schrieb Ido Schimmel:
> On Mon, Nov 16, 2026 at 03:01:27PM +0000, Leonard Lausen wrote:
>> Changes since v2:
>> - Add the separate cached-exception fix and PMTU regression case.
>
> Why?
>
> I said (twice) that I will take care of it. It's not net material
> (always broken) and should be routed via net-next. Please send v4
> without the exception "fix" and the related test case.
>
> Given you already have a patch for this, send it to net-next *after* the
> fix is present there.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net v3 2/3] ipv6: Honor suppress_prefixlength in fib6_lookup()
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
0 siblings, 1 reply; 9+ messages in thread
From: netdev-bot+sashiko @ 2026-11-19 6:03 UTC (permalink / raw)
To: leonard
Cc: netdev, dsahern, idosch, davem, edumazet, kuba, pabeni, horms,
pablo, fw, phil, shuah, daniel, netfilter-devel, coreteam,
linux-kselftest, linux-kernel
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?
Also, the selftest in "selftests: netfilter: cover IPv6 FIB prefix
suppression" covers blackhole, unreachable and prohibit, but not throw.
> +
> if (!rt)
> return false;
>
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116150132.9594-1-leonard%40lausen.nl
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net v3 3/3] selftests: netfilter: cover IPv6 FIB prefix suppression
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
0 siblings, 0 replies; 9+ messages in thread
From: netdev-bot+sashiko @ 2026-11-19 6:03 UTC (permalink / raw)
To: leonard
Cc: netdev, dsahern, idosch, davem, edumazet, kuba, pabeni, horms,
pablo, fw, phil, shuah, daniel, netfilter-devel, coreteam,
linux-kselftest, linux-kernel
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In the "suppress cached default route" case, the nftables check
cannot see the PMTU exception, so it adds no coverage beyond "suppress…
- [Low] If the PMTU exception is not created, the new block runs `exit 1`
(nft_fib.sh lines 920-924).
- [Low] The new comment "The router's logging RPF rules have already been
removed here." (nft_fib.sh line 894) is incomplete, and so is the…
--
selftests: netfilter: cover IPv6 FIB prefix suppression
This extends nft_fib.sh to check that IPv6 policy rules with
suppress_prefixlength 0 suppress a default route but keep a more-specific
route. It also checks that blackhole, unreachable and prohibit routes,
including a blackhole nexthop object, stay terminal. Each check needs a
positive nftables fib counter that agrees with an ordinary route lookup,
and one case seeds a PMTU exception to check that its parent default route
is still suppressed.
> diff --git a/tools/testing/selftests/net/netfilter/nft_fib.sh b/tools/testing/selftests/net/netfilter/nft_fib.sh
> index 04544905c2164..175bdfa825c9e 100755
> --- a/tools/testing/selftests/net/netfilter/nft_fib.sh
> +++ b/tools/testing/selftests/net/netfilter/nft_fib.sh
[ ... ]
> @@ -845,6 +889,71 @@ test_fib_type "default table"
> ip netns exec "$nsrouter" nft delete table ip filter
> ip netns exec "$nsrouter" nft delete table ip6 filter
>
> +# Keep the earlier IPv6 checks on the path without custom rules.
> +# The router's logging RPF rules have already been removed here.
[Severity: Low]
Is this comment accurate? The commit message makes the same claim:
"The router's logging RPF rules have already been removed by then,
allowing neighbour discovery during intentionally different
reverse-route states."
The prerouting RPF rule from load_ruleset() is gone by this point. But
after the earlier nft flush ruleset, the script calls
load_pbr_ruleset "$nsrouter", which installs:
table inet filter {
chain forward {
type filter hook forward priority raw;
fib saddr . iif oif gt 0 accept
log drop
}
}
After that, only the ip filter and ip6 filter tables are deleted. Nothing
removes inet filter until test_fib_vrf()->load_ruleset_vrf() runs flush
ruleset. So this logging RPF check on the forward hook is still loaded for
all of the new suppression checks.
None of the new probes are forwarded by nsrouter, so nothing breaks today.
Should the comment and the commit message say that the forward-hook RPF
rule is still in place? A later change that adds forwarded probes here
would have them logged and dropped.
> +if ip -net "$nsrouter" -6 rule add pref 100 to dead:1::99 table 128 \
> + suppress_prefixlength 0; then
[ ... ]
> + # Seed a PMTU exception while bypassing suppression of its parent route.
> + ip -net "$ns2" -6 route add dead:1::99/128 via dead:2::1 \
> + dev eth0 mtu 1280 || exit 1
> + ip netns exec "$ns2" sysctl -qw net.ipv6.conf.all.forwarding=1
> + ip -net "$nsrouter" -6 rule add pref 99 to dead:1::99 \
> + table 128 || exit 1
> + ip netns exec "$nsrouter" ping -6 -I dead:2::1 -M do -s 1400 -c 1 -W 1 \
> + dead:1::99 > /dev/null 2>&1
> + if ! ip -net "$nsrouter" -6 route get dead:1::99 from dead:1::1 |
> + grep -q 'mtu 1280'; then
> + echo "FAIL: could not create PMTU exception"
> + exit 1
[Severity: Low]
Does a failure here need to abort the whole selftest?
Creating the exception depends on more than a plain route add. The ping
binary must support -6 -I <addr> -M do -s, which busybox ping may not.
ns2 must forward the packet and send an ICMPv6 Packet Too Big. nsrouter
must then handle it via icmpv6_err()->ip6_update_pmtu() into the table 128
default route.
If any of those steps fails, the exit 1 skips the later blackhole,
unreachable, prohibit and nexthop checks. It also skips test_fib_vrf, which
is unrelated. The /128 mtu 1280 route and forwarding=1 in ns2 also stay set
until namespace cleanup.
The rest of this block records failures with || ret=1 and keeps going, and
the later checks don't depend on the exception. Could this path set ret=1
and skip only the "suppress cached default route" check?
> + fi
> + ip -net "$nsrouter" -6 rule del pref 99
> + test_fib_suppress "suppress cached default route" veth0 || ret=1
[Severity: Low]
Can the nftables part of this check see the PMTU exception at all?
The fib expression goes through nft_fib6_lookup():
net/ipv6/netfilter/nft_fib_ipv6.c:nft_fib6_lookup() {
return fib6_lookup(net, fl6->flowi6_oif, fl6, res, flags);
}
With custom rules, this resolves through
fib6_rule_action_alt()->fib6_table_lookup(). That function only uses
fib6_node_lookup() and rt6_select() to fill res->f6i, and never looks up
cached exceptions.
The fib6_table_lookup branch of fib6_rule_suppress() reads
res->f6i->fib6_dst.plen. That is the parent /0 entry whether or not an
exception exists.
So the nft counter here behaves the same as in "suppress default route",
with or without the fix from "ipv6: Use the FIB prefix length when
suppressing cached routes".
Only the ordinary lookup in test_fib_suppress() tests that fix:
ip -net "$nsrouter" -6 route get dead:1::99 from dead:1::1 |
grep -q "dev $expected " || err=1
That lookup goes through
ip6_route_output()->ip6_pol_route()->rt6_find_cached_rt().
This makes it a core IPv6 routing regression test inside nft_fib.sh.
nft_fib.sh is skipped entirely when nft is missing
(checktool "nft --version"). fib_tests.sh already has fib_suppress_test,
but that test doesn't cover cached exceptions.
Would fib_tests.sh be a better home for the cached-route case? If it stays
here, could the label say that only the ordinary lookup covers the cached
route?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116150132.9594-1-leonard%40lausen.nl
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net v3 2/3] ipv6: Honor suppress_prefixlength in fib6_lookup()
2026-11-19 6:03 ` netdev-bot+sashiko
@ 2026-11-19 16:57 ` Ido Schimmel
0 siblings, 0 replies; 9+ messages in thread
From: Ido Schimmel @ 2026-11-19 16:57 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: leonard, netdev, dsahern, davem, edumazet, kuba, pabeni, horms,
pablo, fw, phil, shuah, daniel, netfilter-devel, coreteam,
linux-kselftest, linux-kernel
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
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-11-19 16:58 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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®