HSR and PRP tag, number and de-duplicate each frame on the wire. GRO
and GSO can hand them one skb holding several frames, which the lower
device then drops or which goes out with a single tag or RCT and
sequence number.
Patch 1 keeps software GRO off on HSR/PRP ports. GRO_HW that the
driver keeps on is left alone.
Patch 2 refuses bridge, bond, team and OVS masters as ports, a macvlan
or MACsec device on top of a bridge, bond, team or HSR/PRP master, and
devices that already have a master or cannot take an RX handler.
This fixes the syzbot recursive seqnr_lock report, as Sebastian
suggested [1].
A port check cannot catch every path back into an HSR master, such
as a tc/BPF redirect or a tunnel; those still nest the lock and can
deadlock on the same device. Fixing them without dropping traffic
needs seqnr_lock released before the port transmit, which can reorder
frames for receivers without aae9d6b616b5 ("hsr: Implement more robust
duplicate discard for HSR"). That is left to net-next, where Hangbin's
patch [2] fits. He dropped it in favor of this series [3]; as this
series no longer narrows seqnr_lock, it can go ahead there.
Patch 3 segments GSO skbs before per-frame processing, outside
seqnr_lock. GSO reaches an HSR/PRP port even with GRO off, typically
from a container attached to a PRP RedBox interlink through veth:
container/netns host PRP RedBox
prp0-peer ---- veth ---- prp0-int (interlink RX)
|
split GSO into frames
|
sequence number + RCT
/ \
LAN A LAN B
Some old Linux PRP senders put one RCT on a whole GSO skb; patch 3
drops such aggregates when it can detect them. With GRO_HW off on
virtio-net, the host may segment them first and the RCT arrives as
payload; upgrade the sender or disable GSO and TSO on its HSR/PRP
master.
Patch 4 adds selftests.
Tested on a lockdep kernel: the new selftests (also with Python 3.9)
and the existing hsr selftests pass, and the syzbot reproducer no
longer reports recursive locking. No new W=1 warnings.
No stable backport is requested. The remaining HSR dev->stats races
are left to a separate series, as Paolo suggested [4].
Based on net 30c71476d842; also applies to net-next. Patch 3
conflicts with Sebastian's pending net-next series [5]; its notes give
the resolution.
Changes since v8:
- Patch 1: the message and comments say which ports the rule covers.
- Patch 2: macvlan and MACsec are refused only on top of a bridge,
bond, team or HSR/PRP master; all ports are checked before any is
changed.
- Patch 3: copy a head shared with a clone before segmenting.
- Patch 4: no fixed sleep, no need for iproute2 to print the HSR
version, new refusal cases.
[1] https://lore.kernel.org/netdev/20261014151838.6RyMIRVM@linutronix.de/ (local)
[2] https://lore.kernel.org/netdev/20260805-hsr_deadlock-v1-1-d8a6f06fc5a8@kylinos.cn/ (local)
[3] https://lore.kernel.org/netdev/anXnxn-PBv8qH6VB@fedora/ (local)
[4] https://lore.kernel.org/netdev/4fc3b9f1-4bef-4b34-ae7a-e89037cce829@redhat.com/ (local)
[5] https://lore.kernel.org/netdev/20261104-hsr_ptp-v10-0-2c4a38ad973c@linutronix.de/ (local)
v8: https://lore.kernel.org/netdev/20261107220544.20-1-xiexinet@gmail.com/ (local)
v7: https://lore.kernel.org/netdev/20261009201324.17-1-xiexinet@gmail.com/ (local)
v6: https://lore.kernel.org/netdev/20260809121455.1745-1-xiexinet@gmail.com/ (local)
v5: https://lore.kernel.org/netdev/20260807140751.1351-1-xiexinet@gmail.com/ (local)
v4: https://lore.kernel.org/netdev/20260803222211.877-1-xiexinet@gmail.com/ (local)
v3: https://lore.kernel.org/netdev/20260731090224.18-1-xiexinet@gmail.com/ (local)
v2: https://lore.kernel.org/netdev/20260724161253.79-1-xiexinet@gmail.com/ (local)
v1: https://lore.kernel.org/netdev/20260722171836.196-1-xiexinet@gmail.com/ (local)
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 | 8 +
net/core/dev.c | 15 +
net/hsr/hsr_device.c | 13 +-
net/hsr/hsr_forward.c | 158 ++
net/hsr/hsr_forward.h | 1 +
net/hsr/hsr_slave.c | 145 +-
net/hsr/hsr_slave.h | 2 +
tools/testing/selftests/net/hsr/Makefile | 7 +-
tools/testing/selftests/net/hsr/config | 10 +
.../selftests/net/hsr/hsr_gro_superpacket.py | 1456 +++++++++++++++++
.../selftests/net/hsr/hsr_gro_superpacket.sh | 9 +
.../net/hsr/hsr_ordered_forwarding.sh | 9 +
13 files changed, 1819 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: 30c71476d842b094651bd7712f6c8ee8716147d0
--
2.53.0