🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #17285

[PATCH net v3 3/3] selftests: netfilter: cover IPv6 FIB prefix suppression

#17285
From: Leonard Lausen
Date: Mon, 16 Nov 2026 15:01
164 lines
15566 bytes
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
Technical Details
Message-ID: <20261116150132.9594-4-leonard@lausen.nl>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364491-linux-kernel-netdev=dewy.ru
References: <20261116150132.9594-1-leonard@lausen.nl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364491-linux-kernel-netdev=dewy.ru
From: leonard@lausen.nl (Leonard Lausen)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v3 3/3] selftests: netfilter: cover IPv6 FIB prefix suppression
Date: Mon, 16 Nov 2026 15:01:30 +0000
Organization: Usenet Network
Message-ID: <20261116150132.9594-4-leonard@lausen.nl>
References: <20261116150132.9594-1-leonard@lausen.nl>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2092697"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:TAyzvIyln1SAX+4BadAstZruBj0= sha256:s3J13RHDty4tzg+EtB595ZzfjbjF5AlaDT+KFgTQgkQ=
	sha1:8pMYxO++mZ4jH+13VPyuTXvyf20= sha256:8DrlHop2TSYmkhgBvrHQ2xQ8VLL+E7XKgoSPobGMwHQ=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id CC92F114CA3; Mon, 16 Nov 2026 18:02:37 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (4096-bit key)
	header.d=lausen.nl
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id vKCFXbDpeTsY;
	Mon, 16 Nov 2026 18:02:32 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-364491-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=lausen.nl
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 427CF114C81; Mon, 16 Nov 2026 18:02:16 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 71D332E420; Mon, 16 Nov 2026 15:02:04 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794841314;
	b=w1KDY8GpNx/JwVCGrp9issO8hDlJO2hXlUfaXljVPqHp7G97VXgJrXa70U4qugIFnwDU
	 JX5JNRbZBGaWczR41IFwkRx7WnwxEYu13pTiWFaObpofAVcNxiD4VIRz3NWH80gE4tlq9
	 ppyhaNCrCDt320yG+G+qGW5Tq/RPRA6DP3eNmUxZ7vY5qhl83g0QQP0AtdnTGuTYVpAmZ
	 T4skBwunj/qXCaTVUHV7/7bUcJaCtvMcqhq2wT2susp2nJ2e/S+dvI6c7BLcrG/SqDLUj
	 0/w5PTFePyup5+NS1SiSQ+PS2Xp3eCx23+J+jsu38xCA0NPPBjT3rrxtZams5aFhqMg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794841314;
	h=X-Original-To:Received:DMARC-Filter:Received:Received:Received:From:
	 To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding:X-Rspamd-Bar:X-Rspamd-Report:X-Rspamd-Score:
	 DKIM-Signature;
	bh=wU42Xv+oriwKZx/rxk+EnNc9SsYqK4jjpZoanBLi7Wo=;
	b=wIWQqbAYylwG9N2NzpfGsGTu8mmSnf0eBrrV1WgyzcjzYiaW9LRJzfWwkmwLMsmb+4oD
	 8M/kCUTFLK0wdCDUhUS/7qNnxmC6bpVb2tDioMNk3+tYbqy5zyGK3ZaBYTLUWVzJrVygq
	 P/gvYF4VFdgOoX8r9/3JFDIvqkY1QJu7RJyrEXAhAq5FdOdFiRhs8wRsfYMNjL64vPH1z
	 y2UpSHFZe+Km1H21vKRk//Ma33VufAenvfJHw5eY9KmLUMwetogHkOaNi9f1Ece6YBubD
	 S0h8XZwuvQewM2wGWks1sMh3rgk+SaaRBfPgTpMmm1oIbZ5LwR0QqDGx165MaN41pNA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=lausen.nl header.i=@lausen.nl header.a=rsa-sha256 header.s=uberspace header.b=DyAulS2B;
	dmarc=pass header.from=lausen.nl;
	spf=pass smtp.mailfrom=lausen.nl;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A491606A8BD;
	Mon, 16 Nov 2026 15:01:54 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (4096-bit key) header.d=lausen.nl header.i=@lausen.nl header.a=rsa-sha256 header.s=uberspace header.b=DyAulS2B
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.143.172.20
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794841313;
	b=B+n+5in3045Yo1F5sgB0aNEMcq0EkjMsyzxF0kt9AjvOt+oKlhKtLXt3ljdQdSDB2OGZ
	 +lQQuJw3nr9z/r44o1zzZNqcbxU/2Nc754BDX3ng/D6HGJFUGEr0VTEFKXbhVnyTyzu+L
	 riJk6iG1XUidjbeqnC8+kfpVfZZ761tgFqzXdmmMAkKgCwc1rL9/tDyyNy9JloQ3d0TqM
	 znNl14+XnLOHqLZ5slWmV10vQpOM8IB5Y4g0grRBYlISPxjW+9X6n+hcfX5klnanJExHS
	 vn6DfgMMsSMDK9K32E3UxQgHoF8XV6me20/yjJCzTkI3sUMZjYp8+g37pcUjgCQHPeg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794841313;
	h=DMARC-Filter:Received:Received:Received:From:To:Cc:Subject:Date:
	 Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding:X-Rspamd-Bar:X-Rspamd-Report:X-Rspamd-Score:
	 DKIM-Signature;
	bh=wU42Xv+oriwKZx/rxk+EnNc9SsYqK4jjpZoanBLi7Wo=;
	b=w2WCTOj9GMsQpVkF2OYiqUFt+KtsSmO393eEUf+LwoO/3yJBxVHsU5so7wjk+whyKkHp
	 Sg3P5h6KsCpqFUACrd7kwhQ7F7Xob28Bm3CrSZyY8Po4eg6hNydKLKpHHR8nq6kbV/FWh
	 CnNBj+lLg+acwQexFd4dYKdSzFkgcA7iQhaPAwNiy3bojpYjRIidy7EDA+qKTTDQrG7YA
	 PYClZu68ojRCwvq1o6LYc4hXFXJgmpSi57yilueE0DVp0xgw8vwBrWkJVPqQTvfWNeuZM
	 q9y3zwKapoxt2/wSIKJkzU9xu5onpwCdgl29zXFFImtoA2aKbTVW85oWLvTzHVQnLXQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=lausen.nl;
	spf=pass smtp.mailfrom=lausen.nl;
	dkim=pass header.d=lausen.nl header.i=@lausen.nl header.a=rsa-sha256 header.s=uberspace header.b=DyAulS2B;
	arc=none smtp.remote-ip=95.143.172.20
