From: netdev-bot+sashiko@kernel.org
To: bigeasy@linutronix.de
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
Subject: Re: [PATCH net-next v12 8/8] selftests: hsr: Add test for the inline PTP header on HSR
Date: Thu, 26 Nov 2026 14:40:42 +0000 [thread overview]
Message-ID: <179570404248.3135.7481792168822818977@kernel.org> (raw)
In-Reply-To: <20261125-hsr_ptp-v12-8-9ddd2a73cb90@linutronix.de>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] Two comments in the new test files describe the behaviour
wrongly.
- [Low] selftests: hsr: presetting ns variables to none breaks setup_ns()
in hsr_ptp.sh
--
selftests: hsr: Add test for the inline PTP header on HSR
This adds a selftest that sends PTP frames carrying the HSR inline header
(ETH_P_1588) through an HSR device, with and without a supplied HSR header.
It checks that the inline header is stripped and that the frame appears
only on the requested slave port. When an HSR header was supplied, it also
checks that the sequence number and SRC MAC are kept.
> 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]
This isn't a bug, but is "prepend its own header" accurate here? When
has_hsr_header is set, hsr_forward_do() in net/hsr/hsr_forward.c forwards
the supplied header 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);
...
}
raw_recv() in this file agrees with the kernel rather than with the
comment. It requires the received sequence_nr to equal hsr_seq - 1, and
the SRC MAC (after undoing the 0x21 flip) to match what pkt_send() wrote:
if (fwd_hsr) {
if (hsr_hdr->sequence_nr != htons(hsr_seq - 1)) {
...
hsr_hdr->src[3] ^= 0x21;
if (memcmp(hsr_hdr->src, slave_mac_addr, MAC_LEN)) {
Should the comment say that the supplied HSR header is forwarded as is?
The "# HSRv0/1" comment in setup_hsr_interfaces() in hsr_ptp.sh has a
similar issue:
# HSRv0/1
ip -net "$ns1" link add name hsr1 type hsr slave1 ns1eth1 \
slave2 ns1eth2 supervision 45 version "$HSRv" proto 0
The script only calls "setup_hsr_interfaces 1", and raw_recv() rejects
anything that isn't ETH_P_HSR:
if (hsr_hdr->type != htons(ETH_P_HSR)) {
printf("Error: Unexpected ether type: 0x%x\n", ntohs(hsr_hdr->type));
return -1;
}
With version 0, hsr_fill_tag() (called from hsr_create_tagged_frame())
sets the tag ethertype like this:
hsr_ethhdr->ethhdr.h_proto = htons(proto_version ?
ETH_P_HSR : ETH_P_PRP);
As written, the test binary would fail on HSRv0. Could the v0 reference be
dropped from that comment?
[ ... ]
> diff --git a/tools/testing/selftests/net/hsr/hsr_ptp.sh b/tools/testing/selftests/net/hsr/hsr_ptp.sh
> --- /dev/null
> +++ b/tools/testing/selftests/net/hsr/hsr_ptp.sh
> @@ -0,0 +1,111 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +
> +source ./hsr_common.sh
> +
> +optstring="h"
> +usage() {
> + echo "Usage: $0"
> +}
> +
> +while getopts "$optstring" option;do
> + case "$option" in
> + "h")
> + usage "$0"
> + exit 0
> + ;;
> + "?")
> + usage "$0"
> + exit 1
> + ;;
> +esac
> +done
> +
> +setup_hsr_interfaces()
> +{
> + local HSRv="$1"
> +
> + echo "INFO: Preparing interfaces for HSRv${HSRv}."
> +# Three HSR nodes. Each node has one link to each of its neighbour, two links in total.
> +
> +# ns1eth1 ----- ns2eth1
> +# hsr1 hsr2
> +# ns1eth2 ns2eth2
> +# | |
> +# ns3eth1 ns3eth2
> +# \ /
> +# hsr3
> +#
> + # Interfaces
> + ip link add ns1eth1 netns "$ns1" type veth peer name ns2eth1 netns "$ns2"
> + ip link add ns1eth2 netns "$ns1" type veth peer name ns3eth1 netns "$ns3"
> + ip link add ns3eth2 netns "$ns3" type veth peer name ns2eth2 netns "$ns2"
> +
> + # HSRv0/1
> + ip -net "$ns1" link add name hsr1 type hsr slave1 ns1eth1 \
> + slave2 ns1eth2 supervision 45 version "$HSRv" proto 0
> + ip -net "$ns2" link add name hsr2 type hsr slave1 ns2eth1 \
> + slave2 ns2eth2 supervision 45 version "$HSRv" proto 0
> + ip -net "$ns3" link add name hsr3 type hsr slave1 ns3eth1 \
> + slave2 ns3eth2 supervision 45 version "$HSRv" proto 0
> +
> + # IP for HSR
> + ip -net "$ns1" addr add 100.64.0.1/24 dev hsr1
> + ip -net "$ns1" addr add dead:beef:0::1/64 dev hsr1 nodad
> + ip -net "$ns2" addr add 100.64.0.2/24 dev hsr2
> + ip -net "$ns2" addr add dead:beef:0::2/64 dev hsr2 nodad
> + ip -net "$ns3" addr add 100.64.0.3/24 dev hsr3
> + ip -net "$ns3" addr add dead:beef:0::3/64 dev hsr3 nodad
> +
> + ip -net "$ns1" link set address 00:11:22:00:01:01 dev ns1eth1
> + ip -net "$ns1" link set address 00:11:22:00:01:02 dev ns1eth2
> +
> + ip -net "$ns2" link set address 00:11:22:00:02:01 dev ns2eth1
> + ip -net "$ns2" link set address 00:11:22:00:02:02 dev ns2eth2
> +
> + ip -net "$ns3" link set address 00:11:22:00:03:01 dev ns3eth1
> + ip -net "$ns3" link set address 00:11:22:00:03:02 dev ns3eth2
> +
> + # All Links up
> + ip -net "$ns1" link set ns1eth1 up
> + ip -net "$ns1" link set ns1eth2 up
> + ip -net "$ns1" link set hsr1 up
> +
> + ip -net "$ns2" link set ns2eth1 up
> + ip -net "$ns2" link set ns2eth2 up
> + ip -net "$ns2" link set hsr2 up
> +
> + 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)."
> +
> + ip netns exec "$ns2" ./hsr_ptp_test -H hsr2 -A ns2eth1 -B ns2eth2
> + ret=$?
> + stop_if_error "PTP header test failed (ns2)."
> +
> + ip netns exec "$ns3" ./hsr_ptp_test -H hsr3 -A ns3eth1 -B ns3eth2
> + ret=$?
> + stop_if_error "PTP header test failed (ns3)."
> +}
> +
> +check_prerequisites
> +trap cleanup_all_ns EXIT
> +
> +ns1="none"
> +ns2="none"
> +ns3="none"
> +
> +setup_ns ns1 ns2 ns3
> +setup_hsr_interfaces 1
> +run_ptp_hdr_tests
> +
> +exit $ret
[Severity: Low]
Do these presets stop setup_ns() from working as intended? In
tools/testing/selftests/net/lib.sh, setup_ns() only generates a unique
name such as ns1-XXXXXX when the named variable is empty. If the
variable already holds a value, it calls cleanup_ns() on that value and
then runs ip netns add with the same value.
ns1, ns2 and ns3 all hold "none" here. The first iteration creates a
namespace literally named none. The second and third iterations delete
and recreate that same namespace, and all three variables are left as
"none".
setup_hsr_interfaces() then puts all six veth ends and hsr1, hsr2 and
hsr3, with their overlapping 100.64.0.0/24 and dead:beef::/64 subnets,
into that one namespace. The three node ring drawn in the comment is
never built, and run_ptp_hdr_tests() runs hsr_ptp_test three times in
the same namespace. The test can still pass, but it is no longer
checking the topology it describes.
There are two smaller effects:
- A namespace already called none on the host is deleted.
- NS_LIST ends up holding none three times, so cleanup_all_ns() tries
to remove the same namespace three times on exit.
cleanup_all_ns() only walks NS_LIST, so the presets do not seem to be
needed for the EXIT trap. Can the three assignments simply be dropped,
or set to empty strings, so setup_ns() picks unique names?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125-hsr_ptp-v12-0-9ddd2a73cb90%40linutronix.de
prev parent reply other threads:[~2026-11-26 14:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 14:31 [PATCH net-next v12 0/8] hsr: Allow to send packets on specific port and pass the timestamp Sebastian Andrzej Siewior
2026-11-25 14:31 ` [PATCH net-next v12 1/8] hsr: Add header_ops::parse_protocol Sebastian Andrzej Siewior
2026-11-25 14:31 ` [PATCH net-next v12 2/8] hsr: Use skb_clone() while adding the HSR header Sebastian Andrzej Siewior
2026-11-26 14:40 ` netdev-bot+sashiko
2026-11-25 14:31 ` [PATCH net-next v12 3/8] hsr: Add a magic header for sending PTP packets Sebastian Andrzej Siewior
2026-11-26 14:40 ` netdev-bot+sashiko
2026-11-25 14:31 ` [PATCH net-next v12 4/8] hsr: Drop received " Sebastian Andrzej Siewior
2026-11-26 14:40 ` netdev-bot+sashiko
2026-11-25 14:31 ` [PATCH net-next v12 5/8] hsr: Use the port and header information in hsr_forward_skb() Sebastian Andrzej Siewior
2026-11-26 14:40 ` netdev-bot+sashiko
2026-11-25 14:31 ` [PATCH net-next v12 6/8] hsr: Assign a socket for cloned skbs Sebastian Andrzej Siewior
2026-11-26 14:40 ` netdev-bot+sashiko
2026-11-25 14:31 ` [PATCH net-next v12 7/8] hsr: Move struct hsr_ethhdr to a global header Sebastian Andrzej Siewior
2026-11-25 14:31 ` [PATCH net-next v12 8/8] selftests: hsr: Add test for the inline PTP header on HSR Sebastian Andrzej Siewior
2026-11-26 14:40 ` netdev-bot+sashiko [this message]
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=179570404248.3135.7481792168822818977@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=bigeasy@linutronix.de \
--cc=d-qiu@ti.com \
--cc=daniel.machon@microchip.com \
--cc=danishanwar@ti.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=fmaurer@redhat.com \
--cc=horms@kernel.org \
--cc=j-rameshbabu@ti.com \
--cc=kuba@kernel.org \
--cc=neelima@ti.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=praneeth@ti.com \
--cc=pratheesh@ti.com \
--cc=richardcochran@gmail.com \
--cc=vigneshr@ti.com \
--cc=willemdebruijn.kernel@gmail.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