🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #6744

Re: [PATCH 2/2] selftests: netfilter: add bridge conntrack test for vlan protocol mismatch

#6744
From: netdev-bot+sashiko
Date: Fri, 23 Oct 2026 09:04
151 lines
13257 bytes
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] In bridge_ct_vlan_proto.sh, the check "FAIL: conntrack did not
  reassemble the packets" cannot detect missing reassembly in the vlan…
- [Low] In bridge_ct_vlan_proto.sh, run_all() returns ksft_skip as soon
  as any run_case() returns ksft_skip, even after earlier cases have run.

--

selftests: netfilter: add bridge conntrack test for vlan protocol mismatch

This adds a selftest that sends fragmented IPv4 and IPv6 pings through a
vlan filtering bridge with bridge conntrack, using vlan tags whose
protocol differs from (or matches) the bridge's vlan_protocol. It checks
that the pings get through, that conntrack reassembled the packets, and
that the kernel did not warn.

> diff --git a/tools/testing/selftests/net/netfilter/bridge_ct_vlan_proto.sh b/tools/testing/selftests/net/netfilter/bridge_ct_vlan_proto.sh
> new file mode 100755
> index 000000000000..19f842e17060
> --- /dev/null
> +++ b/tools/testing/selftests/net/netfilter/bridge_ct_vlan_proto.sh
> @@ -0,0 +1,182 @@

[ ... ]

> +	# Loading a ct rule in the bridge family enables bridge conntrack. The
> +	# postrouting counter sees the packets reassembled by conntrack.
> +	ip netns exec "$ns0" nft -f - <<EOF || return "$ksft_skip"
> +table bridge t {
> +	chain pre {
> +		type filter hook prerouting priority 0; policy accept;
> +		ct state new counter
> +	}
> +	chain post {
> +		type filter hook postrouting priority 0; policy accept;
> +		meta length > 1400 counter
> +	}
> +}
> +EOF

[Severity: Medium]
Can this counter go up in the mismatch cases even when nothing was
reassembled?

In the 802.1ad/802.1q, 802.1q/802.1ad and clone cases, __allowed_ingress()
moves the tag into the packet after prerouting:

net/bridge/br_vlan.c:__allowed_ingress() {
    ...
		if (skb->vlan_proto != br->vlan_proto) {
			/* Protocol-mismatch, empty out vlan_tci for new tag */
			skb_push(skb, ETH_HLEN);
			skb = vlan_insert_tag_set_proto(skb, skb->vlan_proto,
							skb_vlan_tag_get(skb));
    ...
}

After that, skb->data sits at the 4 byte in-band vlan header. meta length
is skb->len, so the post chain sees the IP length plus 4.

With the 1400 byte mtu on eth0.100, each IPv6 fragment is
40 + 8 + 1352 = 1400 bytes. A fragment that was never reassembled shows up
in the post chain as 1404 bytes and matches "meta length > 1400". IPv4
fragments come out at exactly 1400 and don't match.

If bridge conntrack stopped defragmenting, nf_ct_bridge_refrag() would
return early:

net/bridge/netfilter/nf_conntrack_bridge.c:nf_ct_bridge_refrag() {
    ...
	if (!BR_INPUT_SKB_CB(skb)->frag_max_size)
		return NF_ACCEPT;
    ...
}

The fragments would still be forwarded, both pings would succeed, and the
"packets [1-9]" check in run_case() would still pass. The refragmentation
path this test targets would then go untested and nothing would flag it.

Also, run_case() checks this one shared counter only once, after both the
IPv4 and IPv6 pings. So the check can't tell which family was reassembled.

For the mismatch cases, the comment "The postrouting counter sees the
packets reassembled by conntrack" doesn't look accurate either.

Would one of these work instead: put the counter in prerouting, where the
tag is still hwaccel; use a threshold above any fragment size (for example
> 1500); or keep separate "meta nfproto ipv4" and "meta nfproto ipv6"
counters and check each one after its own ping?

[ ... ]

> +run_all()
> +{
> +	local rc
> +
> +	# bridge protocol, protocol of the vlan devices
> +	for case in "802.1q 802.1q" "802.1ad 802.1q" "802.1q 802.1ad" "802.1ad 802.1q clone"; do
> +		# shellcheck disable=SC2086
> +		run_case $case
> +		rc=$?
> +		if [ "$rc" -eq "$ksft_skip" ]; then
> +			return "$ksft_skip"
> +		fi
> +		[ "$rc" -ne 0 ] && ret=1
> +	done
> +
> +	return 0
> +}
> +
> +run_all
> +rc=$?
> +if [ "$rc" -eq "$ksft_skip" ] && [ "$ret" -eq 0 ]; then
> +	exit "$ksft_skip"
> +fi
> +
> +read -r t < /proc/sys/kernel/tainted
> +if [ $((t & taint_warn)) -ne 0 ]; then
> +	echo "FAIL: kernel warned"
> +	ret=1
> +fi

[Severity: Low]
Is it possible for a warning from an earlier case to get lost here?

run_all() returns ksft_skip as soon as any run_case() returns ksft_skip,
even when earlier cases have already run. The top level then exits with
ksft_skip before it reads /proc/sys/kernel/tainted.

Say an earlier case triggered a WARN but its pings still passed. ping -c 3
exits 0 if any reply arrives, so ret stays 0. If setup then fails in a
later case, for example because the 802.1ad bridge or vlan device can't
be created, the test reports SKIP and the WARN never gets reported.

The commit message says the test checks "that the kernel did not warn".
Could the taint check run before the skip decision, or could the test
fail whenever TAINT_WARN appears during the run?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261020000308.37362-1-laveeshb%40laveeshbansal.com
Technical Details
Message-ID: <179274624702.3134.15694473086180736851@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350989-linux-kernel-netdev=dewy.ru
References: <20261020005642.39494-1-laveeshb@laveeshbansal.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350989-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH 2/2] selftests: netfilter: add bridge conntrack test for
 vlan protocol mismatch