X-Received: from mailgate01.uberspace.is (mailgate01.uberspace.is [95.143.172.20])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45AC9606A323
	for <netdev@vger.kernel.org>; Mon, 16 Nov 2026 15:01:53 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 45AC9606A323
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lausen.nl
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lausen.nl
X-Received: from devico.uberspace.de (devico.uberspace.de [185.26.156.185])
	by mailgate01.uberspace.is (Postfix) with ESMTPS id 00C4A60B9D
	for <netdev@vger.kernel.org>; Mon, 16 Nov 2026 16:01:47 +0100 (CET)
X-Received: (qmail 22990 invoked by uid 990); 16 Nov 2026 15:01:47 -0000
X-Authentication-Results: devico.uberspace.de;
	auth=pass (plain)
X-Received: from unknown (HELO unknown) (::1)
	by devico.uberspace.de (Haraka/3.1.1) with ESMTPSA; Mon, 16 Nov 2026 16:01:47 +0100
X-Cc: leonard@lausen.nl,
	David Ahern <dsahern@kernel.org>,
	Ido Schimmel <idosch@nvidia.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.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>,
	Daniel Borkmann <daniel@iogearbox.net>,
	netfilter-devel@vger.kernel.org,
	coreteam@netfilter.org,
	linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.55.0
X-In-Reply-To: <20261116150132.9594-1-leonard@lausen.nl>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-Rspamd-Bar: -----
X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.999838) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5)
X-Rspamd-Score: -5.599838
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
	d=lausen.nl; s=uberspace;
	h=from:to:cc:subject:date;
	bh=lOr4fHWDJmDbv/ZQHO6T7OQiyEAQ/Lb9RxYZKQiNakc=;
	b=DyAulS2BaAkK3Ym+Nm2xUoNNuscFK5rsovTLXwQ2ExAb66CbC7I0BuE66Mi8M4TwY8Ojs+FHdm
	Xd2Pxd5/nn9YH+iFL4sCyqD0ur1Cuqv3aGqA90Fn1QnRISDaS/zSLtm51+PPeZlbdDio8a+KiUdP
	e8+hrHpqQTArW16OSmVS9iYiKJg7e1/jN+L0uAdzdpxYH6lyOIZrZ3A7GaOe/StpQnhP0+tclf0j
	2nQb/Xz8ZVfuOeB914vyjLMZjK9Vr++vCoqlOLQghsdX37wez8BSkzQPSlkjWRyxztuEXurkVVhp
	GikWSPnmvxyfBSw9amrF8Cv2SdIzukLTQdaC7mcShbKu7KrzA5Dk2cnAw5NWwSrj6eXVqzk4N8Fx
	+siB3Xk0duRoL8SeDQ3/BPKfYem5q+783QyjOia2RFHzqcLfJi+hfiNXpxaZBNV5KdGsyEOt8OMV
	2vVid9W1zfVK49yMJrS84IvFH/lkODK5R6/y1mtaN83/FPIK6qoPk11PdAvsHipSy4aaramV4CUS
	Oy7YCJDD0MY6FukYocUjj8sifA47xO+2Iqpg6NfY4uaYmJiv2f8CLKoWZyMLiaX7pJT1yfpIrK5c
	9dwYGzTOVDWjUsWFeadrV/y4tQPXL4GmQcaKXfDd6S+QLveZxA86artBs1aK94DbrchaIXNvKYeA
	c=