net: hsr: PRP RedBox (PRP-SAN) support
Subsystems (4)
cover net: hsr: PRP RedBox (PRP-SAN) support
This series adds PRP RedBox support to the hsr driver: a PRP node that proxies one or more SANs sitting behind an interlink port (IEC 62439-3, PRP-SAN). HSR-SAN has been supported since commit 5055cccfc2d1 ("net: hsr:
Provide RedBox support (HSR-SAN)"); this extends the equivalent capability to PRP, reusing the existing protocol-neutral proxy machinery (proxy_node_db, hsr_proxy_announce(), hsr_prune_proxy_nodes()).
A SAN behind the interlink does bidirectional unicast with peers on the PRP network, its source MAC is preserved on the wire, the PRP RCT is correct, and the RedBox announces each proxied SAN with the RedBox-MAC TLV (Type 30) in its supervision frames.
The series is bisect-safe: the datapath, duplicate discard and supervision support are added first; the rtnetlink rejection of "type hsr ... interlink <dev> proto 1" is removed only in patch 3, once the feature is complete.
Design notes:
- prp_drop_frame() does not walk the node tables. The destination classification (PRP-network node vs proxied SAN) is resolved once per frame in fill_frame_info() and cached in struct hsr_frame_info, so the per egress-port drop decision is O(1) in the softIRQ path. The classification is gated on PRP RedBox devices (prot_version == PRP_V1 && hsr->redbox), so HSR RedBox traffic is not affected.
- The LAN A/B duplicate test is factored into prp_is_lan_dup() so the new PRP interlink rules in prp_drop_frame() do not change hsr_drop_frame() behaviour, including the NETIF_F_HW_HSR_FWD path. This is software PRP RedBox only; it adds no new hardware-offload contract.
- The supervision emitter uses pre-reserved tailroom (hsr_init_skb() + skb_put()) on the existing GFP_ATOMIC path; no skb_linearize() or pskb_expand_head(). The RedBox-MAC TLV is followed by an explicit EOT (Type 0, Length 0); padding via skb_put_padto(ETH_ZLEN) and the 6-byte PRP RCT remain at the absolute tail of the egress frame.
- The hsr_get_node() hsr_ethhdr length guard is relaxed only for PRP supervision frames (prot_version == PRP_V1 && ETH_P_PRP && is_sup), which are untagged with mac_len == ETH_HLEN. HSR (ETH_P_HSR) supervision is front-tagged and keeps the original length requirement, so HSR malformed-frame filtering is unchanged.
Testing (on a net-next v7.2-rc1 kernel built from this base, x86-64):
- checkpatch.pl --strict: patches 1-3 clean; patch 4 reports only the expected "added file(s), does MAINTAINERS need updating?" note, which is ignorable here -- MAINTAINERS already lists tools/testing/selftests/net/hsr/ under HSR NETWORK PROTOCOL.
- git diff --check clean; the series git-am's onto the base commit.
- tools/testing/selftests/net/hsr/hsr_prp_redbox.sh: PASS on the patched kernel (bidirectional unicast, SAN MAC preservation, RedBox-MAC TLV + EOT in the proxy-announce).
- HSR regression on the same kernel: hsr_redbox.sh (HSR-SAN/RedBox), hsr_ping.sh and prp_ping.sh all PASS, confirming the PRP changes do not regress the existing HSR/PRP paths.
- netns checks: peer<->SAN 0% loss with no duplicates and a valid PRP RCT on the wire; a silent SAN is pruned from the announce; zero driver WARN/BUG/Oops/RCU-stall during the run.
Beyond the in-tree selftest, this exact series (applied to this base and running as the net-next kernel on x86-64 hardware) was also validated with an out-of-tree IEC 62439-3 conformance harness (supervision TLV chain, duplicate discard, cross-LAN rejection, seqnr rollover, VLAN/multicast/GOOSE frame types with the RCT verified at the absolute frame tail), and interoperability-tested against a commercial PRP RedBox (Siemens SCALANCE X204RNA) over 100 Mbit/s Fast Ethernet with NIC hardware (PTP) timestamping: a mid-stream single-LAN outage of ~2 s at 10 kpps was bridged with zero lost and zero duplicate frames (seamless PRP failover), and the duplicate-discard window held zero lost / zero duplicates under netem asymmetric delay up to 100 ms (~1000 sequence numbers in flight), 25% reorder, and 5% single-LAN loss. The failover and impairment matrix was additionally repeated on a KASAN + lockdep + kmemleak instrumented build of this kernel, including a 72-carrier-event link flap-storm with deliberate double-LAN cuts: zero KASAN, lockdep, or kmemleak findings. This out-of-tree testing is supplementary and not required to evaluate the series.
Xin Xie (4):
net: hsr: add PRP interlink (RedBox) datapath and duplicate discard
net: hsr: emit RedBox-MAC TLV in PRP RedBox supervision frames
net: hsr: allow PRP RedBox (interlink) creation
selftests: net: hsr: add PRP RedBox test
net/hsr/hsr_device.c | 33 ++++++- net/hsr/hsr_forward.c | 49 ++++++++-- net/hsr/hsr_framereg.c | 23 ++++- net/hsr/hsr_framereg.h | 2 + net/hsr/hsr_netlink.c | 8 +- tools/testing/selftests/net/hsr/Makefile | 1 + .../selftests/net/hsr/hsr_prp_redbox.sh | 96 +++++++++++++++++++ 7 files changed, 191 insertions(+), 21 deletions(-) create mode 100755 tools/testing/selftests/net/hsr/hsr_prp_redbox.sh
base-commit: b73bc9ca3686b78b642fb35dcc1fdf874ecb74a1 --
2.53.0
PATCH 1/4 net: hsr: add PRP interlink (RedBox) datapath and duplicate discard
A PRP RedBox proxies SANs that sit behind an interlink port: their frames must reach the PRP network with the SAN source MAC preserved, and PRP unicast must be steered between the LAN and the SAN segment correctly.
Add the PRP interlink forwarding rules to prp_drop_frame() and give RedBox nodes a second duplicate-discard slot so the two LAN copies of a frame destined to a SAN collapse to a single delivery out the interlink.
The destination classification (is the unicast DA a PRP-network node or a proxied SAN) is resolved once per frame in fill_frame_info(), gated to PRP RedBox devices, and cached in struct hsr_frame_info, so prp_drop_frame() stays O(1) and does not walk the node tables for every candidate egress port in the softIRQ path. HSR RedBox frame classification is untouched.
Factor the LAN A/B duplicate test into prp_is_lan_dup() so the new PRP interlink rules do not change hsr_drop_frame() behaviour, including the NETIF_F_HW_HSR_FWD path which keeps using the LAN-duplicate test only.
--- net/hsr/hsr_forward.c | 49 ++++++++++++++++++++++++++++++++++++------ net/hsr/hsr_framereg.c | 10 ++++++--- net/hsr/hsr_framereg.h | 2 ++ 3 files changed, 52 insertions(+), 9 deletions(-)
net/hsr/hsr_forward.c +43 -6
@@ -440,12 +440,37 @@ static int hsr_xmit(struct sk_buff *skb, struct hsr_port *port,return dev_queue_xmit (skb); } +static bool prp_is_lan_dup (struct hsr_frame_info *frame, +struct hsr_port *port) +{ +enum hsr_port_type rx = frame->port_rcv->type; + +return (rx ==HSR_PT_SLAVE_A && port->type ==HSR_PT_SLAVE_B ) || + (rx ==HSR_PT_SLAVE_B && port->type ==HSR_PT_SLAVE_A ); +} +bool prp_drop_frame (struct hsr_frame_info *frame,struct hsr_port *port) { -return ((frame->port_rcv->type ==HSR_PT_SLAVE_A && - port->type ==HSR_PT_SLAVE_B ) || - (frame->port_rcv->type ==HSR_PT_SLAVE_B && - port->type ==HSR_PT_SLAVE_A )); +enum hsr_port_type rx = frame->port_rcv->type; + +/* Supervision frames are not delivered to a SAN on the interlink. */ +if (frame->is_supervision && port->type ==HSR_PT_INTERLINK ) +return true; + +if (prp_is_lan_dup (frame, port)) +return true; + +/* LAN to interlink: keep PRP-network unicast off the SAN segment. */ +if ((rx ==HSR_PT_SLAVE_A || rx ==HSR_PT_SLAVE_B ) && + port->type ==HSR_PT_INTERLINK ) +return frame->dst_in_node_db; + +/* Interlink to LAN: keep SAN-to-SAN unicast local. */ +if ((port->type ==HSR_PT_SLAVE_A || port->type ==HSR_PT_SLAVE_B ) && + rx ==HSR_PT_INTERLINK ) +return frame->dst_in_proxy_node_db; + +return false; }bool hsr_drop_frame (struct hsr_frame_info *frame,struct hsr_port *port)
@@ -453,7 +478,7 @@ bool hsr_drop_frame(struct hsr_frame_info *frame, struct hsr_port *port)struct sk_buff *skb;if (port->dev->features &NETIF_F_HW_HSR_FWD ) -return prp_drop_frame (frame, port); +return prp_is_lan_dup (frame, port);/* RedBox specific frames dropping policies *
@@ -466,7 +491,7 @@ bool hsr_drop_frame(struct hsr_frame_info *frame, struct hsr_port *port)* are addressed to interlink port (and are in the ProxyNodeTable). */ skb = frame->skb_hsr; -if (skb &&prp_drop_frame (frame, port) && +if (skb &&prp_is_lan_dup (frame, port) &&is_unicast_ether_addr (eth_hdr (skb)->h_dest) &&hsr_is_node_in_db (&port->hsr->proxy_node_db,eth_hdr (skb)->h_dest)) {
@@ -706,6 +731,18 @@ static int fill_frame_info(struct hsr_frame_info *frame, frame->is_vlan = false; proto = ethhdr->h_proto; +/* PRP RedBox only: classify the unicast destination once so the +* per-egress-port decision in prp_drop_frame() stays O(1). HSR RedBox +* does its own classification and must not pay these node-table walks. +*/ +if (hsr->prot_version ==PRP_V1 && hsr->redbox && +is_unicast_ether_addr (ethhdr->h_dest)) { + frame->dst_in_node_db = +hsr_is_node_in_db (&hsr->node_db, ethhdr->h_dest); + frame->dst_in_proxy_node_db = +hsr_is_node_in_db (&hsr->proxy_node_db, ethhdr->h_dest); + } +if (proto ==htons (ETH_P_8021Q )) frame->is_vlan = true;
net/hsr/hsr_framereg.c +7 -3
@@ -199,7 +199,7 @@ static struct hsr_node *hsr_add_node(struct hsr_priv *hsr,spin_lock_init (&new_node->seq_out_lock);if (hsr->prot_version ==PRP_V1 ) - new_node->seq_port_cnt =1 ; + new_node->seq_port_cnt = hsr->redbox ?2 :1 ;else new_node->seq_port_cnt =HSR_PT_PORTS -1 ;
@@ -649,9 +649,13 @@ int prp_register_frame_out(struct hsr_port *port, struct hsr_frame_info *frame)if (frame->port_rcv->type ==HSR_PT_MASTER )return 0 ; -/* for PRP we should only forward frames from the slave ports -* to the master port +/* RedBox: forward LAN frames out the interlink to a SAN, deduping the +* two LAN copies on a dedicated slot. */ +if (port->type ==HSR_PT_INTERLINK ) +return hsr_check_duplicate (frame,1 ); + +/* For PRP only slave-to-master frames are forwarded. */ if (port->type !=HSR_PT_MASTER )return 1 ;
net/hsr/hsr_framereg.h +2 -0
@@ -27,6 +27,8 @@ struct hsr_frame_info {bool is_local_dest;bool is_local_exclusive;bool is_from_san; +bool dst_in_node_db; +bool dst_in_proxy_node_db; };void hsr_del_self_node (struct hsr_priv *hsr);
Signature · 1 line
2.53.0
PATCH 2/4 net: hsr: emit RedBox-MAC TLV in PRP RedBox supervision frames
In reply to Xin XieA PRP RedBox must announce the SANs it proxies so peers populate their proxy node tables. The proxy-announce machinery (hsr_proxy_announce(), armed via hsr->redbox) already iterates proxy_node_db under RCU and calls send_sv_frame() once per SAN, but the PRP sender emitted neither the announced SAN MAC nor the RedBox-MAC TLV that IEC 62439-3 requires.
Extend send_prp_supervision_frame() so that, for a proxy-announce (identified by the interlink port, an O(1) test), the frame carries the proxied SAN MAC as MacAddressA followed by the RedBox-MAC TLV (Type 30) and an explicit End-of-TLV marker before padding.
hsr_get_node() must also accept the reinjected proxy-announce: a PRP supervision frame is an untagged ETH_P_PRP frame (mac_len == ETH_HLEN, the RCT is appended only on egress) sourced from macaddress_redbox, which is never learned from data. Exempt only PRP supervision frames from the hsr_ethhdr length guard; HSR (ETH_P_HSR) supervision is front-tagged and keeps the original guard, so HSR malformed-frame filtering is unchanged.
--- net/hsr/hsr_device.c | 33 ++++++++++++++++++++++++++++++--- net/hsr/hsr_framereg.c | 13 +++++++++++-- 2 files changed, 41 insertions(+), 5 deletions(-)
net/hsr/hsr_device.c +30 -3
@@ -372,10 +372,21 @@ static void send_prp_supervision_frame(struct hsr_port *master, {struct hsr_priv *hsr = master->hsr;struct hsr_sup_payload *hsr_sp; +struct hsr_sup_tlv *hsr_stlv;struct hsr_sup_tag *hsr_stag;struct sk_buff *skb; +bool redbox_proxy; +int extra =0 ; + + redbox_proxy = hsr->redbox && master->type ==HSR_PT_INTERLINK ; + +/* A proxy-announce carries a RedBox-MAC TLV and an EOT marker. */ +if (redbox_proxy) + extra =sizeof (struct hsr_sup_tlv ) + +sizeof (struct hsr_sup_payload ) + +sizeof (struct hsr_sup_tlv ); - skb =hsr_init_skb (master,0 ); + skb =hsr_init_skb (master, extra);if (!skb) {netdev_warn_once (master->dev,"PRP: Could not send supervision frame\n" );return ;
@@ -393,9 +404,25 @@ static void send_prp_supervision_frame(struct hsr_port *master, hsr_stag->tlv.HSR_TLV_type =PRP_TLV_LIFE_CHECK_DD ; hsr_stag->tlv.HSR_TLV_length =sizeof (struct hsr_sup_payload ); -/* Payload: MacAddressA */ +/* Payload: MacAddressA, the announced node. */ hsr_sp =skb_put (skb,sizeof (struct hsr_sup_payload )); -ether_addr_copy (hsr_sp->macaddress_A, master->dev->dev_addr); +ether_addr_copy (hsr_sp->macaddress_A, addr); + +/* Proxy-announce: append the RedBox-MAC TLV (Type 30) and an explicit +* EOT to terminate the TLV chain before zero padding. +*/ +if (redbox_proxy) { + hsr_stlv =skb_put (skb,sizeof (struct hsr_sup_tlv )); + hsr_stlv->HSR_TLV_type =PRP_TLV_REDBOX_MAC ; + hsr_stlv->HSR_TLV_length =sizeof (struct hsr_sup_payload ); + + hsr_sp =skb_put (skb,sizeof (struct hsr_sup_payload )); +ether_addr_copy (hsr_sp->macaddress_A, hsr->macaddress_redbox); + + hsr_stlv =skb_put (skb,sizeof (struct hsr_sup_tlv )); + hsr_stlv->HSR_TLV_type =HSR_TLV_EOT ; + hsr_stlv->HSR_TLV_length =0 ; + }if (skb_put_padto (skb,ETH_ZLEN )) {spin_unlock_bh (&hsr->seqnr_lock);
net/hsr/hsr_framereg.c +11 -2
@@ -293,8 +293,17 @@ struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,*/ if (ethhdr->h_proto ==htons (ETH_P_PRP ) || ethhdr->h_proto ==htons (ETH_P_HSR )) { -/* Check if skb contains hsr_ethhdr */ -if (skb->mac_len <sizeof (struct hsr_ethhdr )) +bool prp_sup; + +/* A PRP supervision frame is an untagged ETH_P_PRP frame +* (mac_len == ETH_HLEN); its RCT is appended only on egress. +* HSR (ETH_P_HSR) supervision is front-tagged and still must +* contain a struct hsr_ethhdr. +*/ + prp_sup = hsr->prot_version ==PRP_V1 && + ethhdr->h_proto ==htons (ETH_P_PRP ) && is_sup; + +if (!prp_sup && skb->mac_len <sizeof (struct hsr_ethhdr ))return NULL ; }else { rct =skb_get_PRP_rct (skb);
Signature · 1 line
2.53.0
PATCH 3/4 net: hsr: allow PRP RedBox (interlink) creation
In reply to Xin XieWith the PRP interlink datapath, duplicate discard and supervision support in place, a PRP device can act as a RedBox. Remove the rtnetlink rejection of "type hsr ... interlink <dev> proto 1"; the feature is implemented unconditionally by the preceding patches.
--- net/hsr/hsr_netlink.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
net/hsr/hsr_netlink.c +1 -7
@@ -121,14 +121,8 @@ static int hsr_newlink(struct net_device *dev, } } -if (proto ==HSR_PROTOCOL_PRP ) { +if (proto ==HSR_PROTOCOL_PRP ) proto_version =PRP_V1 ; -if (interlink) { -NL_SET_ERR_MSG_MOD (extack, -"Interlink only works with HSR" ); -return -EINVAL ; - } - }return hsr_dev_finalize (dev, link, interlink, multicast_spec, proto_version, extack);
Signature · 1 line
2.53.0
PATCH 4/4 selftests: net: hsr: add PRP RedBox test
In reply to Xin XieAdd a kselftest that builds a PRP RedBox (interlink) with a SAN behind the interlink and a peer DANP, and checks bidirectional unicast across the interlink, preservation of the SAN source MAC on the PRP network, and that the proxy-announce supervision frame carries the RedBox-MAC TLV (Type 30) terminated by an EOT marker. It reuses the hsr_common.sh / lib.sh helpers and skips cleanly on a kernel or iproute2 without PRP interlink support.
--- tools/testing/selftests/net/hsr/Makefile | 1 + .../selftests/net/hsr/hsr_prp_redbox.sh | 96 +++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100755 tools/testing/selftests/net/hsr/hsr_prp_redbox.sh
tools/testing/selftests/net/hsr/Makefile +1 -0
@@ -4,6 +4,7 @@ top_srcdir = ../../../../.. TEST_PROGS := \ hsr_ping.sh \ + hsr_prp_redbox.sh \ hsr_redbox.sh \ link_faults.sh \ prp_ping.sh \
tools/testing/selftests/net/hsr/hsr_prp_redbox.sh new file +96 -0
96 lines not on this page · raw message
Signature · 1 line
2.53.0
v2 cover net: hsr: PRP RedBox (PRP-SAN) support
In reply to Xin XieThis series adds PRP RedBox support to the hsr driver: a PRP node that proxies one or more SANs sitting behind an interlink port (IEC 62439-3, PRP-SAN). HSR-SAN has been supported since commit 5055cccfc2d1 ("net: hsr:
Provide RedBox support (HSR-SAN)"); this extends the equivalent capability to PRP, reusing the existing protocol-neutral proxy machinery (proxy_node_db, hsr_proxy_announce(), hsr_prune_proxy_nodes()).
A SAN behind the interlink does bidirectional unicast with peers on the PRP network, its source MAC is preserved on the wire, the PRP RCT is correct, and the RedBox announces each proxied SAN with the RedBox-MAC TLV (Type 30) in its supervision frames.
The series is bisect-safe: the datapath, duplicate discard and supervision support are added first; the rtnetlink rejection of "type hsr ... interlink <dev> proto 1" is removed only in patch 3, once the feature is complete.
Design notes:
- prp_drop_frame() does not walk the node tables. The destination classification (PRP-network node vs proxied SAN) is resolved once per frame in fill_frame_info() and cached in struct hsr_frame_info, so the per egress-port drop decision is O(1) in the softIRQ path. The classification is gated on PRP RedBox devices (prot_version == PRP_V1 && hsr->redbox), so HSR RedBox traffic is not affected.
- The LAN A/B duplicate test is factored into prp_is_lan_dup() so the new PRP interlink rules in prp_drop_frame() do not change hsr_drop_frame() behaviour, including the NETIF_F_HW_HSR_FWD path. This is software PRP RedBox only; it adds no new hardware-offload contract.
- The supervision emitter uses pre-reserved tailroom (hsr_init_skb() + skb_put()) on the existing GFP_ATOMIC path; no skb_linearize() or pskb_expand_head(). The RedBox-MAC TLV is followed by an explicit EOT (Type 0, Length 0); padding via skb_put_padto(ETH_ZLEN) and the 6-byte PRP RCT remain at the absolute tail of the egress frame.
- The hsr_get_node() hsr_ethhdr length guard is relaxed only for PRP supervision frames (prot_version == PRP_V1 && ETH_P_PRP && is_sup), which are untagged with mac_len == ETH_HLEN. HSR (ETH_P_HSR) supervision is front-tagged and keeps the original length requirement, so HSR malformed-frame filtering is unchanged.
Testing (on a net-next v7.2-rc1 kernel built from this base, x86-64):
- checkpatch.pl --strict: patches 1-3 clean; patch 4 reports only the expected "added file(s), does MAINTAINERS need updating?" note, which is ignorable here -- MAINTAINERS already lists tools/testing/selftests/net/hsr/ under HSR NETWORK PROTOCOL.
- git diff --check clean; the series git-am's onto the base commit.
- tools/testing/selftests/net/hsr/hsr_prp_redbox.sh: PASS on the patched kernel (bidirectional unicast, SAN MAC preservation, RedBox-MAC TLV + EOT in the proxy-announce).
- HSR regression on the same kernel: hsr_redbox.sh (HSR-SAN/RedBox), hsr_ping.sh and prp_ping.sh all PASS, confirming the PRP changes do not regress the existing HSR/PRP paths.
- netns checks: peer<->SAN 0% loss with no duplicates and a valid PRP RCT on the wire; a silent SAN is pruned from the announce; zero driver WARN/BUG/Oops/RCU-stall during the run.
Beyond the in-tree selftest, this exact series (applied to this base and running as the net-next kernel on x86-64 hardware) was also validated with an out-of-tree IEC 62439-3 conformance harness (supervision TLV chain, duplicate discard, cross-LAN rejection, seqnr rollover, VLAN/multicast/GOOSE frame types with the RCT verified at the absolute frame tail), and interoperability-tested against a commercial PRP RedBox (Siemens SCALANCE X204RNA) over 100 Mbit/s Fast Ethernet with NIC hardware (PTP) timestamping: a mid-stream single-LAN outage of ~2 s at 10 kpps was bridged with zero lost and zero duplicate frames (seamless PRP failover), and the duplicate-discard window held zero lost / zero duplicates under netem asymmetric delay up to 100 ms (~1000 sequence numbers in flight), 25% reorder, and 5% single-LAN loss. The failover and impairment matrix was additionally repeated on a KASAN + lockdep + kmemleak instrumented build of this kernel, including a 72-carrier-event link flap-storm with deliberate double-LAN cuts: zero KASAN, lockdep, or kmemleak findings. This out-of-tree testing is supplementary and not required to evaluate the series.
v1 -> v2:
- publish the RedBox state before lower RX handlers can learn nodes:
fixes an initialization-ordering race where a node learned during device setup got a single-port sequence block, breaking interlink duplicate discard and letting the supervision merge read beyond the source node's allocated sequence bitmap (reported by the NIPA Sashiko review)
- harden the supervision sequence-block merge against mismatched seq_port_cnt
- align macaddress_redbox for ether_addr_copy() on strict-alignment architectures
- selftest: kill the background ping by exact PID and wrap an overlong line
Xin Xie (4):
net: hsr: add PRP interlink (RedBox) datapath and duplicate discard
net: hsr: emit RedBox-MAC TLV in PRP RedBox supervision frames
net: hsr: allow PRP RedBox (interlink) creation
selftests: net: hsr: add PRP RedBox test
net/hsr/hsr_device.c | 44 ++++++++- net/hsr/hsr_forward.c | 49 +++++++-- net/hsr/hsr_framereg.c | 27 +++-- net/hsr/hsr_framereg.h | 2 + net/hsr/hsr_main.h | 2 +- net/hsr/hsr_netlink.c | 8 +- tools/testing/selftests/net/hsr/Makefile | 1 + .../selftests/net/hsr/hsr_prp_redbox.sh | 99 +++++++++++++++++++ 8 files changed, 207 insertions(+), 25 deletions(-) create mode 100755 tools/testing/selftests/net/hsr/hsr_prp_redbox.sh
base-commit: b73bc9ca3686b78b642fb35dcc1fdf874ecb74a1
Signature · 1 line
2.53.0
PATCH v2 1/4 net: hsr: add PRP interlink (RedBox) datapath and duplicate discard
A PRP RedBox proxies SANs that sit behind an interlink port: their frames must reach the PRP network with the SAN source MAC preserved, and PRP unicast must be steered between the LAN and the SAN segment correctly.
Add the PRP interlink forwarding rules to prp_drop_frame() and give RedBox nodes a second duplicate-discard slot so the two LAN copies of a frame destined to a SAN collapse to a single delivery out the interlink.
The destination classification (is the unicast DA a PRP-network node or a proxied SAN) is resolved once per frame in fill_frame_info(), gated to PRP RedBox devices, and cached in struct hsr_frame_info, so prp_drop_frame() stays O(1) and does not walk the node tables for every candidate egress port in the softIRQ path. HSR RedBox frame classification is untouched.
Factor the LAN A/B duplicate test into prp_is_lan_dup() so the new PRP interlink rules do not change hsr_drop_frame() behaviour, including the NETIF_F_HW_HSR_FWD path which keeps using the LAN-duplicate test only.
Publish the RedBox state before the first hsr_add_port(): the slave and interlink rx handlers are live from hsr_add_port() on and rtnl does not stop softirq processing, so a frame could otherwise be handled while hsr->redbox is still false. hsr_add_node() sizes each node's per-port sequence state from hsr->redbox; a node learned in that window would get a single-port sequence block, breaking the interlink duplicate discard (WARN_ON_ONCE plus duplicate delivery to the SAN) and letting the supervision sequence-block merge read beyond the source node's allocated sequence bitmap. Publishing the flag before any port exists makes the per-node sizing uniform by construction. This is safe: the proxy announce timer is only armed from hsr_check_announce() once the master is running, the packet-path readers of hsr->redbox tolerate an empty proxy node database and an absent interlink port, and the prune_proxy_timer is still armed only after the interlink port has been attached successfully.
Additionally bound the supervision sequence-block merge by the smaller of the two nodes' seq_port_cnt as defense in depth against mismatched node sizes.
--- net/hsr/hsr_device.c | 11 ++++++++-- net/hsr/hsr_forward.c | 49 ++++++++++++++++++++++++++++++++++++------ net/hsr/hsr_framereg.c | 14 ++++++++---- net/hsr/hsr_framereg.h | 2 ++ 4 files changed, 64 insertions(+), 12 deletions(-)
net/hsr/hsr_device.c +9 -2
@@ -768,6 +768,15 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],/* Make sure the 1st call to netif_carrier_on() gets through */ netif_carrier_off (hsr_dev); +/* Publish the RedBox state before any port is attached: the rx +* handlers are live from hsr_add_port() on, and hsr_add_node() +* sizes each node's per-port sequence state from hsr->redbox. +*/ +if (interlink) { + hsr->redbox = true; +ether_addr_copy (hsr->macaddress_redbox, interlink->dev_addr); + } + res =hsr_add_port (hsr, hsr_dev,HSR_PT_MASTER , extack);if (res) goto err_add_master;
@@ -805,8 +814,6 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],if (res) goto err_unregister; - hsr->redbox = true; -ether_addr_copy (hsr->macaddress_redbox, interlink->dev_addr);mod_timer (&hsr->prune_proxy_timer, jiffies +msecs_to_jiffies (PRUNE_PROXY_PERIOD )); }
net/hsr/hsr_forward.c +43 -6
75 lines not on this page · raw message
net/hsr/hsr_framereg.c +10 -4
@@ -199,7 +199,7 @@ static struct hsr_node *hsr_add_node(struct hsr_priv *hsr,spin_lock_init (&new_node->seq_out_lock);if (hsr->prot_version ==PRP_V1 ) - new_node->seq_port_cnt =1 ; + new_node->seq_port_cnt = hsr->redbox ?2 :1 ;else new_node->seq_port_cnt =HSR_PT_PORTS -1 ;
@@ -381,6 +381,7 @@ void hsr_handle_sup_frame(struct hsr_frame_info *frame)struct ethhdr *ethhdr;unsigned int total_pull_size =0 ;unsigned int pull_size =0 ; +unsigned int seq_port_cnt;unsigned long idx;int i;
@@ -474,6 +475,7 @@ void hsr_handle_sup_frame(struct hsr_frame_info *frame) } } + seq_port_cnt =min (node_real->seq_port_cnt, node_curr->seq_port_cnt);xa_for_each (&node_curr->seq_blocks, idx, src_blk) {if (hsr_seq_block_is_old (src_blk))continue ;
@@ -482,7 +484,7 @@ void hsr_handle_sup_frame(struct hsr_frame_info *frame)if (!merge_blk)continue ; merge_blk->time =min (merge_blk->time, src_blk->time); -for (i =0 ; i < node_real->seq_port_cnt; i++) { +for (i =0 ; i < seq_port_cnt; i++) {bitmap_or (merge_blk->seq_nrs[i], merge_blk->seq_nrs[i], src_blk->seq_nrs[i],HSR_SEQ_BLOCK_SIZE ); }
@@ -649,9 +651,13 @@ int prp_register_frame_out(struct hsr_port *port, struct hsr_frame_info *frame)if (frame->port_rcv->type ==HSR_PT_MASTER )return 0 ; -/* for PRP we should only forward frames from the slave ports -* to the master port +/* RedBox: forward LAN frames out the interlink to a SAN, deduping the +* two LAN copies on a dedicated slot. */ +if (port->type ==HSR_PT_INTERLINK ) +return hsr_check_duplicate (frame,1 ); + +/* For PRP only slave-to-master frames are forwarded. */ if (port->type !=HSR_PT_MASTER )return 1 ;
net/hsr/hsr_framereg.h +2 -0
@@ -27,6 +27,8 @@ struct hsr_frame_info {bool is_local_dest;bool is_local_exclusive;bool is_from_san; +bool dst_in_node_db; +bool dst_in_proxy_node_db; };void hsr_del_self_node (struct hsr_priv *hsr);
Signature · 1 line
2.53.0
PATCH v2 2/4 net: hsr: emit RedBox-MAC TLV in PRP RedBox supervision frames
In reply to Xin XieA PRP RedBox must announce the SANs it proxies so peers populate their proxy node tables. The proxy-announce machinery (hsr_proxy_announce(), armed via hsr->redbox) already iterates proxy_node_db under RCU and calls send_sv_frame() once per SAN, but the PRP sender emitted neither the announced SAN MAC nor the RedBox-MAC TLV that IEC 62439-3 requires.
Extend send_prp_supervision_frame() so that, for a proxy-announce (identified by the interlink port, an O(1) test), the frame carries the proxied SAN MAC as MacAddressA followed by the RedBox-MAC TLV (Type 30) and an explicit End-of-TLV marker before padding.
hsr_get_node() must also accept the reinjected proxy-announce: a PRP supervision frame is an untagged ETH_P_PRP frame (mac_len == ETH_HLEN, the RCT is appended only on egress) sourced from macaddress_redbox, which is never learned from data. Exempt only PRP supervision frames from the hsr_ethhdr length guard; HSR (ETH_P_HSR) supervision is front-tagged and keeps the original guard, so HSR malformed-frame filtering is unchanged.
Also align macaddress_redbox so that ether_addr_copy() and ether_addr_equal() on it are safe on architectures without efficient unaligned access.
--- net/hsr/hsr_device.c | 33 ++++++++++++++++++++++++++++++--- net/hsr/hsr_framereg.c | 13 +++++++++++-- net/hsr/hsr_main.h | 2 +- 3 files changed, 42 insertions(+), 6 deletions(-)
net/hsr/hsr_device.c +30 -3
@@ -372,10 +372,21 @@ static void send_prp_supervision_frame(struct hsr_port *master, {struct hsr_priv *hsr = master->hsr;struct hsr_sup_payload *hsr_sp; +struct hsr_sup_tlv *hsr_stlv;struct hsr_sup_tag *hsr_stag;struct sk_buff *skb; +bool redbox_proxy; +int extra =0 ; + + redbox_proxy = hsr->redbox && master->type ==HSR_PT_INTERLINK ; + +/* A proxy-announce carries a RedBox-MAC TLV and an EOT marker. */ +if (redbox_proxy) + extra =sizeof (struct hsr_sup_tlv ) + +sizeof (struct hsr_sup_payload ) + +sizeof (struct hsr_sup_tlv ); - skb =hsr_init_skb (master,0 ); + skb =hsr_init_skb (master, extra);if (!skb) {netdev_warn_once (master->dev,"PRP: Could not send supervision frame\n" );return ;
@@ -393,9 +404,25 @@ static void send_prp_supervision_frame(struct hsr_port *master, hsr_stag->tlv.HSR_TLV_type =PRP_TLV_LIFE_CHECK_DD ; hsr_stag->tlv.HSR_TLV_length =sizeof (struct hsr_sup_payload ); -/* Payload: MacAddressA */ +/* Payload: MacAddressA, the announced node. */ hsr_sp =skb_put (skb,sizeof (struct hsr_sup_payload )); -ether_addr_copy (hsr_sp->macaddress_A, master->dev->dev_addr); +ether_addr_copy (hsr_sp->macaddress_A, addr); + +/* Proxy-announce: append the RedBox-MAC TLV (Type 30) and an explicit +* EOT to terminate the TLV chain before zero padding. +*/ +if (redbox_proxy) { + hsr_stlv =skb_put (skb,sizeof (struct hsr_sup_tlv )); + hsr_stlv->HSR_TLV_type =PRP_TLV_REDBOX_MAC ; + hsr_stlv->HSR_TLV_length =sizeof (struct hsr_sup_payload ); + + hsr_sp =skb_put (skb,sizeof (struct hsr_sup_payload )); +ether_addr_copy (hsr_sp->macaddress_A, hsr->macaddress_redbox); + + hsr_stlv =skb_put (skb,sizeof (struct hsr_sup_tlv )); + hsr_stlv->HSR_TLV_type =HSR_TLV_EOT ; + hsr_stlv->HSR_TLV_length =0 ; + }if (skb_put_padto (skb,ETH_ZLEN )) {spin_unlock_bh (&hsr->seqnr_lock);
net/hsr/hsr_framereg.c +11 -2
@@ -293,8 +293,17 @@ struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,*/ if (ethhdr->h_proto ==htons (ETH_P_PRP ) || ethhdr->h_proto ==htons (ETH_P_HSR )) { -/* Check if skb contains hsr_ethhdr */ -if (skb->mac_len <sizeof (struct hsr_ethhdr )) +bool prp_sup; + +/* A PRP supervision frame is an untagged ETH_P_PRP frame +* (mac_len == ETH_HLEN); its RCT is appended only on egress. +* HSR (ETH_P_HSR) supervision is front-tagged and still must +* contain a struct hsr_ethhdr. +*/ + prp_sup = hsr->prot_version ==PRP_V1 && + ethhdr->h_proto ==htons (ETH_P_PRP ) && is_sup; + +if (!prp_sup && skb->mac_len <sizeof (struct hsr_ethhdr ))return NULL ; }else { rct =skb_get_PRP_rct (skb);
net/hsr/hsr_main.h +1 -1
@@ -211,7 +211,7 @@ struct hsr_priv {*/ bool fwd_offloaded;/* Forwarding offloaded to HW */ bool redbox;/* Device supports HSR RedBox */ -unsigned char macaddress_redbox[ETH_ALEN ]; +unsigned char macaddress_redbox[ETH_ALEN ]__aligned(sizeof(u16)) ;unsigned char sup_multicast_addr[ETH_ALEN ]__aligned(sizeof(u16)) ;/* Align to u16 boundary to avoid unaligned access * in ether_addr_equal
Signature · 1 line
2.53.0
PATCH v2 3/4 net: hsr: allow PRP RedBox (interlink) creation
In reply to Xin XieWith the PRP interlink datapath, duplicate discard and supervision support in place, a PRP device can act as a RedBox. Remove the rtnetlink rejection of "type hsr ... interlink <dev> proto 1"; the feature is implemented unconditionally by the preceding patches.
--- net/hsr/hsr_netlink.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
net/hsr/hsr_netlink.c +1 -7
@@ -121,14 +121,8 @@ static int hsr_newlink(struct net_device *dev, } } -if (proto ==HSR_PROTOCOL_PRP ) { +if (proto ==HSR_PROTOCOL_PRP ) proto_version =PRP_V1 ; -if (interlink) { -NL_SET_ERR_MSG_MOD (extack, -"Interlink only works with HSR" ); -return -EINVAL ; - } - }return hsr_dev_finalize (dev, link, interlink, multicast_spec, proto_version, extack);
Signature · 1 line
2.53.0
PATCH v2 4/4 selftests: net: hsr: add PRP RedBox test
In reply to Xin XieAdd a kselftest that builds a PRP RedBox (interlink) with a SAN behind the interlink and a peer DANP, and checks bidirectional unicast across the interlink, preservation of the SAN source MAC on the PRP network, and that the proxy-announce supervision frame carries the RedBox-MAC TLV (Type 30) terminated by an EOT marker. It reuses the hsr_common.sh / lib.sh helpers and skips cleanly on a kernel or iproute2 without PRP interlink support.
The background ping is killed by its exact PID: ip netns exec does not isolate the PID namespace, so a pattern-based pkill could hit unrelated processes on the host.
--- tools/testing/selftests/net/hsr/Makefile | 1 + .../selftests/net/hsr/hsr_prp_redbox.sh | 99 +++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100755 tools/testing/selftests/net/hsr/hsr_prp_redbox.sh
tools/testing/selftests/net/hsr/Makefile +1 -0
@@ -4,6 +4,7 @@ top_srcdir = ../../../../.. TEST_PROGS := \ hsr_ping.sh \ + hsr_prp_redbox.sh \ hsr_redbox.sh \ link_faults.sh \ prp_ping.sh \
tools/testing/selftests/net/hsr/hsr_prp_redbox.sh new file +99 -0
99 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH net-next v2 1/4] net: hsr: add PRP interlink (RedBox) datapath and duplicate discard
In reply to Xin XieQuoted 90 lines · Xin Xie
A PRP RedBox proxies SANs that sit behind an interlink port: their frames must reach the PRP network with the SAN source MAC preserved, and PRP unicast must be steered between the LAN and the SAN segment correctly.
Add the PRP interlink forwarding rules to
prp_drop_frame()and give RedBox nodes a second duplicate-discard slot so the two LAN copies of a frame destined to a SAN collapse to a single delivery out the interlink.The destination classification (is the unicast DA a PRP-network node or a proxied SAN) is resolved once per frame in
fill_frame_info(), gated to PRP RedBox devices, and cached in structhsr_frame_info, soprp_drop_frame()stays O(1) and does not walk the node tables for every candidate egress port in the softIRQ path. HSR RedBox frame classification is untouched.Factor the LAN A/B duplicate test into
prp_is_lan_dup()so the new PRP interlink rules do not changehsr_drop_frame()behaviour, including theNETIF_F_HW_HSR_FWDpath which keeps using the LAN-duplicate test only.Publish the RedBox state before the first
hsr_add_port(): the slave and interlink rx handlers are live fromhsr_add_port()on and rtnl does not stop softirq processing, so a frame could otherwise be handled whilehsr->redboxis still false.hsr_add_node()sizes each node's per-port sequence state fromhsr->redbox; a node learned in that window would get a single-port sequence block, breaking the interlink duplicate discard (WARN_ON_ONCEplus duplicate delivery to the SAN) and letting the supervision sequence-block merge read beyond the source node's allocated sequence bitmap. Publishing the flag before any port exists makes the per-node sizing uniform by construction. This is safe: the proxy announce timer is only armed fromhsr_check_announce()once the master is running, the packet-path readers ofhsr->redboxtolerate an empty proxy node database and an absent interlink port, and theprune_proxy_timeris still armed only after the interlink port has been attached successfully.Additionally bound the supervision sequence-block merge by the smaller of the two nodes'
seq_port_cntas defense in depth against mismatched node sizes.Signed-off-by Xin Xie <[email protected]>net/hsr/hsr_device.c +9
-2@@ -768,6 +768,15 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],/* Make sure the 1st call to netif_carrier_on() gets through */ netif_carrier_off (hsr_dev); +/* Publish the RedBox state before any port is attached: the rx +* handlers are live from hsr_add_port() on, and hsr_add_node() +* sizes each node's per-port sequence state from hsr->redbox. +*/ +if (interlink) { + hsr->redbox = true; +ether_addr_copy (hsr->macaddress_redbox, interlink->dev_addr); + } + res =hsr_add_port (hsr, hsr_dev,HSR_PT_MASTER , extack);if (res) goto err_add_master;@@ -805,8 +814,6 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],if (res) goto err_unregister; - hsr->redbox = true; -ether_addr_copy (hsr->macaddress_redbox, interlink->dev_addr);mod_timer (&hsr->prune_proxy_timer, jiffies +msecs_to_jiffies (PRUNE_PROXY_PERIOD )); }net/hsr/hsr_forward.c +9
-2@@ -440,12 +440,37 @@ static int hsr_xmit(struct sk_buff *skb, struct hsr_port *port,return dev_queue_xmit (skb); } +static bool prp_is_lan_dup (struct hsr_frame_info *frame, +struct hsr_port *port) +{ +enum hsr_port_type rx = frame->port_rcv->type; + +return (rx ==HSR_PT_SLAVE_A && port->type ==HSR_PT_SLAVE_B ) || + (rx ==HSR_PT_SLAVE_B && port->type ==HSR_PT_SLAVE_A ); +} +bool prp_drop_frame (struct hsr_frame_info *frame,struct hsr_port *port) { - return ((frame->port_rcv->type == HSR_PT_SLAVE_A && - port->type == HSR_PT_SLAVE_B) ||
net/hsr/hsr_forward.c static int hsr_xmit(struct sk_buff *skb, struct hsr_port *port, · line 461
Quoted 10 lines
net/hsr/hsr_forward.c +8
-2- (frame->port_rcv->type ==HSR_PT_SLAVE_B && - port->type == HSR_PT_SLAVE_A)); +enum hsr_port_type rx = frame->port_rcv->type; + +/* Supervision frames are not delivered to a SAN on the interlink. */ +if (frame->is_supervision && port->type ==HSR_PT_INTERLINK ) +return true; + +if (prp_is_lan_dup (frame, port)) +return true;
Since we already have rx (enum hsr_port_type) here, can we pass this directly to prp_is_lan_dup() function instead of passing frame?
Quoted 16 lines
net/hsr/hsr_forward.c +12
-0+ +/* LAN to interlink: keep PRP-network unicast off the SAN segment. */ +if ((rx ==HSR_PT_SLAVE_A || rx ==HSR_PT_SLAVE_B ) && + port->type ==HSR_PT_INTERLINK ) +return frame->dst_in_node_db; + +/* Interlink to LAN: keep SAN-to-SAN unicast local. */ +if ((port->type ==HSR_PT_SLAVE_A || port->type ==HSR_PT_SLAVE_B ) && + rx ==HSR_PT_INTERLINK ) +return frame->dst_in_proxy_node_db; + +return false; }bool hsr_drop_frame (struct hsr_frame_info *frame,struct hsr_port *port)
net/hsr/hsr_forward.c bool hsr_drop_frame(struct hsr_frame_info *frame, struct hsr_port *port) · line 482
Quoted 6 lines
net/hsr/hsr_forward.c +1
-1@@ -453,7 +478,7 @@ bool hsr_drop_frame(struct hsr_frame_info *frame, struct hsr_port *port)struct sk_buff *skb;if (port->dev->features &NETIF_F_HW_HSR_FWD ) -return prp_drop_frame (frame, port); +return prp_is_lan_dup (frame, port);
Of course these calls will need to pass rx too.
Re: [PATCH net-next v2 2/4] net: hsr: emit RedBox-MAC TLV in PRP RedBox supervision frames
In reply to Xin XieQuoted 108 lines · Xin Xie
A PRP RedBox must announce the SANs it proxies so peers populate their proxy node tables. The proxy-announce machinery (
hsr_proxy_announce(), armed viahsr->redbox) already iteratesproxy_node_dbunder RCU and callssend_sv_frame()once per SAN, but the PRP sender emitted neither the announced SAN MAC nor the RedBox-MAC TLV that IEC 62439-3 requires.Extend
send_prp_supervision_frame()so that, for a proxy-announce (identified by the interlink port, an O(1) test), the frame carries the proxied SAN MAC as MacAddressA followed by the RedBox-MAC TLV (Type 30) and an explicit End-of-TLV marker before padding.
hsr_get_node()must also accept the reinjected proxy-announce: a PRP supervision frame is an untaggedETH_P_PRPframe (mac_len==ETH_HLEN, the RCT is appended only on egress) sourced frommacaddress_redbox, which is never learned from data. Exempt only PRP supervision frames from thehsr_ethhdrlength guard; HSR (ETH_P_HSR) supervision is front-tagged and keeps the original guard, so HSR malformed-frame filtering is unchanged.Also align
macaddress_redboxso thatether_addr_copy()andether_addr_equal()on it are safe on architectures without efficient unaligned access.Signed-off-by Xin Xie <[email protected]>net/hsr/hsr_device.c +30
-3@@ -372,10 +372,21 @@ static void send_prp_supervision_frame(struct hsr_port *master, {struct hsr_priv *hsr = master->hsr;struct hsr_sup_payload *hsr_sp; +struct hsr_sup_tlv *hsr_stlv;struct hsr_sup_tag *hsr_stag;struct sk_buff *skb; +bool redbox_proxy; +int extra =0 ; + + redbox_proxy = hsr->redbox && master->type ==HSR_PT_INTERLINK ; + +/* A proxy-announce carries a RedBox-MAC TLV and an EOT marker. */ +if (redbox_proxy) + extra =sizeof (struct hsr_sup_tlv ) + +sizeof (struct hsr_sup_payload ) + +sizeof (struct hsr_sup_tlv ); - skb =hsr_init_skb (master,0 ); + skb =hsr_init_skb (master, extra);if (!skb) {netdev_warn_once (master->dev,"PRP: Could not send supervision frame\n" );return ;@@ -393,9 +404,25 @@ static void send_prp_supervision_frame(struct hsr_port *master, hsr_stag->tlv.HSR_TLV_type =PRP_TLV_LIFE_CHECK_DD ; hsr_stag->tlv.HSR_TLV_length =sizeof (struct hsr_sup_payload ); -/* Payload: MacAddressA */ +/* Payload: MacAddressA, the announced node. */ hsr_sp =skb_put (skb,sizeof (struct hsr_sup_payload )); -ether_addr_copy (hsr_sp->macaddress_A, master->dev->dev_addr); +ether_addr_copy (hsr_sp->macaddress_A, addr); + +/* Proxy-announce: append the RedBox-MAC TLV (Type 30) and an explicit +* EOT to terminate the TLV chain before zero padding. +*/ +if (redbox_proxy) { + hsr_stlv =skb_put (skb,sizeof (struct hsr_sup_tlv )); + hsr_stlv->HSR_TLV_type =PRP_TLV_REDBOX_MAC ; + hsr_stlv->HSR_TLV_length =sizeof (struct hsr_sup_payload ); + + hsr_sp =skb_put (skb,sizeof (struct hsr_sup_payload )); +ether_addr_copy (hsr_sp->macaddress_A, hsr->macaddress_redbox); + + hsr_stlv =skb_put (skb,sizeof (struct hsr_sup_tlv )); + hsr_stlv->HSR_TLV_type =HSR_TLV_EOT ; + hsr_stlv->HSR_TLV_length =0 ; + }if (skb_put_padto (skb,ETH_ZLEN )) {spin_unlock_bh (&hsr->seqnr_lock);net/hsr/hsr_framereg.c +11
-2@@ -293,8 +293,17 @@ struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,*/ if (ethhdr->h_proto ==htons (ETH_P_PRP ) || ethhdr->h_proto ==htons (ETH_P_HSR )) { -/* Check if skb contains hsr_ethhdr */ -if (skb->mac_len <sizeof (struct hsr_ethhdr )) +bool prp_sup; + +/* A PRP supervision frame is an untagged ETH_P_PRP frame +* (mac_len == ETH_HLEN); its RCT is appended only on egress. +* HSR (ETH_P_HSR) supervision is front-tagged and still must +* contain a struct hsr_ethhdr. +*/ + prp_sup = hsr->prot_version ==PRP_V1 && + ethhdr->h_proto ==htons (ETH_P_PRP ) && is_sup; + +if (!prp_sup && skb->mac_len <sizeof (struct hsr_ethhdr ))return NULL ; }else { rct =skb_get_PRP_rct (skb);net/hsr/hsr_main.h +0
-0
net/hsr/hsr_main.h struct hsr_priv { · line 214
Quoted 5 lines
net/hsr/hsr_main.h +1
-1@@ -211,7 +211,7 @@ struct hsr_priv {*/ bool fwd_offloaded;/* Forwarding offloaded to HW */ bool redbox;/* Device supports HSR RedBox */ -unsigned char macaddress_redbox[ETH_ALEN ]; +unsigned char macaddress_redbox[ETH_ALEN ]__aligned(sizeof(u16)) ;
The indentation is wrong here, could you keep at the same level it was before?
Quoted 58 lines · Xin Xie
This series adds PRP RedBox support to the hsr driver: a PRP node that proxies one or more SANs sitting behind an interlink port (IEC 62439-3, PRP-SAN). HSR-SAN has been supported since commit
5055cccfc2d1("net: hsr:
Provide RedBox support (HSR-SAN)"); this extends the equivalent capability to PRP, reusing the existing protocol-neutral proxy machinery (proxy_node_db,hsr_proxy_announce(),hsr_prune_proxy_nodes()).A SAN behind the interlink does bidirectional unicast with peers on the PRP network, its source MAC is preserved on the wire, the PRP RCT is correct, and the RedBox announces each proxied SAN with the RedBox-MAC TLV (Type 30) in its supervision frames.
The series is bisect-safe: the datapath, duplicate discard and supervision support are added first; the rtnetlink rejection of "type hsr ... interlink <dev> proto 1" is removed only in patch 3, once the feature is complete.
Design notes:
-
prp_drop_frame()does not walk the node tables. The destination classification (PRP-network node vs proxied SAN) is resolved once per frame infill_frame_info()and cached in structhsr_frame_info, so the per egress-port drop decision is O(1) in the softIRQ path. The classification is gated on PRP RedBox devices (prot_version==PRP_V1&&hsr->redbox), so HSR RedBox traffic is not affected.- The LAN A/B duplicate test is factored into
prp_is_lan_dup()so the new PRP interlink rules inprp_drop_frame()do not changehsr_drop_frame()behaviour, including theNETIF_F_HW_HSR_FWDpath. This is software PRP RedBox only; it adds no new hardware-offload contract.- The supervision emitter uses pre-reserved tailroom (
hsr_init_skb()+skb_put()) on the existingGFP_ATOMICpath; noskb_linearize()orpskb_expand_head(). The RedBox-MAC TLV is followed by an explicit EOT (Type 0, Length 0); padding viaskb_put_padto(ETH_ZLEN)and the 6-byte PRP RCT remain at the absolute tail of the egress frame.- The
hsr_get_node()hsr_ethhdrlength guard is relaxed only for PRP supervision frames (prot_version==PRP_V1&Ð_P_PRP&&is_sup), which are untagged withmac_len==ETH_HLEN. HSR (ETH_P_HSR) supervision is front-tagged and keeps the original length requirement, so HSR malformed-frame filtering is unchanged.Testing (on a net-next v7.2-rc1 kernel built from this base, x86-64):
- checkpatch.pl --strict: patches 1-3 clean; patch 4 reports only the expected "added file(s), doesMAINTAINERSneed updating?" note, which is ignorable here --MAINTAINERSalready liststools/testing/selftests/net/hsr/under HSR NETWORK PROTOCOL.
- git diff --check clean; the series git-am's onto the base commit.
-tools/testing/selftests/net/hsr/hsr_prp_redbox.sh: PASS on the patched kernel (bidirectional unicast, SAN MAC preservation, RedBox-MAC TLV + EOT in the proxy-announce).
- HSR regression on the same kernel:hsr_redbox.sh(HSR-SAN/RedBox),hsr_ping.shandprp_ping.shall PASS, confirming the PRP changes do not regress the existing HSR/PRP paths.
- netns checks: peer<->SAN 0% loss with no duplicates and a valid PRP RCT on the wire; a silent SAN is pruned from the announce; zero driver WARN/BUG/Oops/RCU-stall during the run.
Quoted 17 lines
Beyond the in-tree selftest, this exact series (applied to this base and running as the net-next kernel on x86-64 hardware) was also validated with an out-of-tree IEC 62439-3 conformance harness (supervision TLV chain, duplicate discard, cross-LAN rejection, seqnr rollover, VLAN/multicast/GOOSE frame types with the RCT verified at the absolute frame tail), and interoperability-tested against a commercial PRP RedBox (Siemens SCALANCE X204RNA) over 100 Mbit/s Fast Ethernet with NIC hardware (PTP) timestamping: a mid-stream single-LAN outage of ~2 s at 10 kpps was bridged with zero lost and zero duplicate frames (seamless PRP failover), and the duplicate-discard window held zero lost / zero duplicates under netem asymmetric delay up to 100 ms (~1000 sequence numbers in flight), 25% reorder, and 5% single-LAN loss. The failover and impairment matrix was additionally repeated on a KASAN + lockdep + kmemleak instrumented build of this kernel, including a 72-carrier-event link flap-storm with deliberate double-LAN cuts: zero KASAN, lockdep, or kmemleak findings. This out-of-tree testing is supplementary and not required to evaluate the series.
The series looks good to me, I just found a couple of nits.
Thank you!
Quoted 77 lines · Fernando Fernandez Mancera
Quoted 58 lines · Xin Xie
This series adds PRP RedBox support to the hsr driver: a PRP node that proxies one or more SANs sitting behind an interlink port (IEC 62439-3, PRP-SAN). HSR-SAN has been supported since commit
5055cccfc2d1("net: hsr:
Provide RedBox support (HSR-SAN)"); this extends the equivalent capability to PRP, reusing the existing protocol-neutral proxy machinery (proxy_node_db,hsr_proxy_announce(),hsr_prune_proxy_nodes()).A SAN behind the interlink does bidirectional unicast with peers on the PRP network, its source MAC is preserved on the wire, the PRP RCT is correct, and the RedBox announces each proxied SAN with the RedBox-MAC TLV (Type 30) in its supervision frames.
The series is bisect-safe: the datapath, duplicate discard and supervision support are added first; the rtnetlink rejection of "type hsr ... interlink <dev> proto 1" is removed only in patch 3, once the feature is complete.
Design notes:
-
prp_drop_frame()does not walk the node tables. The destination classification (PRP-network node vs proxied SAN) is resolved once per frame infill_frame_info()and cached in structhsr_frame_info, so the per egress-port drop decision is O(1) in the softIRQ path. The classification is gated on PRP RedBox devices (prot_version==PRP_V1&&hsr->redbox), so HSR RedBox traffic is not affected.- The LAN A/B duplicate test is factored into
prp_is_lan_dup()so the new PRP interlink rules inprp_drop_frame()do not changehsr_drop_frame()behaviour, including theNETIF_F_HW_HSR_FWDpath. This is software PRP RedBox only; it adds no new hardware-offload contract.- The supervision emitter uses pre-reserved tailroom (
hsr_init_skb()+skb_put()) on the existingGFP_ATOMICpath; noskb_linearize()orpskb_expand_head(). The RedBox-MAC TLV is followed by an explicit EOT (Type 0, Length 0); padding viaskb_put_padto(ETH_ZLEN)and the 6-byte PRP RCT remain at the absolute tail of the egress frame.- The
hsr_get_node()hsr_ethhdrlength guard is relaxed only for PRP supervision frames (prot_version==PRP_V1&Ð_P_PRP&&is_sup), which are untagged withmac_len==ETH_HLEN. HSR (ETH_P_HSR) supervision is front-tagged and keeps the original length requirement, so HSR malformed-frame filtering is unchanged.Testing (on a net-next v7.2-rc1 kernel built from this base, x86-64):
- checkpatch.pl --strict: patches 1-3 clean; patch 4 reports only the expected "added file(s), doesMAINTAINERSneed updating?" note, which is ignorable here --MAINTAINERSalready liststools/testing/selftests/net/hsr/under HSR NETWORK PROTOCOL.
- git diff --check clean; the series git-am's onto the base commit.
-tools/testing/selftests/net/hsr/hsr_prp_redbox.sh: PASS on the patched kernel (bidirectional unicast, SAN MAC preservation, RedBox-MAC TLV + EOT in the proxy-announce).
- HSR regression on the same kernel:hsr_redbox.sh(HSR-SAN/RedBox),hsr_ping.shandprp_ping.shall PASS, confirming the PRP changes do not regress the existing HSR/PRP paths.
- netns checks: peer<->SAN 0% loss with no duplicates and a valid PRP RCT on the wire; a silent SAN is pruned from the announce; zero driver WARN/BUG/Oops/RCU-stall during the run.Quoted 17 lines
Beyond the in-tree selftest, this exact series (applied to this base and running as the net-next kernel on x86-64 hardware) was also validated with an out-of-tree IEC 62439-3 conformance harness (supervision TLV chain, duplicate discard, cross-LAN rejection, seqnr rollover, VLAN/multicast/GOOSE frame types with the RCT verified at the absolute frame tail), and interoperability-tested against a commercial PRP RedBox (Siemens SCALANCE X204RNA) over 100 Mbit/s Fast Ethernet with NIC hardware (PTP) timestamping: a mid-stream single-LAN outage of ~2 s at 10 kpps was bridged with zero lost and zero duplicate frames (seamless PRP failover), and the duplicate-discard window held zero lost / zero duplicates under netem asymmetric delay up to 100 ms (~1000 sequence numbers in flight), 25% reorder, and 5% single-LAN loss. The failover and impairment matrix was additionally repeated on a KASAN + lockdep + kmemleak instrumented build of this kernel, including a 72-carrier-event link flap-storm with deliberate double-LAN cuts: zero KASAN, lockdep, or kmemleak findings. This out-of-tree testing is supplementary and not required to evaluate the series.
Quoted 3 lines
The series looks good to me, I just found a couple of nits.
Thank you!
Oh I just realized you posted a v3 - anyway, as there were no changes my comments also apply there.
Thanks,
Fernando.
Re: [PATCH net-next v2 1/4] net: hsr: add PRP interlink (RedBox) datapath and duplicate discard
In reply to Fernando Fernandez ManceraQuoted 4 lines · Fernando Fernandez Mancera
Since we already have rx (enum
hsr_port_type) here, can we pass this directly toprp_is_lan_dup()function instead of passing frame?Of course these calls will need to pass rx too.
Yes, that is cleaner. Will change it in v4.
Thanks for the review!
Xin
Re: [PATCH net-next v2 2/4] net: hsr: emit RedBox-MAC TLV in PRP RedBox supervision frames
In reply to Fernando Fernandez ManceraQuoted 2 lines · Fernando Fernandez Mancera
The indentation is wrong here, could you keep at the same level it was before?
Sure, will restore the original indentation in v4.
Thanks,
Xin