Date: Fri, 23 Oct 2026 09:04:07 +0000
Organization: Usenet Network
Message-ID: <179274624702.3134.15694473086180736851@kernel.org>
References: <20261020005642.39494-1-laveeshb@laveeshbansal.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="457476"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:pZDgp4TZY5qtQV8DvkvsWivYi7U= sha256:noyOSppxe57yTl/XZOCloCIGSyeI9uxRQP8oieCCRY0=
	sha1:UheqQ7ciEGVU2k41LWsGPCwbpvs= sha256:3lfMkd+6MsYAqF7A9LqGi7iEXtIu0pJ6tSq/48n06iQ=
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 09E7711144B; Fri, 23 Oct 2026 12:08:08 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.738
X-Spam-Status: No, score=-3.738 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
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 bCpDG1riUNHk;
	Fri, 23 Oct 2026 12:08:04 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-350989-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 00BE2111447; Fri, 23 Oct 2026 12:07:53 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 08C272C248; Fri, 23 Oct 2026 09:04:30 +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=1792746249;
	b=HhPUFVhkXH77Wqu51+sDet3GWhvvRgmNtDN/60L5PGK/bIh+B9UAT2/tlNdSOqc0Tq1c
	 DtwxRy9AlHYUNeZ9xMObbHkPv/BRUNnHTRe/utEXyYTwPImyiqlSu441oksHeRtOfrcnf
	 R9e7w4P4AU5BGGc4/658IT8AaP+qrYOj0k9tJk6IF4BF1XBG90ZdxGPx3GcJFObR6x3qZ
	 n6FHMnk8Qdh1PzGqCSRD3SGZ/2qk+J2f9T4sk9AiJAlewJuIhszEr6C2aFeu8xgjXOAzz
	 xhkfbeW77PotmrZIC+P1yytyQky4olol0AdygDxU/eV+FGGJwmYsGvonTlZLdl8eLAA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792746249;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=Qm6mggyFBa11YEU0QCjD5Fk5lL6IMH1f7dPerchKVUE=;
	b=08UBm3bbApU4HbIOETrI/A24oCxFTG/QAlufG0+l+C1D7Mf2dENkjHbu69ObBQhH/Zmj
	 5lldhqMg1xQEgN+hAoxN3WQ8g2XV/DU0lIyJ904GX3B8J2HlkY8bs9RyyOHZ3QoKXkzuu
	 jv/4JPqzk+w26bwCMwI/viE+PpSSlE283px2XTNqw/6swqlekWfTIWlr1iN/gVaOZvsef
	 YeJKcwBuYt1awzjRt3mpJjVmVPkhcXariK1/SCqNa2C/7fxCsl6l6IzODcRUZGAXqZ3I8
	 Yn2Q//8VcRbb0Uqe0NJKncWhUXODvA9LXZ8XhKSuQfltcl7btwVJS+MGngNzFt/XcRg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DnBCsOTz;
	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 64C2A60A260D;
	Fri, 23 Oct 2026 09:04:09 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DnBCsOTz
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792746248;
	b=YchPv1F7A4KMPIJyRvWzHcvswYV+pMD+oWzKchWuP4DECvAN+EXR+s+3zK52sZSgxKMo
	 9bAVcddrj+A48b0uFqFH1y6O4ONu4D03ghf5xVRhyes3ZoZLH0DL1BVwNH1ClKhqF1duC
	 x2jEHd9jr8QNZKYGoLraEDA788aLaiajXH3PkP324qfNuUP+vRcaIBMci5ja0ZOMwPGco
	 Lvh/8JbVFEvQI5zYyDtJcwLhrfM+7KsVVCIuBmD8+XMAcGsFtUUc9af78gd4jc22OeKXH
	 d3DQ6jwGvXOQdMEmdTbY2vvgX+WY9NxJIRAQ33nRtQeG5NJGp74f+hAG9o2pEs/Ht5Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792746248;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=Qm6mggyFBa11YEU0QCjD5Fk5lL6IMH1f7dPerchKVUE=;
	b=XTACjF06l6RKrFZdzi6ASefNNSTPnoNfR/hbJA9TDiBYbfqWCA+AYugA5KHjikI7e60C
	 Xo7j5y2wc9db58MWPhTF/rldOHTfsQTeRzdj6VbtlBoQGonDKiwW4r7sORJ5HiaIL1hFu
	 UJ2566UfUHEPwbpOUQbqiZE0Lhnvi49m3wFa/5upB8gb4oUlVfHGZMlWz4tJ0gR7SYFRb
	 6ZbXTbTx9q/lFHsMAtG+5HDp3mc8ah6X6bn0RkZB4FDhekMvo+CpXd0V8hK8abkQLuMX0
	 b77zPfNTiPDs82mWifgWOPrbNK5YQyQefdmfFBgyO31QPYqvi787WzPetZN0eNgxk8g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DnBCsOTz;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(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 3CEE5606A31D;
	Fri, 23 Oct 2026 09:04:08 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BDE01F01828;
	Fri, 23 Oct 2026 09:04:07 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1792746247;
	bh=Qm6mggyFBa11YEU0QCjD5Fk5lL6IMH1f7dPerchKVUE=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=DnBCsOTzNMdKB2pJNE+2E9UYRrUzuWSaMMO2PcVdng+vd51zPEqpt0wkUygiGSy/l
	 WdQQQB2NR0cgCYC5+SQoPrF+URpMM14WbtDZ1m4vNvRiwoNDkESM3fAoZ+785wF9tp
	 ki67AFL8hFo+NICacOUVQlcxyt8T4i+M4rXpJBIdxq/GzCJZHoqOaOCSFazZ7rz4uj
	 XyIO63lHQficXvPmvg6gw21JIhmUjsp/voXzrYf8Tfh30ifmXNtvGL9EFWnR1fBZAr
	 Z6XYnYikEpl2YleZZKodx0CzAb2++yE1040ZQYQCy9yS4vh06rZy+xefBm1BDOfs7c
	 p3+/9wJXgAkEA==
X-Cc: pablo@netfilter.org, fw@strlen.de, razor@blackwall.org, idosch@nvidia.com,
 netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
 bridge@lists.linux.dev, netdev@vger.kernel.org, kuba@kernel.org
X-In-Reply-To: <20261020005642.39494-1-laveeshb@laveeshbansal.com>
X-sashiko-severity: Medium
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