net: hsr: fix super-packet forwarding
Subsystems (6)
v8 cover net: hsr: fix super-packet forwarding
HSR/PRP requires per-wire-frame tags/RCTs and sequence numbers, and duplicate discard is per frame. RX GRO and TX GSO can present multiple frames as one skb and violate that assumption: a super-skb is either rejected by a constrained lower device, or forwarded without valid per-frame trailers and sequence numbers. An oversized PRP aggregate can also truncate the RCT's 12-bit LSDU size field.
Patch 1 keeps software GRO off while devices are direct HSR/PRP members, in the requested as well as in the active features. Fixed-on or driver-required GRO_HW may remain enabled.
Patch 2 refuses bridge, bond, team, OVS, macvlan and MACsec devices, and devices without an RX handler such as ipvlan and VRF, as HSR/PRP ports. This closes the syzbot report of recursive seqnr_lock locking through a bridge whose port is a second HSR master. seqnr_lock stays as it is.
Patch 3 segments valid GSO before per-frame processing, so each wire frame gets its own tag/RCT and sequence number; segmentation runs outside seqnr_lock. Patch 4 tests member GRO policy, port refusal, GSO forwarding and local submission order.
A typical GSO source is a container connected to a PRP RedBox interlink through veth. An existing TCP/UDP GSO skb can reach the interlink with GRO disabled:
container/netns host PRP RedBox
prp0-peer ---- veth ---- prp0-int (interlink RX)
|
split GSO into frames
|
sequence number + RCT
/ \
LAN A LAN BCompatibility with older PRP senders:
Valid PRP frames from older senders remain supported. Some old Linux PRP senders incorrectly append one RCT to an entire GSO skb. This violates the per-frame PRP requirement. Patch 3 drops such intact aggregates when trailing bytes extend past a known, nonzero IP length; zero lengths and GSO_PARTIAL are not covered by that check.
On virtio-net/TAP paths, disabling GRO_HW in patch 1 can make the host segment an old sender's malformed aggregate before it reaches the receiving VM. The RCT then becomes transport payload, which the receiver cannot reliably identify or remove. Upgrade the sender or disable GSO/TSO on its HSR/PRP master.
Validation:
On a lockdep kernel with the series, the GRO selftest passed 15/15 and the ordered selftest 5/5. The syzbot reproducer reports recursive locking on the base kernel and nothing on the series in five minutes. It needed one adjusted ifindex, because the caif device it counts on no longer exists. Down/up of an attached veth and detach of a veth attached while down hang or hit BUG_ON with v7 and pass with this series.
W=1 allmodconfig and allyesconfig builds show no new warnings against the base.
Based on net fafbc4051123 (2026-11-05). The series applies without conflicts to net 30c71476d842 and net-next fa5196392691, where net/hsr is identical. The net-next conflicts reported for v7 came from the sequence-number changes in v7's patch 2, which this version drops.
No stable backport is requested here. The remaining HSR dev->stats races are left to a separate series, as Paolo suggested [1]. Pre-existing shared-skb mutations are also handled separately.
[1] https://lore.kernel.org/netdev/[email protected]/
Changes since v7:
- Patch 1: also clear GRO and configurable GRO_HW from wanted_features. veth adds and deletes its NAPI instances according to the request, so the v7 split between requested and active GRO could hang "ip link set down" or hit the BUG_ON() in napi_enable() (the critical NIPA finding on patch 1). GRO is no longer restored when a port leaves, as for LRO; the comments only claim GRO off for direct members.
- Patch 2: replace the ordered forwarding consumer with a check of the port type, as Sebastian suggested [2]; seqnr_lock is unchanged. The rule is by device type rather than "no lower devices" as I wrote in the thread, because DSA user ports are uppers of their conduit. Dropping the consumer also drops the review points on its admission limit, supervision budget and PREEMPT_RT behavior. Narrowing seqnr_lock is left to a separate net-next change, where Hangbin's patch fits [3]. Ports whose RX handler is in use or not supported are refused before any state change too, so a refused device keeps its GRO request.
- Patch 3: segment before taking seqnr_lock and number each segment under it; the lock moves from the callers into the per-frame helper. A still-shared GSO input is unshared before segmentation. New gate drops are counted once on the entry device.
- Patch 4: the GRO checks follow the new policy, including the requested state. New cases cover down/up while attached, attach while down then up and detach, a request while attached, and port refusal. From the NIPA review: CONFIG_MACVLAN and CONFIG_BONDING in config, captures scoped to their case, read-back instead of ethtool output matching, PRP trailers decoded only on PRP LANs with the kernel's fallback, capture sockets bound before they receive, producer errors not hidden by the barrier, INT/TERM blocked while namespaces or handlers switch, completion on the expected frames rather than a quiet period, and only the common prefix compared where supervision runs through the lane cutoff. Unused code is removed. The helper stays standalone instead of using net/lib/py, which has no in-process, namespace-bound AF_PACKET capture or stop-after-failure TAP handling. The remaining low-severity remarks are addressed or went away with the consumer.
[2] https://lore.kernel.org/netdev/[email protected]/
[3] https://lore.kernel.org/netdev/[email protected]/
Previous postings (earlier design, newest first):
v7: https://lore.kernel.org/netdev/[email protected]/
v6: https://lore.kernel.org/netdev/[email protected]/
v5: https://lore.kernel.org/netdev/[email protected]/
v4: https://lore.kernel.org/netdev/[email protected]/
v3: https://lore.kernel.org/netdev/[email protected]/
v2: https://lore.kernel.org/netdev/[email protected]/
v1: https://lore.kernel.org/netdev/[email protected]/
Xin Xie (4):
net: hsr: keep GRO disabled on HSR/PRP ports
net: hsr: refuse forwarding devices as HSR/PRP ports
net: hsr: segment GSO before per-frame forwarding
selftests: net: hsr: verify GRO policy and ordered forwarding
.../networking/net_cachelines/net_device.rst | 1 + include/linux/netdevice.h | 7 + net/core/dev.c | 15 + net/hsr/hsr_device.c | 6 +- net/hsr/hsr_forward.c | 154 ++ net/hsr/hsr_forward.h | 1 + net/hsr/hsr_slave.c | 94 +- tools/testing/selftests/net/hsr/Makefile | 7 +- tools/testing/selftests/net/hsr/config | 4 + .../selftests/net/hsr/hsr_gro_superpacket.py | 1376 +++++++++++++++++ .../selftests/net/hsr/hsr_gro_superpacket.sh | 9 + .../net/hsr/hsr_ordered_forwarding.sh | 9 + 12 files changed, 1668 insertions(+), 15 deletions(-) create mode 100755 tools/testing/selftests/net/hsr/hsr_gro_superpacket.py create mode 100755 tools/testing/selftests/net/hsr/hsr_gro_superpacket.sh create mode 100755 tools/testing/selftests/net/hsr/hsr_ordered_forwarding.sh
base-commit: fafbc4051123d5459ea6950899cec08ed946e278
Signature · 1 line
2.53.0
PATCH v8 1/4 net: hsr: keep GRO disabled on HSR/PRP ports
HSR and PRP tag and de-duplicate each wire frame separately. GRO on a member device merges several frames into one skb that cannot get valid per-frame metadata, and userspace can turn GRO back on at any time.
Mark direct members (slave A/B, interlink) with a kernel role bit. While it is set, __netdev_update_features() drops software GRO and configurable GRO_HW from wanted_features as well as from the computed features, before ndo_fix_features(). GRO_HW that the driver keeps on is left alone. The request has to go too: veth adds and deletes its NAPI instances according to wanted_features, so with GRO still requested, closing an attached veth spins in napi_disable(), and detaching a veth that was attached while down and then brought up hits the BUG_ON() in napi_enable(). As for LRO disabled by an upper device, GRO is not restored when the port leaves; ethtool can turn it back on.
The attach fails if software GRO stays active. A failed attach does not restore the GRO request either; the next patch refuses the usual causes before any state is changed. GSO skbs can still arrive, for example from a stacked member whose lower device runs GRO; a later patch segments them.
--- .../networking/net_cachelines/net_device.rst | 1 + include/linux/netdevice.h | 7 +++ net/core/dev.c | 15 ++++++ net/hsr/hsr_slave.c | 52 +++++++++++++++++++ 4 files changed, 75 insertions(+)
Documentation/networking/net_cachelines/net_device.rst +1 -0
@@ -169,6 +169,7 @@ unsigned_long:1 see_all_hwtstamp_requests unsigned_long:1 change_proto_down unsigned_long:1 netns_immutable unsigned_long:1 fcoe_mtu +unsigned_long:1 hsr_port struct list_head net_notifier_list struct macsec_ops* macsec_ops struct udp_tunnel_nic_info* udp_tunnel_nic_info
include/linux/netdevice.h +7 -0
@@ -2110,6 +2110,7 @@ enum netdev_reg_state {* @change_proto_down: device supports setting carrier via IFLA_PROTO_DOWN * @netns_immutable: interface can't change network namespaces * @fcoe_mtu: device supports maximum FCoE MTU, 2158 bytes +* @hsr_port: direct HSR/PRP member (slave A/B or interlink) * * @net_notifier_list: List of per-net netdev notifier block * that follow this device when it is moved
@@ -2531,6 +2532,12 @@ struct net_device { unsigned long change_proto_down:1; unsigned long netns_immutable:1; unsigned long fcoe_mtu:1; +/* Direct HSR/PRP member: slave A/B or interlink. While set, +* software GRO and configurable GRO_HW are dropped, requested and +* active; GRO_HW that the driver keeps on is left alone. Kernel +* role state only; no user ABI or offload capability. +*/ + unsigned long hsr_port:1;struct list_head net_notifier_list;
net/core/dev.c +15 -0
@@ -11269,6 +11269,21 @@ int __netdev_update_features(struct net_device *dev) features =netdev_get_wanted_features (dev); +/* A direct HSR/PRP port needs per-frame metadata. Drop software +* GRO and configurable GRO_HW from the request as well as from the +* result, as the core does for upper-disabled features: drivers +* such as veth derive state from wanted_features and need the +* requested and the active bit to agree. Fixed-on or +* driver-required GRO_HW is left to the driver. +*/ +if (dev->hsr_port) { +netdev_features_t gro =NETIF_F_GRO | + (dev->hw_features &NETIF_F_GRO_HW ); + + dev->wanted_features &= ~gro; + features &= ~gro; + } +if (dev->netdev_ops->ndo_fix_features) features = dev->netdev_ops->ndo_fix_features (dev, features);
net/hsr/hsr_slave.c +52 -0
83 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH net v8 1/4] net: hsr: keep GRO disabled on HSR/PRP ports
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 0
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_portdev_setup() (net/hsr/hsr_slave.c:210) calls hsr_portdev_role_set() on every non-master port without checking…
- [Medium] hsr_portdev_role_set() calls netdev_change_features() with dev->hsr_port set.
--
net: hsr: keep GRO disabled on HSR/PRP ports
This patch adds an hsr_port role bit to struct net_device. The bit is set on HSR/PRP slave A/B and interlink ports. While it is set, __netdev_update_features() drops software GRO and configurable GRO_HW from both wanted_features and the computed features, and the attach fails if software GRO stays active.
Quoted 30 lines
net/core/dev.c +15
-0@@ -11269,6 +11269,21 @@ int __netdev_update_features(struct net_device *dev) features =netdev_get_wanted_features (dev); +/* A direct HSR/PRP port needs per-frame metadata. Drop software +* GRO and configurable GRO_HW from the request as well as from the +* result, as the core does for upper-disabled features: drivers +* such as veth derive state from wanted_features and need the +* requested and the active bit to agree. Fixed-on or +* driver-required GRO_HW is left to the driver. +*/ +if (dev->hsr_port) { +netdev_features_t gro =NETIF_F_GRO | + (dev->hw_features &NETIF_F_GRO_HW ); + + dev->wanted_features &= ~gro; + features &= ~gro; + } +if (dev->netdev_ops->ndo_fix_features) features = dev->netdev_ops->ndo_fix_features (dev, features);net/hsr/hsr_slave.c +0
-0
[ ... ]
Quoted 13 lines
net/hsr/hsr_slave.c +13
-0+static void hsr_portdev_role_clear (struct net_device *dev) +{ +netdev_lock_ops (dev); + dev->hsr_port = false; +/* Recompute features without the role. GRO was dropped from +* the request while the role was set and stays off; the user +* can turn it back on with ethtool. A dying device just drops +* the role, a netns move stays registered and is recomputed. +*/ +if (dev->reg_state ==NETREG_REGISTERED ) +netdev_change_features (dev); +netdev_unlock_ops (dev); +}
[ ... ]
Quoted 4 lines
net/hsr/hsr_slave.c +0
-0@@ -169,6 +199,22 @@ static int hsr_portdev_setup(struct hsr_priv *hsr, struct net_device *dev,if (res) goto fail_upper_dev_link;
net/hsr/hsr_slave.c static int hsr_portdev_setup(struct hsr_priv *hsr, struct net_device *dev, · line 211
Quoted 10 lines
net/hsr/hsr_slave.c +10
-0+/* Enable the member role and recompute before the RX handler +* is published, so that software GRO on this device is off +* before frames can arrive. This covers the direct member +* only: a stacked member receives from a lower device that +* may still run GRO and can deliver merged frames as GSO skbs. +* A still-active software GRO rejects the port, a remaining +* GRO_HW alone does not. +*/ +hsr_portdev_role_set (dev); +if (dev->features &NETIF_F_GRO ) {
[Severity: Medium]
The role is set here for every non-master port. Nothing checks prot_version, port->type or hsr->fwd_offloaded first. Is GRO actually a problem on all of these ports?
On PRP slave A/B, frames that carry an RCT trailer do not appear to be merged. inet_gro_receive() flushes when the IP tot_len does not match skb_gro_len():
net/ipv4/af_inet.c:inet_gro_receive() {
...
flush = (u16)((ntohl(*(__be32 *)iph) ^ skb_gro_len(skb)) | (ntohl(*(__be32 *)&iph->id) & ~IP_DF));
...
}prp_is_lan_dup() also drops A/B forwarding. Untagged LAN traffic goes to the master or interlink untagged, the same way a bridge forwards GRO skbs.
Some slaves have HW forwarding offload (NETIF_F_HW_HSR_FWD, for example icssg, ksz9477 and xrs700x). For those, hsr_drop_frame() does:
net/hsr/hsr_forward.c:hsr_drop_frame() {
if (port->dev->features & NETIF_F_HW_HSR_FWD)
return prp_is_lan_dup(frame->port_rcv->type, port);
...
}so merged skbs are never re-tagged towards the other slave.
There is also no GRO offload for ETH_P_HSR or ETH_P_PRP. Outside net/hsr, the only references are in flow_dissector, so tagged frames cannot be merged. The per-frame metadata problem seems to exist only where untagged frames get tagged: the interlink, and SAN frames forwarded between non-offloaded HSR slaves.
Because wanted_features is cleared and not restored when the port leaves, PRP ports and HW-offloaded ports lose software GRO for good. Host-bound receive then costs more CPU and gets less throughput. The commit message does not mention this cost. The Fixes: tag would also bring this behaviour change into stable kernels.
Could the role be limited to the ports where GRO actually breaks per-frame tagging?
Quoted 10 lines
net/hsr/hsr_slave.c +6
-0+NL_SET_ERR_MSG_MOD (extack, +"software GRO still on after feature update, cannot join" ); + res = -EBUSY ; + goto fail_role_policy; + } + res =netdev_rx_handler_register (dev, hsr_handle_frame, port);if (res) goto fail_rx_handler;
net/hsr/hsr_slave.c static int hsr_portdev_setup(struct hsr_priv *hsr, struct net_device *dev, · line 231
Quoted 9 lines
net/hsr/hsr_slave.c +5
-0@@ -177,7 +223,12 @@ static int hsr_portdev_setup(struct hsr_priv *hsr, struct net_device *dev,return 0 ; fail_rx_handler: +fail_role_policy: +/* Rollback order: unlink the upper, clear the role and +* recompute, then undo this setup's promiscuous increment. +*/ netdev_upper_dev_unlink (dev, hsr_dev); +hsr_portdev_role_clear (dev);
[Severity: Medium]
Can a failed attach leave GRO disabled on a device that never became an HSR member?
hsr_portdev_role_set() leads to __netdev_update_features(), which clears NETIF_F_GRO (and configurable GRO_HW) from dev->wanted_features. This happens before the attach is known to succeed. The previous request is not saved anywhere. hsr_portdev_role_clear() only recomputes from the reduced wanted_features.
This rollback undoes the upper link, the role bit and promiscuity, but not the GRO request. The -EBUSY check above can fire, for example, when ndo_set_features() fails. In that case __netdev_update_features() returns early with dev->features unchanged, but wanted_features has already been cleared.
A second path goes through hsr_del_port(). hsr_dev_finalize() attaches the ports one at a time:
net/hsr/hsr_device.c:hsr_dev_finalize() {
...
res = hsr_add_port(hsr, slave[0], HSR_PT_SLAVE_A, extack);
if (res)
goto err_unregister;
res = hsr_add_port(hsr, slave[1], HSR_PT_SLAVE_B, extack);
if (res)
goto err_unregister;
...
}Slave B or the interlink can fail, for example in hsr_check_dev_ok() or in the new -EBUSY check. Then err_unregister runs hsr_del_ports()->hsr_del_port()->hsr_portdev_role_clear() on slave A, which had attached successfully, and slave A keeps GRO disabled. For example:
ip link add hsr0 type hsr slave1 eth0 slave2 lo
fails, but GRO stays off on eth0.
The commit message says:
A failed attach does not restore the GRO request either; the next patch refuses the usual causes before any state is changed.
The next patch, "net: hsr: refuse forwarding devices as HSR/PRP ports", only adds checks to hsr_check_dev_ok() for the port being attached. Wouldn't that still leave out ports attached earlier in hsr_dev_finalize(), and ndo_set_features() failures?
A stable backport selected through the Fixes: tag could also take this patch without the follow-up.
Quoted 3 lines
net/hsr/hsr_slave.c +0
-0fail_upper_dev_link:if (!port->hsr->fwd_offloaded || port->type ==HSR_PT_INTERLINK )dev_set_promiscuity (dev,-1 );
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261107220544.20-1-xiexinet%40gmail.com
PATCH v8 2/4 net: hsr: refuse forwarding devices as HSR/PRP ports
In reply to Xin Xiesyzbot reported recursive locking with an HSR device whose slave is a bridge, and that bridge has the master of a second HSR device as a port. The first device transmits its supervision frames with its seqnr_lock held; the bridge floods them to the second HSR master, whose hsr_dev_xmit() takes the seqnr_lock of that device:
WARNING: possible recursive locking detected
...
hsr_dev_xmit+0x18a/0x210 net/hsr/hsr_device.c:234 ... br_dev_xmit+0x1202/0x1b40 ... hsr_forward_skb+0x171c/0x2ac0 net/hsr/hsr_forward.c:728 send_hsr_supervision_frame+0x63b/0xcc0 net/hsr/hsr_device.c:351 hsr_announce+0x1f8/0x3a0 net/hsr/hsr_device.c:408
Interlink RX forwards to the slaves with the same lock held. A chain of two devices does not deadlock, but such a port makes no sense: an HSR ring and the two PRP LANs are attached to the node directly.
Refuse bridge and OVS masters, bond and team masters (also without ports, since ports can be added later), and macvlan and MACsec devices as slave or interlink. The rule is by device type, not by the presence of lower devices, because a DSA user port is an upper of its conduit and can offload HSR. VLAN devices are already refused. A tunnel device whose route leads back through the HSR master, or a software device without an identifying flag such as batman-adv, is not covered.
Also refuse, before any state is changed, a device whose RX handler is in use or not supported (IFF_NO_RX_HANDLER: ipvlan, VRF), with an extack message and the same error codes. Some of them, such as a macvlan lower, ipvlan or VRF, used to fail only in netdev_rx_handler_register(), after the previous patch had dropped their GRO request; a refused device now keeps its state.
A bridge can no longer be used directly as the interlink; connect it through a veth pair.
--- net/hsr/hsr_slave.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
net/hsr/hsr_slave.c +28 -2
@@ -120,6 +120,22 @@ static int hsr_check_dev_ok(struct net_device *dev,return -EINVAL ; } +/* The RX handler is taken by devices such as bridge/bond/team +* ports, macvlan and ipvlan lowers and HSR ports, or unsupported +* (IFF_NO_RX_HANDLER). Refuse before any state change, so a +* failed attach leaves the device as it was. +*/ +if (dev->priv_flags &IFF_NO_RX_HANDLER ) { +NL_SET_ERR_MSG_MOD (extack, +"This device does not support an RX handler." ); +return -EINVAL ; + } +if (netdev_is_rx_handler_busy (dev)) { +NL_SET_ERR_MSG_MOD (extack, +"RX handler busy: device is already a lower of another device." ); +return -EBUSY ; + } +if (is_vlan_dev (dev)) {NL_SET_ERR_MSG_MOD (extack,"HSR on top of VLAN is not yet supported in this driver." );return -EINVAL ;
@@ -131,9 +147,19 @@ static int hsr_check_dev_ok(struct net_device *dev,return -EOPNOTSUPP ; } -/* HSR over bonded devices has not been tested, but I'm not sure it -* won't work... +/* Forwarding devices feed HSR frames into another device's +* transmit path. A bridge, bond, team or OVS master or a macvlan +* or MACsec device makes no sense as a ring or LAN port and can +* nest seqnr_lock through a second HSR device. Refuse them by +* type: devices with lower devices in general stay valid, DSA +* user ports are uppers of their conduit. */ +if (netif_is_any_bridge_master (dev) ||netif_is_lag_master (dev) || +netif_is_macvlan (dev) ||netif_is_macsec (dev)) { +NL_SET_ERR_MSG_MOD (extack, +"Cannot use a bridge, bond, team, OVS, macvlan or MACsec device as HSR port." ); +return -EINVAL ; + }return 0 ; }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH net v8 2/4] net: hsr: refuse forwarding devices as HSR/PRP ports
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Critical: 0 · High: 1 · Medium: 1 · Low: 0
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).
- [High] The fix does not close the bug class it targets.
- [Medium] hsr_check_dev_ok() now refuses every macvlan and MACsec device as an HSR/PRP slave or interlink with -EINVAL, whatever its lower…
--
net: hsr: refuse forwarding devices as HSR/PRP ports
This patch makes hsr_check_dev_ok() refuse bridge, OVS, bond, team, macvlan and MACsec devices as an HSR/PRP slave or interlink. It also refuses devices with IFF_NO_RX_HANDLER or a busy RX handler before any state is changed. The target is a syzbot recursive locking report: a supervision frame sent with seqnr_lock held goes to a bridge slave, which floods it into a second HSR master.
Quoted 4 lines
net/hsr/hsr_slave.c +0
-0
[ ... ]
Quoted 9 lines
net/hsr/hsr_slave.c +3
-2@@ -131,9 +147,19 @@ static int hsr_check_dev_ok(struct net_device *dev,return -EOPNOTSUPP ; } -/* HSR over bonded devices has not been tested, but I'm not sure it -* won't work... +/* Forwarding devices feed HSR frames into another device's +* transmit path. A bridge, bond, team or OVS master or a macvlan +* or MACsec device makes no sense as a ring or LAN port and can
net/hsr/hsr_slave.c static int hsr_check_dev_ok(struct net_device *dev, · line 162
Quoted 10 lines
net/hsr/hsr_slave.c +9
-0+* nest seqnr_lock through a second HSR device. Refuse them by +* type: devices with lower devices in general stay valid, DSA +* user ports are uppers of their conduit. */ +if (netif_is_any_bridge_master (dev) ||netif_is_lag_master (dev) || +netif_is_macvlan (dev) ||netif_is_macsec (dev)) { +NL_SET_ERR_MSG_MOD (extack, +"Cannot use a bridge, bond, team, OVS, macvlan or MACsec device as HSR port." ); +return -EINVAL ; + }
[Severity: High]
Does this type check close the seqnr_lock nesting, or only the bridge reproducer from syzbot?
The lock is still held across the whole transmit path of the port. For example, in hsr_dev_xmit():
net/hsr/hsr_device.c:hsr_dev_xmit() {
...
spin_lock_bh(&hsr->seqnr_lock);
hsr_forward_skb(skb, master);
spin_unlock_bh(&hsr->seqnr_lock);
...
}send_hsr_supervision_frame(), send_prp_supervision_frame() and the interlink branch of hsr_handle_frame() follow the same pattern. The call hsr_forward_skb()->hsr_xmit()->dev_queue_xmit(port) runs the port's tc, BPF and ndo_start_xmit with the lock held.
spin_lock_init() is only called from hsr_dev_finalize(), so all HSR instances share one lockdep class.
Any ARPHRD_ETHER port that passes these checks but whose egress reaches an HSR master synchronously seems to hit the same splat:
- A plain veth or NIC slave with a clsact egress filter doing "mirred egress redirect dev hsr1". In that case tcf_mirred_act()->tcf_mirred_forward() calls dev_queue_xmit(hsr1). The mirred loop check only compares against devices already in sched_mirred_dev[], so it does not catch the first redirect. bpf_redirect() from tcx or cls_bpf behaves the same way.
- A virt_wifi device created on top of an HSR master. virt_wifi_newlink() accepts any lower device, and the virt_wifi device is set up with ether_setup() and none of the refused priv_flags. virt_wifi_start_xmit() then does:
skb->dev = priv->lowerdev; return dev_queue_xmit(skb);
- Ethernet tunnels whose underlay routes through an HSR master. The commit message already mentions these.
Suppose the redirect targets the same HSR master: veth0 is a slave of hsr0, and veth0's egress filter redirects to hsr0. Can this deadlock the CPU?
hsr_announce() timer
spin_lock_bh(&hsr0->seqnr_lock) hsr_forward_skb()->hsr_xmit()->dev_queue_xmit(veth0)
sch_handle_egress()->tcf_mirred_act()->tcf_mirred_forward()
dev_queue_xmit(hsr0)
hsr_dev_xmit()
spin_lock_bh(&hsr0->seqnr_lock)hsr0 is lltx and IFF_NO_QUEUE, so __dev_queue_xmit() calls ndo_start_xmit directly. Neither the dev_xmit_recursion() limit nor MIRRED_NEST_LIMIT is reached before the second spin_lock_bh(), so the CPU spins on a lock it already holds, with BH disabled. Setting this up only needs CAP_NET_ADMIN, which a user namespace provides.
The commit message says:
A chain of two devices does not deadlock, but such a port makes no sense
It lists only tunnels and batman-adv as not covered. Should it also mention tc/BPF redirects, virt_wifi and the single-device self-deadlock?
The later commit "net: hsr: segment GSO before per-frame forwarding" moves the lock into hsr_forward_frame(). It still holds the lock around hsr_forward_skb(), and so around dev_queue_xmit(), so the problem appears to remain at the end of the series.
Would it be better to change the locking itself? For example, the sequence number could be assigned under seqnr_lock and the frame sent after dropping the lock. At minimum, each instance could get its own lockdep key. Either would replace this denylist rather than extend it, so the Closes: tag for the syzbot report looks premature.
[Severity: Medium]
Is it intended to refuse every macvlan and MACsec device here, whatever its lower device is?
Before this patch both types were accepted as a slave or interlink. Both are ARPHRD_ETHER with ETH_ALEN, neither sets IFF_DONT_BRIDGE or IFF_NO_RX_HANDLER, and their RX handler is on the lower device.
The commit message justifies the type rule with "ports can be added later", but that only applies to bridge, bond and team masters. A macvlan's lower and a MACsec real_dev are fixed when the device is created. After that, macvlan_port or macsec holds the lower's RX handler, so the lower cannot join a bridge or bond later either.
Could a single walk of the lower chain at attach time close the nesting path through these two types, refusing an HSR master or a bridge/LAG master found there? Configurations that cannot nest seqnr_lock would then keep working. Examples are PRP LANs or HSR links over MACsec-protected physical links, and PRP ports on macvlan in containers.
Because of the Fixes: tags, stable kernels would start rejecting these previously valid rtnetlink requests with -EINVAL, for example "ip link add ... type hsr slave1 macsec0 ...". Should the commit message say that these configurations are no longer allowed?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261107220544.20-1-xiexinet%40gmail.com
Re: [PATCH net v8 2/4] net: hsr: refuse forwarding devices as HSR/PRP ports
The point about cloned data is right: skb_share_check() only handles a shared skb, but when packet_rcv() or a tc mirror holds a clone, the TCP/UDP GSO handlers on the RX path still write the checksum into the shared head. v9 will make the head private with skb_cow_head(skb, 0) before __skb_gso_segment().
I will check the TX GSO cost on HW tag-insertion offloads and mention aggregates from older HSR senders as well as older PRP senders in the v9 message.
v8 also conflicts with Sebastian's pending "hsr: inline PTP header" v10 in net-next; v9 will describe how the two combine.
Signature · 3 lines
Xin pw-bot: cr
PATCH v8 3/4 net: hsr: segment GSO before per-frame forwarding
In reply to Xin XieHSR and PRP tag and de-duplicate each wire frame separately. A GSO super-packet reaching the forwarding path hides several wire frames, which cannot be tagged or numbered per frame. Such skbs reach a member even with GRO off, for example from a container or VM attached through veth, tap or virtio to a software RedBox, or from a member whose GRO_HW cannot be turned off.
Add one forwarding entry, hsr_forward_input(), for master TX and for frames received on any port. It segments GSO input outside seqnr_lock; each segment is then numbered and submitted under the lock, one frame at a time as before, and follows the normal forwarding and local delivery paths. Master TX and interlink RX now take the lock there instead of in their callers.
Classify by the effective inner protocol with the core's bounded VLAN decoder (802.1Q, 802.1AD, nested or accelerated). Drop aggregates with inner HSR/PRP, unreadable fragments or undecodable headers, and IPv4 or IPv6 aggregates whose nonzero IP length ends before the skb does, since the trailing bytes would become segment payload. GSO_PARTIAL and zero IP lengths are left to the segmenter. Drops are counted once on the entry device in the core per-CPU drop counters. Segmentation writes the control block and headers, so a still-shared input is unshared first.
Older PRP senders can append one RCT to a whole GSO skb. Such aggregates, including locally destined ones, are now dropped instead of being delivered.
Remove the NETIF_F_GSO_MASK types from the master's hw_features so the core segments local traffic before ndo_start_xmit().
--- net/hsr/hsr_device.c | 6 +- net/hsr/hsr_forward.c | 154 ++++++++++++++++++++++++++++++++++++++++++ net/hsr/hsr_forward.h | 1 + net/hsr/hsr_slave.c | 12 ++-- 4 files changed, 161 insertions(+), 12 deletions(-)
net/hsr/hsr_device.c +2 -4
@@ -232,9 +232,7 @@ static netdev_tx_t hsr_dev_xmit(struct sk_buff *skb, struct net_device *dev) skb->dev = master->dev;skb_reset_mac_header (skb);skb_reset_mac_len (skb); -spin_lock_bh (&hsr->seqnr_lock); -hsr_forward_skb (skb, master); -spin_unlock_bh (&hsr->seqnr_lock); +hsr_forward_input (skb, master); }else {dev_core_stats_tx_dropped_inc (dev);dev_kfree_skb_any (skb);
@@ -686,7 +684,7 @@ void hsr_dev_setup(struct net_device *dev) dev->needs_free_netdev = true; dev->hw_features =NETIF_F_SG |NETIF_F_FRAGLIST |NETIF_F_HIGHDMA | -NETIF_F_GSO_MASK |NETIF_F_HW_CSUM | +NETIF_F_HW_CSUM |NETIF_F_HW_VLAN_CTAG_TX |NETIF_F_HW_VLAN_CTAG_FILTER ;
net/hsr/hsr_forward.c +154 -0
163 lines not on this page · raw message
net/hsr/hsr_forward.h +1 -0
@@ -14,6 +14,7 @@#include "hsr_main.h" void hsr_forward_skb (struct sk_buff *skb,struct hsr_port *port); +void hsr_forward_input (struct sk_buff *skb,struct hsr_port *port);struct sk_buff *prp_create_tagged_frame (struct hsr_frame_info *frame,struct hsr_port *port); struct sk_buff *hsr_create_tagged_frame(struct hsr_frame_info *frame,
net/hsr/hsr_slave.c +4 -8
@@ -75,15 +75,11 @@ static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb)skb_reset_mac_len (skb);/* Only the frames received over the interlink port will assign a -* sequence number and require synchronisation vs other sender. +* sequence number and require synchronisation vs other sender; +* hsr_forward_input() takes seqnr_lock for them, one frame at a +* time. */ -if (port->type ==HSR_PT_INTERLINK ) { -spin_lock_bh (&hsr->seqnr_lock); -hsr_forward_skb (skb, port); -spin_unlock_bh (&hsr->seqnr_lock); - }else { -hsr_forward_skb (skb, port); - } +hsr_forward_input (skb, port); finish_consume:return RX_HANDLER_CONSUMED ;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH net v8 3/4] net: hsr: segment GSO before per-frame forwarding
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · 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] Setups with HSR offload now lose GSO on TX, and the commit message does not mention it.
- [Medium] hsr_forward_input() protects software segmentation only with skb_share_check(), which handles skb_shared() (users > 1) by cloning.
- [Low] hsr_forward_input() now drops every GSO skb whose effective protocol is ETH_P_HSR or ETH_P_PRP (net/hsr/hsr_forward.c:916-917),…
--
net: hsr: segment GSO before per-frame forwarding
This patch adds hsr_forward_input() as the single forwarding entry point for master TX and slave RX. It segments GSO skbs in software before the per-frame HSR/PRP tagging and sequence numbering, and drops aggregates with inner HSR/PRP, unreadable frags or trailing data. It also removes NETIF_F_GSO_MASK from the master's hw_features.
Quoted 4 lines
net/hsr/hsr_device.c +0
-0
[ ... ]
net/hsr/hsr_device.c void hsr_dev_setup(struct net_device *dev) · line 689
Quoted 8 lines
net/hsr/hsr_device.c +1
-1@@ -686,7 +684,7 @@ void hsr_dev_setup(struct net_device *dev) dev->needs_free_netdev = true; dev->hw_features =NETIF_F_SG |NETIF_F_FRAGLIST |NETIF_F_HIGHDMA | -NETIF_F_GSO_MASK |NETIF_F_HW_CSUM | +NETIF_F_HW_CSUM |NETIF_F_HW_VLAN_CTAG_TX |NETIF_F_HW_VLAN_CTAG_FILTER ;
[Severity: Medium]
Does removing NETIF_F_GSO_MASK here cause a TX performance regression on lowers with HSR tag insertion offload, such as xrs700x or icssg?
Before this patch the master kept TSO even when the lowers had none. The master port is in hsr->ports, so hsr_features_recompute() folds in the master's own features:
net/hsr/hsr_device.c:hsr_features_recompute() {
...
features &= ~NETIF_F_ONE_FOR_ALL;
hsr_for_each_port_rtnl(hsr, port)
features = netdev_increment_features(features,
port->dev->features,
mask);
...
}On NETIF_F_HW_HSR_TAG_INS lowers, the aggregate was passed on unchanged:
net/hsr/hsr_forward.c:hsr_create_tagged_frame() {
...
} else if (port->dev->features & NETIF_F_HW_HSR_TAG_INS) {
return skb_clone(frame->skb_std, GFP_ATOMIC);
}
...
}prp_create_tagged_frame() does the same. The lower's validate_xmit_skb() then segmented the aggregate, and the hardware tagged and numbered each wire frame. So GSO already worked correctly on these setups.
The mask is now removed whatever the lowers support. The core therefore segments every local super-packet before hsr_dev_xmit(). Each MSS-sized frame then goes through these steps on its own: seqnr_lock, fill_frame_info(), the node list lookup, hsr_register_frame_in(), a clone per port and dev_queue_xmit().
RX is affected too. Plain aggregates that used to be delivered correctly are now segmented in hsr_forward_input() with features = 0. That means linear copies and software checksums. One example is a PRP SAN aggregate arriving from a veth on LAN A/B. Plain TAG_RM aggregates would be affected as well. In-tree offload drivers should stop producing those once the GRO patch in this series is applied.
This patch carries a Fixes: tag, so it will be picked up for stable. Should the commit message mention the cost for offload setups?
Could the feature removal and the segmentation apply only when software tagging is actually needed?
Quoted 4 lines
net/hsr/hsr_forward.c +0
-0
[ ... ]
Quoted 1 line
net/hsr/hsr_forward.c +0
-0@@ -794,3 +797,154 @@ void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port)
[ ... ]
Quoted 2 lines
net/hsr/hsr_forward.c +2
-0+void hsr_forward_input (struct sk_buff *skb,struct hsr_port *port) +{
[ ... ]
net/hsr/hsr_forward.c void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port) · line 917
Quoted 7 lines
net/hsr/hsr_forward.c +7
-0+if (!skb_frags_readable (skb)) + goto drop; + proto =hsr_gso_effective_proto (skb, &l3off); +if (!proto) + goto drop; +if (proto ==htons (ETH_P_HSR ) || proto ==htons (ETH_P_PRP )) + goto drop;
[Severity: Low]
Will this also drop locally destined traffic from unpatched HSR senders?
An unpatched HSR master advertises TSO, and hsr_create_tagged_frame() pushes one HSR tag onto the whole aggregate. A virtio/tap lower with HW_CSUM and TSO carries that skb to the peer unchanged, as a VIRTIO_NET_HDR_GSO_TCPV4 packet.
Before this patch, a receiver with a tap/virtio HSR slave stripped the tag in create_stripped_skb_hsr(). That uses __pskb_copy(), which keeps the GSO metadata, and the result went to the master for local delivery. So local TCP worked.
With this patch, hsr_gso_effective_proto() returns ETH_P_HSR and the skb is dropped before local delivery. TCP from an unpatched HSR guest to a patched host would then degrade to RTO-driven single-MSS retransmissions.
The commit message covers the PRP case:
"Older PRP senders can append one RCT to a whole GSO skb. Such aggregates, including locally destined ones, are now dropped instead of being delivered."
Should it also mention the HSR case? It only happens with mixed kernel versions over tap/virtio. veth cannot trigger it, because both ends run the same kernel.
Quoted 7 lines
net/hsr/hsr_forward.c +7
-0+if (hsr_gso_trailing_data (skb, proto, l3off)) + goto drop; + +/* Segmentation writes skb->cb and header metadata: work on a +* private skb if the input is still shared with a packet socket. +*/ + skb =skb_share_check (skb,GFP_ATOMIC );
net/hsr/hsr_forward.c void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port) · line 934
Quoted 10 lines
net/hsr/hsr_forward.c +10
-0+if (!skb) { +hsr_gso_drop_stat (port); +return ; + } + +/* features = 0 requests full software segmentation into single +* wire frames; tx_path is true only for locally generated +* traffic on the master. +*/ + segs =__skb_gso_segment (skb,0 , port->type ==HSR_PT_MASTER ,0 );
[Severity: Medium]
Is skb_share_check() enough to protect the packet data here? It only handles skb_shared() (users > 1). A cloned skb (users == 1, cloned == 1) still shares its data with another holder. So does the clone that skb_share_check() creates itself.
On RX ports tx_path is false, so __skb_gso_segment() calls skb_cow_head() only for CHECKSUM_NONE:
net/core/gso.c:skb_needs_check() {
if (tx_path)
return skb->ip_summed != CHECKSUM_PARTIAL &&
skb->ip_summed != CHECKSUM_UNNECESSARY;
return skb->ip_summed == CHECKSUM_NONE;
}The GSO handlers then write checksum fields into the head's linear data. udp4_ufo_fragment() does this for every SKB_GSO_UDP input:
net/ipv4/udp_offload.c:udp4_ufo_fragment() {
...
uh->check = 0;
csum = skb_checksum(skb, 0, skb->len, 0);
uh->check = udp_v4_check(skb->len, iph->saddr, iph->daddr, csum);
...
}tcp4_gso_segment() also rewrites th->check whenever ip_summed is not CHECKSUM_PARTIAL.
An RX skb reaching hsr_handle_frame() can be cloned. Two ways this happens:
- packet_rcv() on a non-mmap AF_PACKET socket bound to the port
- a tc ingress mirred mirror
A guest or tap user can inject UFO frames through virtio_net_hdr_to_skb(), either on the interlink or on a PRP LAN as a SAN.
In that case, could the other clone holder see the rewritten UDP checksum bytes? It could also race with them if it segments or checksums the same data at the same time.
The comment above says segmentation writes skb->cb and header metadata, but it writes packet bytes as well. Before this patch, software HSR worked on __pskb_copy() copies with private heads, so this write appears to be new.
Would calling skb_cow_head(skb, 0) or skb_unshare() before __skb_gso_segment() on the RX path close this? For reference, openvswitch's RX path uses the same skb_share_check() plus tx_path = false pattern.
Quoted 2 lines
net/hsr/hsr_forward.c +2
-0+if (IS_ERR_OR_NULL (segs)) + goto drop;
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261107220544.20-1-xiexinet%40gmail.com
PATCH v8 4/4 selftests: net: hsr: verify GRO policy and ordered forwarding
In reply to Xin XieAdd two tests, run by shell entries that exec one installed Python helper.
hsr_gro_superpacket.sh checks the member GRO policy: GRO is off, requested and active, while a device is a member and after it leaves, and can then be turned on again; a device refused at attach keeps its request. It covers close and reopen of an attached veth, a veth attached while down, the master's GSO type mask, a refused bridge port with rollback of the port added before it, a busy macvlan lower, and the refusal of bridge, bond, macvlan and ipvlan devices without leaving an upper link or a promiscuity reference on any port. Natural TCP from the interlink is compared byte for byte, retransmissions included, with both LAN captures. TCP from a SAN on one PRP LAN, in plain and VLAN forms, is compared the same way with the ingress LAN and the local delivery, and its reply must appear once on each LAN. Tags/RCT, sequence numbers and VLAN stacks are checked.
hsr_ordered_forwarding.sh checks local data around interlink data and UDP GSO aggregates, local and proxy supervision, two concurrent producers and an observed sequence-number wrap.
Work is bounded to 120 seconds and cleanup to 20; INT/TERM remove the test's namespaces. Packets are judged only on complete captures without socket loss or truncation. A missing prerequisite SKIPs the affected case; query errors and missing packet evidence FAIL, and the cases after a failure are reported as not ok.
--- tools/testing/selftests/net/hsr/Makefile | 7 +- tools/testing/selftests/net/hsr/config | 4 + .../selftests/net/hsr/hsr_gro_superpacket.py | 1376 +++++++++++++++++ .../selftests/net/hsr/hsr_gro_superpacket.sh | 9 + .../net/hsr/hsr_ordered_forwarding.sh | 9 + 5 files changed, 1404 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/net/hsr/hsr_gro_superpacket.py create mode 100755 tools/testing/selftests/net/hsr/hsr_gro_superpacket.sh create mode 100755 tools/testing/selftests/net/hsr/hsr_ordered_forwarding.sh
tools/testing/selftests/net/hsr/Makefile +6 -1
@@ -3,6 +3,8 @@ top_srcdir = ../../../../.. TEST_PROGS := \ + hsr_gro_superpacket.sh \ + hsr_ordered_forwarding.sh \ hsr_ping.sh \ hsr_prp_redbox.sh \ hsr_redbox.sh \
@@ -10,6 +12,9 @@ TEST_PROGS := \ prp_ping.sh \ # end of TEST_PROGS -TEST_FILES += hsr_common.sh +TEST_FILES += \ + hsr_common.sh \ + hsr_gro_superpacket.py \ +# end of TEST_FILES include ../../lib.mk
tools/testing/selftests/net/hsr/config +4 -0
@@ -1,6 +1,10 @@ +CONFIG_BONDING=y CONFIG_BRIDGE=y CONFIG_HSR=y CONFIG_IPV6=y +CONFIG_IPVLAN=y +CONFIG_MACVLAN=y CONFIG_NET_SCH_NETEM=m +CONFIG_PACKET=y CONFIG_VETH=y CONFIG_VLAN_8021Q=m
tools/testing/selftests/net/hsr/hsr_gro_superpacket.py new file +1376 -0
1,376 lines not on this page · raw message
tools/testing/selftests/net/hsr/hsr_gro_superpacket.sh new file +9 -0
@@ -0,0 +1,9 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +if ! command -v python3 > /dev/null; then + echo "SKIP: missing python3" + exit 4 +fi + +exec python3 -B "$(dirname "$0")/hsr_gro_superpacket.py" gro "$@"
tools/testing/selftests/net/hsr/hsr_ordered_forwarding.sh new file +9 -0
@@ -0,0 +1,9 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +if ! command -v python3 > /dev/null; then + echo "SKIP: missing python3" + exit 4 +fi + +exec python3 -B "$(dirname "$0")/hsr_gro_superpacket.py" ordered "$@"
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH net v8 4/4] selftests: net: hsr: verify GRO policy and ordered forwarding
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
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] topo() in tools/testing/selftests/net/hsr/hsr_gro_superpacket.py treats a…
- [Low] ordered_wrap() in tools/testing/selftests/net/hsr/hsr_gro_superpacket.py checks the…
--
selftests: net: hsr: verify GRO policy and ordered forwarding
This commit adds two HSR/PRP selftests. Each is a shell entry point that execs a shared Python helper. hsr_gro_superpacket.sh covers the GRO policy on member ports, refusal of forwarding port types, and TCP over the interlink and PRP LANs. hsr_ordered_forwarding.sh covers the ordering of local and interlink data, supervision frames, concurrent producers and the sequence number wrap.
Quoted 6 lines
tools/testing/selftests/net/hsr/hsr_gro_superpacket.py new file +0
-0@@ -0,0 +1,1376 @@
[ ... ]
tools/testing/selftests/net/hsr/hsr_gro_superpacket.py line 1117
Quoted 10 lines
tools/testing/selftests/net/hsr/hsr_gro_superpacket.py new file +10
-0+def ordered_wrap(lab): + """The interlink sequence number wraps with both lanes intact.""" + topology = topo(lab) + caps = ordered_lanes(lab, topology) + sender = ordered_socket(lab, topology["tx"], "100.64.2.1") + probe = ordered_send(lab, sender, 4, 0, 1, 5130) + # This only selects the warmup count; final loss-free captures certify it. + rows = [udp_rows(cap, {5130}) for cap in caps] + require(all(len(lane) == 1 for lane in rows) and + rows[0][0]["seq"] == rows[1][0]["seq"], "wrap probe missing or unequal")
[Severity: Low]
Could this check run before the probe has reached the da/db captures? The only wait between sending the probe and reading the captures is the fixed drain at the end of ordered_send(), and it has no completion condition:
ordered_send() {
...
lab.observe(0.1)
return expected
}The probe goes from t0 over the veth to dil, through the HSR rx_handler in NET_RX softirq, and then out on da/db. That softirq usually runs synchronously inside sendto(). If net_rx_action() runs out of budget, the remaining work is handed to ksoftirqd.
On a loaded CI VM, can ksoftirqd take longer than 100 ms to get scheduled? If so, the case would fail with "wrap probe missing or unequal" even though the kernel behaves correctly.
The other packet checks in the script wait through lab.finish() with a completion predicate. Would polling lab.observe() until both lanes hold the probe, bounded by lab.remaining(), close this window?
Quoted 1 line
+ start = rows[0][0]["seq"]
[ ... ]
Quoted 4 lines
tools/testing/selftests/net/hsr/hsr_gro_superpacket.py new file +4
-0+def topo(lab): + """SAN - interlink - HSR DUT - two LANs - receiver namespaces.""" + tx, dut, rx = lab.ns(), lab.ns(), lab.ns() + for ns, dev, peer_ns, peer in ((tx, "t0", dut, "dil"),
tools/testing/selftests/net/hsr/hsr_gro_superpacket.py line 1151
Quoted 10 lines
tools/testing/selftests/net/hsr/hsr_gro_superpacket.py new file +10
-0+ (dut, "da", rx, "ra"), (dut, "db", rx, "rb")): + lab.veth(ns, dev, peer_ns, peer) + for owner, link in ((ns, dev), (peer_ns, peer)): + lab.ip(owner, "link", "set", "dev", link, "up") + hsr_attach(lab, dut, "hm", "da", "db", "dil") + attributes = link_state(lab, dut, "hm")["linkinfo"]["info_data"] + require(attributes.get("proto") == 0 and attributes.get("version") == 1 and + all(attributes.get(key) == value for key, value in + (("slave1", "da"), ("slave2", "db"), ("interlink", "dil"))), + "HSR topology has unexpected protocol/version")
[Severity: Medium]
What happens here with an iproute2 that does not print the HSR version attribute?
The kernel has only sent IFLA_HSR_VERSION for non-PRP devices since commit 16a2206354d169 ("net/hsr: add protocol version to fill_info output"), in hsr_fill_info():
else if (nla_put_u8(skb, IFLA_HSR_VERSION, hsr->prot_version))
Whether a "version" key shows up in the ip -j -d link show output then depends on the iproute2 HSR print code. Older iproute2 releases print slave1, slave2, interlink, seq_nr, supervision and proto, but not version. In that case attributes.get("version") returns None and require() raises ValueError.
ValueError is in CASE_ERRORS, so main() reports the case as not ok. It then marks every later case as failed too:
for later, (other, _) in enumerate(cases[number:], number + 1):
print(f"not ok {later} - {other}: stopped after prior failure", flush=True)
In gro mode, "natural TCP interlink" is the first caller of topo(). The six "PRP LAN" cases after it never call topo(), but they would still be reported as not ok. In ordered mode all five cases call topo(), so the whole test would fail.
A missing interlink option in iproute2 is already reported as SKIP through interlink_unsupported(). Could a missing "version" key get the same treatment, or simply not be required?
Quoted 1 line
+
lab.ip(tx, "addr", "add", "100.64.2.1/24", "dev", "t0")
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261107220544.20-1-xiexinet%40gmail.com