On 2026-12-01 08:55:33 [+0000], netd…@kernel.org wrote:
> Critical: 0 · High: 0 · Medium: 1 · Low: 2
…
> [ ... ]
>
> > + 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?
The other scripts do wait but not for the link to get up but for "HSR
supervision" frames to get exchanged and the nodes on both sides are
known/ "merged". This avoids duplicate frames.
In the PTP case, the duplication is skipped and sending is done a
specific interface.
On the other hand this can only happen once the link is up. I'm unsure
if this wait/ sleep is really needed.
Sebastian