From: Julius Bairaktaris <julius@bairaktaris.de>
To: pablo@netfilter.org, fw@strlen.de
Cc: phil@nwl.cc, netfilter-devel@vger.kernel.org,
coreteam@netfilter.org, netdev@vger.kernel.org,
lorenzo@kernel.org, nbd@nbd.name, matthias.bgg@gmail.com,
angelogioacchino.delregno@collabora.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, corbet@lwn.net,
rdunlap@infradead.org, skhan@linuxfoundation.org,
linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-mediatek@lists.infradead.org,
linux-arm-kernel@lists.infradead.org, saeedm@nvidia.com,
leon@kernel.org, tariqt@nvidia.com, mbloch@nvidia.com,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH nf-next v3 3/3] selftests: netfilter: nft_flowtable.sh: check the priority a flow carries
Date: Sun, 4 Oct 2026 19:16:36 +0200 [thread overview]
Message-ID: <20261004171636.3545085-4-julius@bairaktaris.de> (raw)
In-Reply-To: <20261004171636.3545085-1-julius@bairaktaris.de>
Count the forwarded TCP packets that leave with priority 0:3 and those
that leave with none, first without a priority and then with "meta
priority set 0:3" ahead of "flow add". With the priority set, every
packet must carry it, including those the flowtable forwards. Runs for
IPv4 and IPv6.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
.../selftests/net/netfilter/nft_flowtable.sh | 110 ++++++++++++++++++
1 file changed, 110 insertions(+)
diff --git a/tools/testing/selftests/net/netfilter/nft_flowtable.sh b/tools/testing/selftests/net/netfilter/nft_flowtable.sh
index 449c518bd947..73c7b1ec2208 100755
--- a/tools/testing/selftests/net/netfilter/nft_flowtable.sh
+++ b/tools/testing/selftests/net/netfilter/nft_flowtable.sh
@@ -458,6 +458,106 @@ fi
check_dscp "dscp_fwd" "$pmtu"
}
+check_priority()
+{
+ local what="$1"
+ local pmtu="$2"
+ local ok=1
+
+ local counter
+ counter=$(ip netns exec "$nsr1" nft reset counter netdev priocheck prio3 | grep packets)
+ local pc3=${counter%*bytes*}
+ pc3=${pc3#*packets}
+
+ counter=$(ip netns exec "$nsr1" nft reset counter netdev priocheck prio0 | grep packets)
+ local pc0=${counter%*bytes*}
+ pc0=${pc0#*packets}
+
+ local failmsg="FAIL: pmtu $pmtu: $what counters do not match, expected"
+
+ case "$what" in
+ "prio_none")
+ if [ "$pc3" -gt 0 ] || [ "$pc0" -eq 0 ]; then
+ echo "$failmsg prio3 == 0, prio0 > 0, but got $pc3,$pc0" 1>&2
+ ret=1
+ ok=0
+ fi
+ ;;
+ "prio_fwd")
+ if [ "$pc3" -eq 0 ] || [ "$pc0" -gt 0 ]; then
+ echo "$failmsg prio3 > 0, prio0 == 0, but got $pc3,$pc0" 1>&2
+ ret=1
+ ok=0
+ fi
+ ;;
+ *)
+ echo "FAIL: pmtu $pmtu: unknown priority check $what" 1>&2
+ ret=1
+ ok=0
+ esac
+
+ if [ "$ok" -eq 1 ] ;then
+ echo "PASS: $what: priority packet counters match"
+ fi
+}
+
+test_tcp_forwarding_set_priority()
+{
+ local pmtu="$3"
+ local proto="$4"
+ local dstip="$5"
+ local dstport="$6"
+ local lret=0
+
+ip netns exec "$nsr1" nft -f - <<EOF
+table netdev priocheck {
+ counter prio0 { }
+ counter prio3 { }
+
+ chain egress0 {
+ type filter hook egress device "veth0" priority 0; policy accept
+ meta l4proto tcp meta priority 0:3 counter name "prio3"
+ meta l4proto tcp meta priority none counter name "prio0"
+ }
+
+ chain egress1 {
+ type filter hook egress device "veth1" priority 0; policy accept
+ meta l4proto tcp meta priority 0:3 counter name "prio3"
+ meta l4proto tcp meta priority none counter name "prio0"
+ }
+}
+EOF
+ if [ $? -ne 0 ]; then
+ echo "SKIP: Could not load netdev:egress for veth0 and veth1"
+ return 0
+ fi
+
+ if ! test_tcp_forwarding_ip "$1" "$2" "$pmtu" "$proto" "$dstip" "$dstport"; then
+ lret=1
+ fi
+ check_priority "prio_none" "$pmtu"
+
+ # The flow stores the priority set before it is added, so the packets
+ # the flowtable forwards leave with it too, in both directions.
+ip netns exec "$nsr1" nft -f - <<EOF
+table inet prioset {
+ chain forward {
+ type filter hook forward priority -1; policy accept
+ meta priority set 0:3
+ }
+}
+EOF
+ if ! test_tcp_forwarding_ip "$1" "$2" "$pmtu" "$proto" "$dstip" "$dstport"; then
+ lret=1
+ fi
+ check_priority "prio_fwd" "$pmtu"
+
+ ip netns exec "$nsr1" nft delete table inet prioset
+ ip netns exec "$nsr1" nft delete table netdev priocheck
+
+ return $lret
+}
+
test_tcp_forwarding_nat()
{
local nsa="$1"
@@ -516,6 +616,11 @@ else
ret=1
fi
+if ! test_tcp_forwarding_set_priority "$ns1" "$ns2" 0 6 "[dead:2::99]" 12345; then
+ echo "FAIL: IPv6 flow offload for ns1/ns2 with priority update" 1>&2
+ ret=1
+fi
+
# delete default route, i.e. ns2 won't be able to reach ns1 and
# will depend on ns1 being masqueraded in nsr1.
# expect ns1 has nsr1 address.
@@ -572,6 +677,11 @@ if ! test_tcp_forwarding_set_dscp "$ns1" "$ns2" 1 4 10.0.2.99 12345; then
exit 0
fi
+if ! test_tcp_forwarding_set_priority "$ns1" "$ns2" 1 4 10.0.2.99 12345; then
+ echo "FAIL: flow offload for ns1/ns2 with priority update and pmtu discovery" 1>&2
+ ret=1
+fi
+
ip netns exec "$nsr1" nft reset counters table inet filter >/dev/null
if ! test_tcp_forwarding_nat "$ns1" "$ns2" 1 ""; then
--
2.53.0
next prev parent reply other threads:[~2026-10-04 17:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-04 17:16 [PATCH nf-next v3 0/3] netfilter: flowtable: carry a priority into the offload Julius Bairaktaris
2026-10-04 17:16 ` [PATCH nf-next v3 1/3] net/mlx5e: Ignore FLOW_ACTION_PRIORITY on flowtable offload Julius Bairaktaris
2026-10-05 17:16 ` sashiko-bot
2026-10-04 17:16 ` [PATCH nf-next v3 2/3] netfilter: flowtable: carry a priority into the offload Julius Bairaktaris
2026-10-05 17:16 ` sashiko-bot
2026-10-04 17:16 ` Julius Bairaktaris [this message]
2026-10-05 17:16 ` [PATCH nf-next v3 3/3] selftests: netfilter: nft_flowtable.sh: check the priority a flow carries sashiko-bot
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=20261004171636.3545085-4-julius@bairaktaris.de \
--to=julius@bairaktaris.de \
--cc=andrew+netdev@lunn.ch \
--cc=angelogioacchino.delregno@collabora.com \
--cc=corbet@lwn.net \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-rdma@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=mbloch@nvidia.com \
--cc=nbd@nbd.name \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=phil@nwl.cc \
--cc=rdunlap@infradead.org \
--cc=saeedm@nvidia.com \
--cc=skhan@linuxfoundation.org \
--cc=tariqt@nvidia.com \
/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