Article View: linux.kernel.netdev
Article #25099Re: [PATCH net-next v13 8/8] selftests: hsr: Add test for the inline PTP header on HSR
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 08:55
Date: Tue, 01 Dec 2026 08:55
181 lines
14338 bytes
14338 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 2
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] hsr_ptp.sh starts `ip netns exec $ns1 ./hsr_ptp_test` (line
90) right after setup_hsr_interfaces() runs its last `ip link set ...…
- [Low] The file header comment of
tools/testing/selftests/net/hsr/hsr_ptp_test.c (lines 5-7) says the…
- [Low] hsr_ptp_test only works on HSRv1 devices, but neither the commit
message ("This test needs a HSR device and the two slave devices…
--
selftests: hsr: Add test for the inline PTP header on HSR
This commit adds a selftest for the inline header that the HSR stack
accepts with ether type ETH_P_1588. The hsr_ptp_test binary sends four PTP
frames through the HSR master, with and without a caller-supplied HSR
header, and checks that each one only appears on the requested slave port.
The hsr_ptp.sh wrapper sets up three HSRv1 nodes and runs the binary in
each namespace.
> diff --git a/tools/testing/selftests/net/hsr/hsr_ptp.sh b/tools/testing/selftests/net/hsr/hsr_ptp.sh
> new file mode 100755
> index 0000000000000..5fd3c5cd7a1cf
> --- /dev/null
> +++ b/tools/testing/selftests/net/hsr/hsr_ptp.sh
> @@ -0,0 +1,110 @@
[ ... ]
> + ip -net "$ns3" link set ns3eth1 up
> + ip -net "$ns3" link set ns3eth2 up
> + ip -net "$ns3" link set hsr3 up
> +}
> +
> +run_ptp_hdr_tests()
> +{
> + echo "INFO: Running PTP-header tests."
> +
> + ip netns exec "$ns1" ./hsr_ptp_test -H hsr1 -A ns1eth1 -B ns1eth2
> + ret=$?
> + stop_if_error "PTP header test failed (ns1)."
[ ... ]
> +check_prerequisites
> +trap cleanup_all_ns EXIT
> +
> +setup_ns ns1 ns2 ns3
> +setup_hsr_interfaces 1
> +run_ptp_hdr_tests
[Severity: Medium]
Can the first hsr_ptp_test run send its frame before the links are fully
active?
run_ptp_hdr_tests() starts right after the last "ip link set ... up" in
setup_hsr_interfaces(), and nothing waits in between. hsr_ping.sh,
hsr_redbox.sh, hsr_prp_redbox.sh and link_faults.sh all sleep or wait after
setup.
When a veth peer comes up, the other side gets carrier through the
asynchronous linkwatch work. Until linkwatch calls dev_activate(), that
device's TX queue is still on noop_qdisc:
net/sched/sch_generic.c:dev_activate() {
...
if (!netif_carrier_ok(dev))
/* Delay activation until next carrier-on event */
return;
...
}
The hsr master's carrier also only follows the slave operstate, which
linkwatch sets.
If pkt_send() runs inside that window, noop_enqueue drops the frame on
either hsrN or the slave. send() still succeeds, because NET_XMIT_CN maps
to 0 and hsr_dev_xmit() returns NETDEV_TX_OK. raw_recv() then times out
after 100ms, and recv_verify() reports "Missing packet on portA" or
"Missing packet on portB".
Would it make sense to wait for carrier/operstate on the hsr and slave
devices before running the test, as the other scripts here do?
> diff --git a/tools/testing/selftests/net/hsr/hsr_ptp_test.c b/tools/testing/selftests/net/hsr/hsr_ptp_test.c
> new file mode 100644
> index 0000000000000..e2c2da56138ae
> --- /dev/null
> +++ b/tools/testing/selftests/net/hsr/hsr_ptp_test.c
> @@ -0,0 +1,496 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Simple test to verify the usage of the inline header used for HSR with
> + * ether type ETH_P_1588.
> + * The inline header has to be stripped, the sent packet must only appear on the
> + * specified port and the interface needs to accept a foreign HSR header and
> + * prepend its own header.
[Severity: Low]
Is "prepend its own header" accurate?
hsr_forward_do() clones a frame that has has_hsr_header set and sends it
out unchanged:
net/hsr/hsr_forward.c:hsr_forward_do() {
...
/* If this TX frame already has a HSR header then forward the
* frame with it and don't add one.
*/
if (frame->has_hsr_header && frame->skb_std) {
skb = skb_clone(frame->skb_std, GFP_ATOMIC);
...
goto inject_into_stack;
}
...
}
This path skips create_tagged_frame(), and hsr_xmit() also skips address
substitution when has_hsr_header is set.
The fwd_hsr checks in raw_recv() agree with the kernel, not with this
comment. They expect the caller's sequence number, the caller's flipped
source MAC and encap_type == ETH_P_1588 to come through unchanged.
Could the comment say that a supplied HSR header is forwarded as-is?
[ ... ]
> + /* Assuming it is *our* network and nobody but the test here sends
> + * packets to p2p_dst_mac. Therefore any received packet needs to be
> + * ours and every mismatch is considered as error.
> + */
> + if (memcmp(hsr_hdr->dst, p2p_dst_mac, MAC_LEN))
> + goto again;
> +
> + if (hsr_hdr->type != htons(ETH_P_HSR)) {
> + printf("Error: Unexpected ether type: 0x%x\n", ntohs(hsr_hdr->type));
> + return -1;
> + }
[Severity: Low]
Would this check fail on an HSRv0 device that is working correctly?
For version 0, hsr_fill_tag() tags frames with ETH_P_PRP:
net/hsr/hsr_forward.c:hsr_fill_tag() {
...
hsr_ethhdr->ethhdr.h_proto = htons(proto_version ?
ETH_P_HSR : ETH_P_PRP);
...
}
On v0, the no-hsr-header subtests would then print "Unexpected ether type:
0x88fb" and fail. hsr_dev_xmit() and hsr_ptp_parse_header() don't check the
protocol version, so the inline header path is reachable on HSRv0 too.
The commit message ("This test needs a HSR device and the two slave devices
passed") and the usage text don't say that only HSRv1 is supported.
hsr_ptp.sh keeps the "# HSRv0/1" comment and the HSRv parameter of
setup_hsr_interfaces(), but it only calls:
setup_hsr_interfaces 1
so the v0 inline header path is never tested.
Should the test accept ETH_P_PRP on v0 and loop over both versions like
hsr_ping.sh does? Otherwise, could the HSRv1-only assumption be documented?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-hsr_ptp-v13-0-598326208fc5%40linutronix.de
Technical Details
Message-ID:
<179611533353.3146.6294208363158546982@kernel.org>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374868-linux-kernel-netdev=dewy.ruReferences:
<20261130-hsr_ptp-v13-8-598326208fc5@linutronix.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374868-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v13 8/8] selftests: hsr: Add test for the inline PTP header on HSR Date: Tue, 01 Dec 2026 08:55:33 +0000 Organization: Usenet Network Message-ID: <179611533353.3146.6294208363158546982@kernel.org> References: <20261130-hsr_ptp-v13-8-598326208fc5@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1665989"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:633SePHFp9Biv0eT5lf65qgEKd4= sha256:yWYxD+Vm0vFMV7TCuk+fsMhrngle9Nyx6ysb5BUSQTk= sha1:JqFp68uAa8DZFOUFoTEBph9AhHg= sha256:6K03ZBguKDnldtW5xnNVKkJ0MU6O+tC5TzsGfyCc/ug= 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 C4CCD1172E3; Tue, 1 Dec 2026 11:55:51 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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 xyBImEVwDtqP; Tue, 1 Dec 2026 11:55:48 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-374868-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id EBBBC1172E0; Tue, 1 Dec 2026 11:55:38 +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 37FCC26B04; Tue, 1 Dec 2026 08:55:36 +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=1796115336; b=n1qsHexAhioZ/NPvgjcOrdbM3pHRPPVfiiiiBQ2VQYM5YFG+WGCT9PVKfde+epC5TcWI /NzISjeEscvUCKg2Auhewe6oUKWYWITlldwUUit7Dsdy1mXh0pYoU5nEwkcx9TUrs5nF9 ql5GC/ACVRdM+c3k20lSnT6udty8+BD5xt+cysHgjVNryV6+GebAbEdG7QaTEUttUm67Y JsjVN/L0h18x04t+gkz35/OilHXyKtC4XZmcs42QeHiNQrLuKDnxcK7njsceMPlyWN9cz G8PGxgLjvScrDTkTRRo4O14PSWcXYb9b0P2zxWovA6aMbE5i0INHLF/NZDJwqpgiWYA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796115336; 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=iPH2W7pYI02zxcB37CGpQB2myFfJn9E4Frdj8oBITos=; b=IXCgobWG0/pVjdU0Yaoko4ftDoa0uLaeT/ualclQZnlWRbe92F8bSOrr3Xd7gkpyT4qS /yATSOYQygv0x1540kdAwCr2PIgRMvtWJP6ydoN28XZoTv+ckC24Oijr1HBAgz+anI9Xr 4gnSiGtSKBeo347HOHyIHqLxMItfFVsG/8YZIL3xcOGr/hzAXdocHlsKF6oX2ta+Zep8M PX+HN33zZ7QVKQ2sSzeKqf0aXqrMwi1ak4UB1Re4equVPRvgGei2zAtxkEfLDY9tLTsEC 7FDgP1VrZRUqFwNwjGf/QSKlmOt7fiXvcM6g82MPD0+o+wYP44ZwinNAWb457P1dumA== 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=m5dASfN9; 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 ED834606A325; Tue, 1 Dec 2026 08:55:35 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=m5dASfN9 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=1796115335; b=x7ifmoq12xloW/EWXKh9HG7YnB164xNy7FsfNcu5k/u3naNzNYn4tO0wLbUFuZ4t7/jF aX33TMnySAyOWgEUxShEzVqBs30GKL3qncTHI4VchVSeGN0dpg/EzZF+Y9yRjnrf+fMfV BWrcz00T4B4jh2425Ez3fZEZ6/Sp/Gh2vy66JbKuZt2noHrBGx7TIgzkf2kP7zuO0dinQ Nk0qpNvShE3AKQHBKw/LuvJbyta+hc3bgT455TPwlHLSZFv7DZu5jv7pXueYYEZ6bEsJ3 2X+kiAd1ObNFKGZvnI+WeyyiVBEUkO5448YXoj2xA3GuWg44pDZE1NVhb/6KTW02LSw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796115335; 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=iPH2W7pYI02zxcB37CGpQB2myFfJn9E4Frdj8oBITos=; b=rrMbwb0e/Jxc8hlMcSSUW3bCNNbcr5p0urSxJOl8qvLUA0Cq3hedboJrxouKgxf2rzsF PctRrO6D0ot6FdnvW4FPmD2akiRSuYAXXE/CZKpgWGIQMlX8qRPV01FBG622BAI5clULD e6vo/9fjHE38wUZvQVcO3qX+6V3xu7j9sc0QWHSNmFYuLyn13hXtbnp/oAIgL8p3kp5NH Li3EAJ9Pj9fHT5cXrNVWgsnp4PyK7lzJcKTD8+KlIysxvdchJawb1oFlmON+tGibN7sdS xJJXPUORCkg38YEPDlI5CG5PtnHk5rHfiihazVmiwUAv+eQTqR8xTYy+A6ZTcZ0zLGw== 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=m5dASfN9; 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 19CE9606A32F for <netdev@vger.kernel.org>; Tue, 1 Dec 2026 08:55:35 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDF031F000C1; Tue, 1 Dec 2026 08:55:33 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796115335; bh=iPH2W7pYI02zxcB37CGpQB2myFfJn9E4Frdj8oBITos=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=m5dASfN90LJhvN51g6RKX0szHUc0xG2z++dxLdkK24lg9BuZFT2obtM6PVjRTFy4+ s9y1P35RoD440bLZbhxiLvYaw18c74CNkzk9zjdqomPDwwmeaoQl7gDBRMjqjCai2x ED3tCCReioGpyEHVIdvvdZ9p0Pk3ohlKjPvgrnSiR/ycXCmQ6IFTSWrS8kMycmkjPe V56+w9CRtwuKcG7WHR6xXZ8CKdROhuuUYhkCi85KLD4Umm1mQ8reb+DdUJe5lxoq+0 8a5oKh6N1VV9IakDOVx7a07giUggIQubHx2PqbD3rBPTKAnMtsRO1iq7K88JIpeU4w irKoqqogmoP1Q== X-Cc: netdev@vger.kernel.org, j-rameshbabu@ti.com, andrew+netdev@lunn.ch, danishanwar@ti.com, d-qiu@ti.com, davem@davemloft.net, fmaurer@redhat.com, kuba@kernel.org, neelima@ti.com, pabeni@redhat.com, praneeth@ti.com, pratheesh@ti.com, richardcochran@gmail.com, horms@kernel.org, vigneshr@ti.com, willemdebruijn.kernel@gmail.com, daniel.machon@microchip.com, edumazet@kernel.org X-In-Reply-To: <20261130-hsr_ptp-v13-8-598326208fc5@linutronix.de> 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