* [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; 5+ 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] 5+ 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; 5+ 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] 5+ 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-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, 0 replies; 5+ 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] 5+ 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-17 9:13 ` [PATCH net v3 0/3] ipv6: Honor prefix suppression for FIB lookups and cached routes Ido Schimmel
3 siblings, 0 replies; 5+ 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] 5+ 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
3 siblings, 0 replies; 5+ 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] 5+ messages in thread
end of thread, other threads:[~2026-11-17 9:13 UTC | newest]
Thread overview: 5+ 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-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
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®