From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.143.172.20 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794913712; b=aokYsYCg8EUFwvOspHExtD+iiRCoY25y2PHFjLkk0tK0CNB0bzmF/hBPn5uj1EEys+W5 Sv94ZIUsSulNoMHsw7bLa4cGTaHL+RX3XjMDBdeH8u8kvnYIcb9XSYj1n9g0dQViXkLhQ 7HIsJEINQpLVCuBpXm8/BYJ4QdLYy9My0oMlQd8mO1aKn1DTZXmi0suqBHMug0PooEoSQ UqqBb9pIs/bCviFfrNzuYzadt1fB2BzsCsHFes1RJjzaEpFk+spQPDouVEdJ4ZSUAmnfL Y/Vgu7ooDo/P3bj+aBusOsBjTJaCWXGkHtKF7tyyYkkxfDzR2MIH/YmbgjaCqXAe95Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794913712; 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=/RvB3qJv6CSbIlr5KiUVbq8iym8xVaZo8csqTV6KZro=; b=JJjM8rIGBCNZHmV0hOOFQ8ZEFIFZhoEql/c28r94oP9RMegj3BaY9IbCwf9DycxNdve3 0HdrpP+KoedLaO2qJCbFNXn0k4fOQH2s+HaJ0QWY+GPHl9ErVDYnxJ8kPKPfCgmjSy2bu ldxA+ikm2v1Djfxhw+OVawnnKEeuL0o7mSYla9cjmPItsgQXY5U6EbH27SyGNoUiywWsv kYuFEKpV9EZ1s5vy/Lv4Cd80h4RCyDNYAaO+UiZQBKgQAb9vKXI7/F/UaYfpAkAXeDf21 3vbAI3dG/FZDF5tdpTWCMkPwZGIuP8zV4CSqLG/0CkNdT38Cq3SE31jsyn4Re2i4Wlw== 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="FxKd/VOa"; arc=none smtp.remote-ip=95.143.172.20 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 6E13D606A89D for ; Tue, 17 Nov 2026 11:08:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6E13D606A89D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lausen.nl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lausen.nl 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=FxKd/VOa Received: from devico.uberspace.de (devico.uberspace.de [185.26.156.185]) by mailgate01.uberspace.is (Postfix) with ESMTPS id C9EA261085 for ; Tue, 17 Nov 2026 12:08:29 +0100 (CET) Received: (qmail 22605 invoked by uid 990); 17 Nov 2026 11:08:29 -0000 Authentication-Results: devico.uberspace.de; auth=pass (plain) Received: from unknown (HELO unknown) (::1) by devico.uberspace.de (Haraka/3.1.1) with ESMTPSA; Tue, 17 Nov 2026 12:08:29 +0100 From: Leonard Lausen To: netdev@vger.kernel.org Cc: leonard@lausen.nl, 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@vger.kernel.org, coreteam@netfilter.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v4 2/2] selftests: netfilter: cover IPv6 FIB prefix suppression Date: Tue, 17 Nov 2026 11:08:12 +0000 Message-ID: <20261117110813.9894-4-leonard@lausen.nl> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261117110813.9894-2-leonard@lausen.nl> References: <20261117110813.9894-2-leonard@lausen.nl> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.999923) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599923 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lausen.nl; s=uberspace; h=from:to:cc:subject:date; bh=0+6TucBtJP1EvGaCe3sII8W6Vv25yTZVBM+bEdyPi40=; b=FxKd/VOaJgjwnB4Tf7G/evoiBVXND85GdiEFotGnZOh+NzeDMCIjA1lVXNvlw6tOwIslSNHc9M 4SsGpg+gXS9ynEyB0zMdpks6lIXvSwsBRjjh1UuKtiULDwT7hOTDwmeF6r3pQ8XR8aR7SkKN1dp2 5fHB8qCr2KncDn42/zMWCWvJayeg5958WbskLDhcZ4ABTKmV+USxBDhQBf4LjYiHzlQLEtmzsImr hzXjVa4TUpHA1WLgyYyDDBaqlryTyS9TgnIcs9Q+2A9ZVdwSmopgWperNA2ZT7WdwvqnfUfJnt7l P6idt7eds3wOOrwo8Hv6z9DTmzDQ/iIpOapZW9mwPDwfT6JUBIBY8ZKsPPLAXw7RsVZNRd2/Ri8x SQzsTeBcbX3gWdvI1tRsQ5u94NvOn4Eog7lzjdyiEy3DpxtR2vWh+zBj6SvOnceuJ6S5AvDJm3PD ZouAAQyApf2ir0niVyDh0ryotmJ1uLUBnR41+TYI4gvUp5IA/p2R4HBsd7xGv0mZpXTCrzwcG2A0 jLUkKhyhu/C4QQ+Vuge7GKaqETwLcqMnVBFP9pAGP57NJaDo9mZFBbcH5GBRhVsh+6wdS4R5/B1R dAWyh2tM6+p3PT4Ow9/VCHAYk+m+uiaP3kSqup2gQ4I29rsatayi+58ZIkcyffcuV0RgVZu1ACTR Q= 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. 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 --- v4: - Drop the cached-default PMTU case and its fixture setup. - Retain the six prefix-suppression and terminal-reject checks from v3. Verified on the rebuilt v4 laptop kernel (7.4.0-rc2+ #6): all six added checks pass in full normal and eight-second-delayed nft_fib.sh runs. Both runs exit 0; twelve separate reject-route controls also pass. V3 review: https://lore.kernel.org/netdev/20261117091340.GA581197@shredder/T/#t .../selftests/net/netfilter/nft_fib.sh | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/tools/testing/selftests/net/netfilter/nft_fib.sh b/tools/testing/selftests/net/netfilter/nft_fib.sh index 04544905c216..25e13197f057 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 < /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,52 @@ 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 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 + + 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