From nobody Sat Jul 25 04:53:33 2026 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6B5D392802 for ; Fri, 17 Jul 2026 20:15:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784319307; cv=none; b=dsaORA8IiykJz+2gS8pblL6KZiJ8q4p5g7vPAR/HNr1Ve8/LPN48zdXxb1e9u9/JwYMhjiWbN/L6XWdo63qcXd/9P1oTUWehdkPeBDxkoes8pnDHHHNzqst+M3tdP3xZpzhVs72fwxnUrEcLhqMh4eC0e2sF42sdZlfgAVYbAX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784319307; c=relaxed/simple; bh=oR/ROjLKlRFIjhcEbnpOOPpnmoD1Kqh0yynfxGlnces=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DIU6R2hSLOsFNiouYf2COmUel6WJqqvHXinWLmz8V1YDl00bdVAqqo8k2G3aNih2QmViCAofyvzDMO6p3S/cKGxJLZnx3YZh9KsZ/wN/SGyu800MfgVzx4RjQxrz/B7v/nD7FShS6xQzIWQoHBBRPXV2qVflkIau8IzAQX8cL9Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CrWeYEZY; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CrWeYEZY" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4953f64372aso3993475e9.0 for ; Fri, 17 Jul 2026 13:15:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784319303; x=1784924103; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Bp5Pw0SQqVz4tkHO7oYKinMfNGqk277KjrMzF7qehWA=; b=CrWeYEZY0wwjbpMInyRRlJDwvr5ZduiAJ98djn8tBpwheH5LStqvBYEq/4tAor/oCp sJbI/gXJ5Ah6DQHD3Wc4W5vG6i7PfNre1RpRgWlDN1KKZtIsFWNaXolqfY/S8quhNYW4 tRsFp0BN3Nv46yA183JYJt1ZdsezqoPDHPHEEeRB+HpPi14RWkaIOMQvmbNgfWTfgDWo Uw6Xn2dc7tsJkCfnZmXk5SEslQ3lU2IsXBMYEct6ful19x2tb8oTJEL/GCQ2VxVsMnuA VAsaSs8hI/HlQyFYipo5wu+vSBKuna/dDLqSWRTH9snPFb2hSE2aIK3yc8JQ2DhSjXfZ EF2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784319303; x=1784924103; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Bp5Pw0SQqVz4tkHO7oYKinMfNGqk277KjrMzF7qehWA=; b=OaNgeBWGwZMopkGDIclv2AydhOs6QRRcRGV97flDTT81XrlAqe/XpNPP82HR6V62p9 gzTLIuC+Rm9IAHdhhhb2StUnhEX55SmxtXJsz9/5AZONphaeczfJa+Q4JR7TBXMAm4oe IwB2vsOfDW0BlhXO9CovxOjHyqiWbEUsa96PpDpCgoi/3se4X8KVEv8q+OF6ywaagJCk NJdB2n6osIL1nI6xKzK/M5ummMOzOjoc4KuT9YvMmAj+q7K7UBaSkhHhTwuXdmzjA2AV b6XKJ50gpVmo28PI1Yr/0Tpggoy0INn8veS/WjxqNq0zu+g9LW1hwRePaNVoAIg8/c3U xXcA== X-Forwarded-Encrypted: i=1; AHgh+RqYFhk+ytXeQiCgfzc+QlDMlP0Nd6jARQA3PhhsSNuAbsQ9F1PSeMugWnYEAAV9YTmIOhE+hwDHf9AVHKM=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5lhjZ1DsDg0GHuU6XXahMbL5OC5NcGbgdK5NkUkr+WA7qub1g VYDRAt92lExYCX9b1Ptwk6tz44qj/My4atUhlMY5uZ3QE64azD0P1SrMyLPsME8m X-Gm-Gg: AfdE7cmTMXHl90g7GssH/BbvVo+pkYJYb1SQ2Cp/Toa8ojiFbwCAuWZshqFmFAbJGQS lt+92yDv//NKHMgY5HXqa++w+mzpAk7ZDMsaxGOiy08a2i9INLk6hgy4/alYwPOB3kNF0xeVD5Y Hv3nWBw6TiPAMZZthkR1vG5Pzr2SLp2PNw2cuYTWW5gqNaK89YubYOtV7CAOTAErtnsVqlmCAiJ PNVLhWoEylE9/jS1ewgULGZQoojfbnUw+kg3xovYLomySO+MQ59Yi5eGKWKNbpMZ7Z8R7oC2Myw A0YDRfwCT+ag8ul5+ktQojl+/tGhmGpeGoIED4WW6jGYc5BlWipXk/viIY6gXd99BpBpG9hnDOC xTlMXNFPGwjfnRsZrnbCQt7BM88h2FOOFt2sPHAXkZosTBcCPuTTiODzpBsoxwRA512y3LmYolj X7ZNbWZXfhtSSdEVK96gMBv2Tkq/p+hjEUI/MYoFsqCy8QtB4qL/vApM1JiyvvRFEmOzuaRhFHi BTOiNykc66TXitjvhQhlWxVUvZO3X/y7ZJPerM6WLhIK4lNLA== X-Received: by 2002:a05:600c:b8d:b0:493:b6a2:858d with SMTP id 5b1f17b1804b1-4954a51321cmr27185195e9.6.1784319302354; Fri, 17 Jul 2026 13:15:02 -0700 (PDT) Received: from L-022584.energy.envision.com (dynamic-077-179-077-126.77.179.pool.telefonica.de. [77.179.77.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-495499a5847sm53179335e9.2.2026.07.17.13.15.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 13:15:01 -0700 (PDT) From: Xin Xie To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, wsa+renesas@sang-engineering.com, jie.luo@oss.qualcomm.com, shuah@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, fmancera@suse.de, bigeasy@linutronix.de, fmaurer@redhat.com, luka.gejak@linux.dev, Xin Xie Subject: [PATCH net-next v4 1/4] net: hsr: add PRP interlink (RedBox) datapath and duplicate discard Date: Fri, 17 Jul 2026 22:14:54 +0200 Message-ID: <20260717201457.54-2-xiexinet@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260717201457.54-1-xiexinet@gmail.com> References: <20260717201457.54-1-xiexinet@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Xin Xie --- net/hsr/hsr_device.c | 11 ++++++++-- net/hsr/hsr_forward.c | 46 ++++++++++++++++++++++++++++++++++++------ net/hsr/hsr_framereg.c | 14 +++++++++---- net/hsr/hsr_framereg.h | 2 ++ 4 files changed, 61 insertions(+), 12 deletions(-) diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 5555b71ab19..5af491ed2b7 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -768,6 +768,15 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struc= t net_device *slave[2], /* Make sure the 1st call to netif_carrier_on() gets through */ netif_carrier_off(hsr_dev); =20 + /* 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 =3D true; + ether_addr_copy(hsr->macaddress_redbox, interlink->dev_addr); + } + res =3D 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; =20 - hsr->redbox =3D true; - ether_addr_copy(hsr->macaddress_redbox, interlink->dev_addr); mod_timer(&hsr->prune_proxy_timer, jiffies + msecs_to_jiffies(PRUNE_PROXY_PERIOD)); } diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c index 0774981a65c..7734a521a96 100644 --- a/net/hsr/hsr_forward.c +++ b/net/hsr/hsr_forward.c @@ -440,12 +440,34 @@ static int hsr_xmit(struct sk_buff *skb, struct hsr_p= ort *port, return dev_queue_xmit(skb); } =20 +static bool prp_is_lan_dup(enum hsr_port_type rx, struct hsr_port *port) +{ + return (rx =3D=3D HSR_PT_SLAVE_A && port->type =3D=3D HSR_PT_SLAVE_B) || + (rx =3D=3D HSR_PT_SLAVE_B && port->type =3D=3D HSR_PT_SLAVE_A); +} + bool prp_drop_frame(struct hsr_frame_info *frame, struct hsr_port *port) { - return ((frame->port_rcv->type =3D=3D HSR_PT_SLAVE_A && - port->type =3D=3D HSR_PT_SLAVE_B) || - (frame->port_rcv->type =3D=3D HSR_PT_SLAVE_B && - port->type =3D=3D HSR_PT_SLAVE_A)); + enum hsr_port_type rx =3D frame->port_rcv->type; + + /* Supervision frames are not delivered to a SAN on the interlink. */ + if (frame->is_supervision && port->type =3D=3D HSR_PT_INTERLINK) + return true; + + if (prp_is_lan_dup(rx, port)) + return true; + + /* LAN to interlink: keep PRP-network unicast off the SAN segment. */ + if ((rx =3D=3D HSR_PT_SLAVE_A || rx =3D=3D HSR_PT_SLAVE_B) && + port->type =3D=3D HSR_PT_INTERLINK) + return frame->dst_in_node_db; + + /* Interlink to LAN: keep SAN-to-SAN unicast local. */ + if ((port->type =3D=3D HSR_PT_SLAVE_A || port->type =3D=3D HSR_PT_SLAVE_B= ) && + rx =3D=3D HSR_PT_INTERLINK) + return frame->dst_in_proxy_node_db; + + return false; } =20 bool hsr_drop_frame(struct hsr_frame_info *frame, struct hsr_port *port) @@ -453,7 +475,7 @@ bool hsr_drop_frame(struct hsr_frame_info *frame, struc= t hsr_port *port) struct sk_buff *skb; =20 if (port->dev->features & NETIF_F_HW_HSR_FWD) - return prp_drop_frame(frame, port); + return prp_is_lan_dup(frame->port_rcv->type, port); =20 /* RedBox specific frames dropping policies * @@ -466,7 +488,7 @@ bool hsr_drop_frame(struct hsr_frame_info *frame, struc= t hsr_port *port) * are addressed to interlink port (and are in the ProxyNodeTable). */ skb =3D frame->skb_hsr; - if (skb && prp_drop_frame(frame, port) && + if (skb && prp_is_lan_dup(frame->port_rcv->type, 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 +728,18 @@ static int fill_frame_info(struct hsr_frame_info *fram= e, frame->is_vlan =3D false; proto =3D ethhdr->h_proto; =20 + /* 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 =3D=3D PRP_V1 && hsr->redbox && + is_unicast_ether_addr(ethhdr->h_dest)) { + frame->dst_in_node_db =3D + hsr_is_node_in_db(&hsr->node_db, ethhdr->h_dest); + frame->dst_in_proxy_node_db =3D + hsr_is_node_in_db(&hsr->proxy_node_db, ethhdr->h_dest); + } + if (proto =3D=3D htons(ETH_P_8021Q)) frame->is_vlan =3D true; =20 diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c index e4492987127..8f708b6e6c3 100644 --- a/net/hsr/hsr_framereg.c +++ b/net/hsr/hsr_framereg.c @@ -199,7 +199,7 @@ static struct hsr_node *hsr_add_node(struct hsr_priv *h= sr, spin_lock_init(&new_node->seq_out_lock); =20 if (hsr->prot_version =3D=3D PRP_V1) - new_node->seq_port_cnt =3D 1; + new_node->seq_port_cnt =3D hsr->redbox ? 2 : 1; else new_node->seq_port_cnt =3D HSR_PT_PORTS - 1; =20 @@ -381,6 +381,7 @@ void hsr_handle_sup_frame(struct hsr_frame_info *frame) struct ethhdr *ethhdr; unsigned int total_pull_size =3D 0; unsigned int pull_size =3D 0; + unsigned int seq_port_cnt; unsigned long idx; int i; =20 @@ -474,6 +475,7 @@ void hsr_handle_sup_frame(struct hsr_frame_info *frame) } } =20 + seq_port_cnt =3D 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 =3D min(merge_blk->time, src_blk->time); - for (i =3D 0; i < node_real->seq_port_cnt; i++) { + for (i =3D 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, stru= ct hsr_frame_info *frame) if (frame->port_rcv->type =3D=3D HSR_PT_MASTER) return 0; =20 - /* 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 =3D=3D HSR_PT_INTERLINK) + return hsr_check_duplicate(frame, 1); + + /* For PRP only slave-to-master frames are forwarded. */ if (port->type !=3D HSR_PT_MASTER) return 1; =20 diff --git a/net/hsr/hsr_framereg.h b/net/hsr/hsr_framereg.h index c65ecb92573..127a3fb64d5 100644 --- a/net/hsr/hsr_framereg.h +++ b/net/hsr/hsr_framereg.h @@ -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; }; =20 void hsr_del_self_node(struct hsr_priv *hsr); --=20 2.53.0 From nobody Sat Jul 25 04:53:33 2026 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F2F93955F4 for ; Fri, 17 Jul 2026 20:15:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784319310; cv=none; b=r6/kWVc3NfmaJOzRKlbdfDAtmlp2MuSdUl1uUOLJfkxYhiT6KHNo5rYg5WaJ+/2JQ0XU9E4VZgxaSIW0CxcnrHWmhA+aEHgxwfq5YxDx8ThrjT4sRxAEt/NOfZieVELX+/srqRYBshXotb/EJ0Etu6lUJjcWI0bcu/bqm+Xs1aw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784319310; c=relaxed/simple; bh=PMfdPP8tbxO4rGaiNWWMMR+GuufY3qRT/GwPQyy8FmA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lY+H9mSVcQW2FtYxGHRAnkpR9mbbcieck9x2DixiOZ986t6rwq6vz4fLUb3tlWyLf3+Hx06yigr/Gr2242YlE+EIrVo7J3brMIKXWAwQ6kO2FhXVq0qR4FtSTQt8EMaRbgiNNAGqfYq7LU5yl7PwIeZH1cimLE4OYeByhJYA/KE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=rCJNaLCB; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rCJNaLCB" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-472c021a608so884669f8f.3 for ; Fri, 17 Jul 2026 13:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784319304; x=1784924104; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=KgwWXpWZ5E6B/1xrDcK3wBAQSk4ptg7t74XAEY84UEo=; b=rCJNaLCBkqR06nCMfkwMlJgM7T0VryjOG9PRjzun3dAteZF/ziLA4hFjbzSR9ulPGE TGPpAeM/KKBo7Ql4JqdVVimDvGZNxADf2ueFwwSt0lXdEUb848npv317xSZS9JW5Q6Z3 uPx/0JiGFoDWDK5DWCkcSnDwdYdkhlkT5n2wIhblVZUcsxYLyg6XiT4ry3MfUEfhKbXo A6j9tu1B7enWeTnhMZBdQujj+1kSeMt7wGUYioRjdARiA5IDZm/Wxb2kiPKPAJjFeuAF 8AT13QIdo43Y/ijAuknr16KE/Fn9mfwEQ8VDUXv+LyXotmMU/RPSEmOr9GgpMxXLLE2S YUgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784319304; x=1784924104; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=KgwWXpWZ5E6B/1xrDcK3wBAQSk4ptg7t74XAEY84UEo=; b=Vr6CKILBF2zjMDcgUFbsK7X9/7uad+FwdORblw6pbfh3FJD78bAUY474YeFPGZuUzM Qf7wXzqmSTkc2L8OMfEpmtGhSPWRz2Wsit0hnEVpPAZj01KjKArpAzn0WCHQ1W0KASk5 4yZZj2saVsmqBYAk7Ds6v+zLNfJTB7jZp66uro7ou86VKpx5J5yPGIOsPhHGzoj+rDnI g4NUq9gqZjELw2eW7yHMYowHz9l5q0cw0yIljxBlxrTH7D5KkXZTli6wHZR2qq5z3bxy m9i+x9TNDKImXLLTXp8dmahNKNztIMZl8ck+hS1je+BqpUHVoCfcmoxNeEevGWXOhHFr +1aw== X-Forwarded-Encrypted: i=1; AHgh+RoL1+hmn9IPXL4StkF1UEKyaJ1uCuqtOS+ZS4LCfVzDGdNCruLUrXi1gw/mjXLPZcAMwJfKH0Dmiiwcsnc=@vger.kernel.org X-Gm-Message-State: AOJu0Yyqu0jaAN4Spl1TqQR35ZDVmly7X8eKjBVbXOIikcoRfgnmHkOl bUvFvYquUSZLcqlsaP/KmtnPxwsn+rhKXSw4GnuEz8u+7yrTM6TN2gx4 X-Gm-Gg: AfdE7clmsJoB+CW79HpQrBs6+VZ54s5aLMCp+S3xjpTSZjOpt+gmxtsrjtrjllqJfxb GRfjrguLqF71J792NivlMrlXL+kzE+uoXBbI2eEXlE0SAVRuae1zcY/rtAlfwzl1Y5tv10qkswx leKv+p/fJDUyWPi/cxQIinjIbNgGzxdpdkZjstXSTMTd0h7NgkvHzFwadgVDy9scb4qB2M1HQXP prbO9DGuvyf2/TRJj94MxBqFl4yJmyJkumGqx6c9YYD3WvwOmh86X8N9Gk9jA6x1c5TjXenOy/N umewG2BOlEdKJnlqLJbVMu6HotkTGulWFTE1CKZeDfIELSBxHaPWnetVz4Ncu+v4BJx9VwM7g4R 4C1xUob5WkXV7I/8pGNpsdIOWtqQFSHr0dfuW5sv7VuutaSJaCB1iw4C15OABZgxBGKagdvDa2i 63PVGFlOizJzZ2Ui78SlgxtP5l+DgVMakYhrTf7F9850zHllTLdAX4JYvF/cvPTxmIq8qMBUS7i jTJB7VBBfgkF4joxGptQLwHcr5WKIvrG0GipLo= X-Received: by 2002:a05:600c:1c23:b0:490:846d:4edf with SMTP id 5b1f17b1804b1-4954a3ebc81mr26331675e9.1.1784319304154; Fri, 17 Jul 2026 13:15:04 -0700 (PDT) Received: from L-022584.energy.envision.com (dynamic-077-179-077-126.77.179.pool.telefonica.de. [77.179.77.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-495499a5847sm53179335e9.2.2026.07.17.13.15.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 13:15:03 -0700 (PDT) From: Xin Xie To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, wsa+renesas@sang-engineering.com, jie.luo@oss.qualcomm.com, shuah@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, fmancera@suse.de, bigeasy@linutronix.de, fmaurer@redhat.com, luka.gejak@linux.dev, Xin Xie , Hangbin Liu Subject: [PATCH net-next v4 2/4] net: hsr: emit RedBox-MAC TLV in PRP RedBox supervision frames Date: Fri, 17 Jul 2026 22:14:55 +0200 Message-ID: <20260717201457.54-3-xiexinet@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260717201457.54-1-xiexinet@gmail.com> References: <20260717201457.54-1-xiexinet@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A 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 =3D=3D 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. Signed-off-by: Xin Xie --- 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(-) diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 5af491ed2b7..0973f9a94f4 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -372,10 +372,21 @@ static void send_prp_supervision_frame(struct hsr_por= t *master, { struct hsr_priv *hsr =3D 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 =3D 0; + + redbox_proxy =3D hsr->redbox && master->type =3D=3D HSR_PT_INTERLINK; + + /* A proxy-announce carries a RedBox-MAC TLV and an EOT marker. */ + if (redbox_proxy) + extra =3D sizeof(struct hsr_sup_tlv) + + sizeof(struct hsr_sup_payload) + + sizeof(struct hsr_sup_tlv); =20 - skb =3D hsr_init_skb(master, 0); + skb =3D 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 =3D PRP_TLV_LIFE_CHECK_DD; hsr_stag->tlv.HSR_TLV_length =3D sizeof(struct hsr_sup_payload); =20 - /* Payload: MacAddressA */ + /* Payload: MacAddressA, the announced node. */ hsr_sp =3D 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 =3D skb_put(skb, sizeof(struct hsr_sup_tlv)); + hsr_stlv->HSR_TLV_type =3D PRP_TLV_REDBOX_MAC; + hsr_stlv->HSR_TLV_length =3D sizeof(struct hsr_sup_payload); + + hsr_sp =3D skb_put(skb, sizeof(struct hsr_sup_payload)); + ether_addr_copy(hsr_sp->macaddress_A, hsr->macaddress_redbox); + + hsr_stlv =3D skb_put(skb, sizeof(struct hsr_sup_tlv)); + hsr_stlv->HSR_TLV_type =3D HSR_TLV_EOT; + hsr_stlv->HSR_TLV_length =3D 0; + } =20 if (skb_put_padto(skb, ETH_ZLEN)) { spin_unlock_bh(&hsr->seqnr_lock); diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c index 8f708b6e6c3..b3b106be692 100644 --- a/net/hsr/hsr_framereg.c +++ b/net/hsr/hsr_framereg.c @@ -293,8 +293,17 @@ struct hsr_node *hsr_get_node(struct hsr_port *port, s= truct list_head *node_db, */ if (ethhdr->h_proto =3D=3D htons(ETH_P_PRP) || ethhdr->h_proto =3D=3D 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 =3D=3D 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 =3D hsr->prot_version =3D=3D PRP_V1 && + ethhdr->h_proto =3D=3D htons(ETH_P_PRP) && is_sup; + + if (!prp_sup && skb->mac_len < sizeof(struct hsr_ethhdr)) return NULL; } else { rct =3D skb_get_PRP_rct(skb); diff --git a/net/hsr/hsr_main.h b/net/hsr/hsr_main.h index 134e4f3fff6..53e95bae0ee 100644 --- a/net/hsr/hsr_main.h +++ b/net/hsr/hsr_main.h @@ -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 --=20 2.53.0 From nobody Sat Jul 25 04:53:33 2026 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A26F3914FD for ; Fri, 17 Jul 2026 20:15:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784319311; cv=none; b=dvyJtetjl0DnD6AHy1Hal1AlA0X7SiNUcEXBskvxOVgvZLwAYojI6/b3OsVSWeOstnzrVqIQk6Wr97IwskCxdOvrX0KTMSmNGQ+ZK8GYFa0/aQSiD1diIDsQh1YaPROEpfY+mU6XgFhtfFo1imjxskEMKogPf1Yfpne4Joj9oGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784319311; c=relaxed/simple; bh=fKe70vqmsSB7Sbpqp5Pwa9y18Qh7KEsEmm0Uen+uTFw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OV0jGc9aMWMGo/DSF4K87mGdxPe60F5ewmMlN5PR8VgqJDUhJmTMmYk5wNEJ7Y5KaccxX1ZEs2kj8V7V9qlr9nrpKzPwqfbJ6LqrgvizuZDZda8OiaC90ing+wCX4GLE3qbAHUH6CfLc8my6vCM6thsrvrx8Jc+3y0IlzSAZPPc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DG5YIEJr; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DG5YIEJr" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-4706f016316so542975f8f.3 for ; Fri, 17 Jul 2026 13:15:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784319306; x=1784924106; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=f9VRQMdG5mh4GbPjofS2MPnVG7awxExT5N1bUTExBEM=; b=DG5YIEJrcxqgXQuqgUTeekgqShXDHiGBfC7aElmm2s29YVh5VARPP80eTO1OQuziIJ n0LXuU1OYUen7BA8DgNSFxf34Tw6d2wgRbNWv4KwqIBSK9gH6TqmWKhMa2AGNxEHZlxr WvmX8yByXVD01yVyrWzFFsp4eg1GJdi6LafIv7msdJKpCUGl/Ks4CC3RgaM/ZvR47Tpp gGGHRKkxJMniDBGXbiTWrqcCxzNZ4ntjrPjPtjsdViWeN53ljiTREPbuvMvS1wVqMkRx LbLJvh3zkphxBM6dMXC8OisEFU29jp0r7A4FfDaf1jOEPWBXM6gfIh0PvjIp0ZBDY5jU 7wwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784319306; x=1784924106; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=f9VRQMdG5mh4GbPjofS2MPnVG7awxExT5N1bUTExBEM=; b=AID7SP0uhJ+NvO8YLleG5aR4elnC/UT38smTKy7kM/282bUsym8iVyYBLWyyKrIX4I PtIlmMatOnCAIQOajlajcWOnNYKBvsMiOusXczok7XUWFjhs5PIhm0Stu0GRRYyX7O2b iuMXdKRR60YN4GYe7HkYLYEkNtZ+eXCgEUbUels2/xUPeRzOpquHZfMyeAJ0bwO2IVWk PQ3mU+ImchXj7D52sVir6plAjx1TND0Aaa+hCwlFVP89sNBqe4/NLO+RT7NLNDsIdNYh Ymv+QX/3yxun4caBGmp1kwflnXZ07ie3xowEtYyqbyxXprRbRgpss+kdMRmi1xMZtuTM lDQg== X-Forwarded-Encrypted: i=1; AHgh+RqQg/r71VkBh9PshQx7yYJsWrsunCy58VWLjE4+yKRFeuD+gwXkh80cZAYMtK40g3qajUTsi74rztwVzoI=@vger.kernel.org X-Gm-Message-State: AOJu0Yx/XDatz0qlCJut78DeezFm+765eGJMKBsNUD884GcwRzpBkrxI wX+iAfr4lJeQgzqka5fhz0SZ1wBGsX7tlWTtZIRoSg36XLpiknPXbqzS X-Gm-Gg: AfdE7clreuj4jIZOCMPWo2Q2EI9WmjpWamDFhX89Nfvk+VHYrsJzIpy9oJe9FiyRc8s F40dzid+/kJQL8sS0QQUU6abioh+XylPvDMk4aF/VlqfhbTCfgJ2XeNy1MzTaG71sbCIRoRJJiD VrgNXAyijwWN/GsrhQzCdP92y4aFwIEruSLim/Q9O4Qa3h/3hkB5aPztlUxMryVfDRqJErrjV4D QHX58A1VBQzbd+hScV0oN2a6c/2yVAiA9O90IOL+EEqHewIoYHN0dVJfu634nu8/RoIhen/d3SZ h4F8U18Jrwv63bv9HQJ/X8GMvp4cjSqsTIkw28APkiVSfzjyJYlQN19Qg6b9iwh5hL9kyOP3+ff ohEoCHUPr98xeyfx2GQVkwfNWMfb7TecSOzw+vnNIu3SW/nc3HitbDjU4hoKtj8taF8hBAZ69TQ omQfvaTCk+bP78u1dottCswjygfpNy+mfc/vKzT7YTukd+OwczqEcTvcXux8ODhrnyaY3xkM0lT V0qigLe4Wqzn+y3S1hT4mA+jQ3KdMEDuUTaweM= X-Received: by 2002:a05:600c:1f8c:b0:493:f7ca:bd6a with SMTP id 5b1f17b1804b1-4954a50d080mr27318195e9.8.1784319305927; Fri, 17 Jul 2026 13:15:05 -0700 (PDT) Received: from L-022584.energy.envision.com (dynamic-077-179-077-126.77.179.pool.telefonica.de. [77.179.77.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-495499a5847sm53179335e9.2.2026.07.17.13.15.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 13:15:04 -0700 (PDT) From: Xin Xie To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, wsa+renesas@sang-engineering.com, jie.luo@oss.qualcomm.com, shuah@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, fmancera@suse.de, bigeasy@linutronix.de, fmaurer@redhat.com, luka.gejak@linux.dev, Xin Xie Subject: [PATCH net-next v4 3/4] net: hsr: allow PRP RedBox (interlink) creation Date: Fri, 17 Jul 2026 22:14:56 +0200 Message-ID: <20260717201457.54-4-xiexinet@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260717201457.54-1-xiexinet@gmail.com> References: <20260717201457.54-1-xiexinet@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" With 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 proto 1"; the feature is implemented unconditionally by the preceding patches. Signed-off-by: Xin Xie --- net/hsr/hsr_netlink.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c index 8099f2069a7..88940e8014b 100644 --- a/net/hsr/hsr_netlink.c +++ b/net/hsr/hsr_netlink.c @@ -121,14 +121,8 @@ static int hsr_newlink(struct net_device *dev, } } =20 - if (proto =3D=3D HSR_PROTOCOL_PRP) { + if (proto =3D=3D HSR_PROTOCOL_PRP) proto_version =3D PRP_V1; - if (interlink) { - NL_SET_ERR_MSG_MOD(extack, - "Interlink only works with HSR"); - return -EINVAL; - } - } =20 return hsr_dev_finalize(dev, link, interlink, multicast_spec, proto_version, extack); --=20 2.53.0 From nobody Sat Jul 25 04:53:33 2026 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6C7E34F26F for ; Fri, 17 Jul 2026 20:15:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784319314; cv=none; b=NxQB4q7x7WHOC0XNpUIGIWzS6/1X+Ff4CORqI/+zSN+zY/ZTUy6V8ye0HFAKW9RPuMe5H3RhrL9nR50zVBLp7JeUNcVvrpT95IbMoopq8b8/25cmXMOtqqf1tPfB3cc4ZEfh5bcehOVnoRXyNjGNW2DpSM39r92VgYHf0B2E61Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784319314; c=relaxed/simple; bh=diUIIKStfenJCEasoEwrp+wCmRi3qtN6/sa0FZ2l7bg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GOJxMj8SkoTDiN4hhsZyYHcb3VTKxdm1RYl2I6I4tzYyvamCc1Aumk/1YECru/JoAeKfoFnWhzPQ+m1k3JSffEeYZ4X9Eyp3of/7X6/YSN2N12q4chA2JquDpkyB4Nza2NKoSCBxalgpsScuadwsuJk2FxYje7pm5aV0Oc1jhnA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=m8hK3rbW; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="m8hK3rbW" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-4706f016316so542981f8f.3 for ; Fri, 17 Jul 2026 13:15:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784319308; x=1784924108; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=4Pv4NrN4dYt4KyUEdjIMuVrZU8kjGasmAaF2k9w2Y9c=; b=m8hK3rbWJ9dCXRpYUMS8e5kU6ayjyoBM4AfwAuGK+XRLsdXJCcgqRxWGTYYYjC5bIL lwZ3rAcHJ1ELt8LLKUuViHJcNrhGhAxn1HUMzO1jNOB5E4+LcTilBy6ArFs/nrPSf0HE vqSsCccU5f8sxpGqR9Zzbst4KRwdQnG2UNfVjOv3uVaAF9RrjqMIOd7ylJLg+TkZ4/rc It3iUdpLnsm/VcuK1ff/CKLeIJJTAOyt6hWYvtqAMPfXzdSPCPisl6mNLMpVQbzV8Rwe zwVEgsTrPMTpSaDPT72+dPIzkk8/Z/9mH2WDYoxorwingznSCvnOR79Ky/msqvImTTJw gZ5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784319308; x=1784924108; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=4Pv4NrN4dYt4KyUEdjIMuVrZU8kjGasmAaF2k9w2Y9c=; b=jbUEkEGTKWPyWNKrB9TVXgajtTOf/JX3gvlFqAj6zB5QLN4qlmS3Ze0S4zn9xL73lX h1kRbJuqsqIkFdk7tE7hF7PcmG2OkW5M3tjpMzR4lXTcSqACnWTXyflaTij6FJgfLnV5 DVxN3pwhWhU6CCMPXXHPv5p+8AT3r3EPx5suL8YBvzAg9WNj9LQvLHkwS9LS8plMTp+u sexhBiCjjLsi6rrGN2rkOQV2KkRc+45TAoc1/5dj+VReNYeX0vOh03zOFFHfqsklI+yR 1m+nGqmw75njIkkkk5smRQsapLLBZ/p6ksFhsaq9pl7mM2O5O8wQgCb3Gr3hjTJT3dpi XluA== X-Forwarded-Encrypted: i=1; AHgh+Rr+LC3PLxWYY/DS+uRYMwobrZufTTLyG29GJaJhRmzcljs9cfBUGk2PQ1ujNIxVX5nuqE0hSnv8KEFFdxA=@vger.kernel.org X-Gm-Message-State: AOJu0YwZwyZ+mfbwFHB7jOCYM1E68PfaXQLvzxsNjT5mFEtFhxy5UcAU Nj8FIdDKkihRTWZ+lySti2Tm46R6AQFIdICmzGNJYR+DFpQwDTbYL+x1 X-Gm-Gg: AfdE7ckMBtG99FeH+2MunRK0Re82ss/wlItBWRhDeapqDXCrwPpaQ4z4r3QCIQXZNEn DjdT+q1zKiVvhjRscLhTuN28yEoWMnC5P44P7TGLFz+SrPvxut5j+chsqggLovoj1DX5RVg6BlR Otdi/1Xhqm3PmOcvNdTZGjd09iu4Beh3J9kevpJckvxxDR759PXQquL0/pjqFhVo28St6CJk0+R 2XZomJVAlRqQKPnORmtc5poq35H7VyTANbRk5NtgR/qYVn+AKsD3uxxEMAIPg7gaIRo3BOuBm8x YLtqwJL/qYKqwLNkqHqV6WhJzROZjUcGus0f4/wh0fsZbCFfyBvrxy18ELcQGl/QDC7Yoo6TCAJ nU8MPCvPHuFB8nA4Dah2EFjMC0sb+p6uXVmywL/1GNYqZRr1gNJEtXjYArt4mBHZQuJFNIFc1Ab o/Lfj6OVAntyhY7kZTuJfuYOTbl20woPi1ndLbkqYlgEDnEV9ee1GVOoSattfza4OtsZv+sUrDR uNVzSDHOha2UNSP4XAlpz3Cbk6TNmX315QdJ3w= X-Received: by 2002:a05:600c:46c7:b0:493:efdf:7c80 with SMTP id 5b1f17b1804b1-4954a40ebf0mr29386095e9.5.1784319307839; Fri, 17 Jul 2026 13:15:07 -0700 (PDT) Received: from L-022584.energy.envision.com (dynamic-077-179-077-126.77.179.pool.telefonica.de. [77.179.77.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-495499a5847sm53179335e9.2.2026.07.17.13.15.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 13:15:06 -0700 (PDT) From: Xin Xie To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, wsa+renesas@sang-engineering.com, jie.luo@oss.qualcomm.com, shuah@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, fmancera@suse.de, bigeasy@linutronix.de, fmaurer@redhat.com, luka.gejak@linux.dev, Xin Xie Subject: [PATCH net-next v4 4/4] selftests: net: hsr: add PRP RedBox test Date: Fri, 17 Jul 2026 22:14:57 +0200 Message-ID: <20260717201457.54-5-xiexinet@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260717201457.54-1-xiexinet@gmail.com> References: <20260717201457.54-1-xiexinet@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add 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. Signed-off-by: Xin Xie --- 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 diff --git a/tools/testing/selftests/net/hsr/Makefile b/tools/testing/selft= ests/net/hsr/Makefile index 31fb9326cf5..2150e487ac7 100644 --- a/tools/testing/selftests/net/hsr/Makefile +++ b/tools/testing/selftests/net/hsr/Makefile @@ -4,6 +4,7 @@ top_srcdir =3D ../../../../.. =20 TEST_PROGS :=3D \ hsr_ping.sh \ + hsr_prp_redbox.sh \ hsr_redbox.sh \ link_faults.sh \ prp_ping.sh \ diff --git a/tools/testing/selftests/net/hsr/hsr_prp_redbox.sh b/tools/test= ing/selftests/net/hsr/hsr_prp_redbox.sh new file mode 100755 index 00000000000..479c892225b --- /dev/null +++ b/tools/testing/selftests/net/hsr/hsr_prp_redbox.sh @@ -0,0 +1,99 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Test a PRP RedBox (PRP-SAN): a SAN that sits behind the interlink port m= ust +# reach, and be reached by, a peer DANP on the PRP network with its own MAC +# preserved on the wire, and the RedBox must announce the SAN with a RedBo= x-MAC +# TLV (terminated by an EOT marker) in its PRP supervision frames. +# +# RB PRP RedBox: prp0 over rb_a/rb_b (LAN A/B) + interlink rb_il +# PEER peer DANP : prp0 over pe_a/pe_b, 100.64.0.2 +# SAN SAN : san_il, own MAC, 100.64.0.51 (behind the interlink) + +ipv6=3Dfalse + +source ./hsr_common.sh + +check_prerequisites + +if ! command -v tcpdump >/dev/null 2>&1; then + echo "SKIP: This test requires tcpdump" + exit $ksft_skip +fi + +if ! ip link help hsr 2>&1 | grep -q interlink; then + echo "SKIP: iproute2 too old (no hsr interlink support)" + exit $ksft_skip +fi + +setup_ns RB PEER SAN +trap 'cleanup_ns "$RB" "$PEER" "$SAN"' EXIT + +ip link add rb_a netns "$RB" type veth peer name pe_a netns "$PEER" +ip link add rb_b netns "$RB" type veth peer name pe_b netns "$PEER" +ip link add rb_il netns "$RB" type veth peer name san_il netns "$SAN" + +ip -n "$RB" link set rb_a up +ip -n "$RB" link set rb_b up +ip -n "$RB" link set rb_il up +ip -n "$PEER" link set pe_a up +ip -n "$PEER" link set pe_b up +ip -n "$SAN" link set san_il up +ip -n "$SAN" addr add 100.64.0.51/24 dev san_il + +# Feature gate: PRP interlink (RedBox) creation. A kernel without PRP RedB= ox +# support rejects this with -EINVAL, so SKIP rather than FAIL. +if ! ip -n "$RB" link add name prp0 type hsr slave1 rb_a slave2 rb_b \ + interlink rb_il proto 1 2>/dev/null; then + echo "SKIP: kernel without PRP RedBox (interlink) support" + exit $ksft_skip +fi +ip -n "$RB" link set prp0 up +ip -n "$PEER" link add name prp0 type hsr slave1 pe_a slave2 pe_b proto 1 +ip -n "$PEER" link set prp0 up +ip -n "$PEER" addr add 100.64.0.2/24 dev prp0 +sleep 1 + +san_mac=3D$(ip -n "$SAN" -br link show san_il | awk '{print $3}') +rb_mac=3D$(ip -n "$RB" -br link show rb_il | awk '{print $3}') + +# Bidirectional unicast across the interlink. +do_ping "$PEER" 100.64.0.51 +do_ping "$SAN" 100.64.0.2 +stop_if_error "PRP RedBox bidirectional unicast failed" + +# The SAN source MAC must be preserved on the PRP network, not laundered t= o the +# RedBox MAC: the peer resolves the SAN IP to the SAN's own MAC. +neigh=3D$(ip -n "$PEER" neigh show 100.64.0.51 | awk '{print $5}') +if [ "$neigh" !=3D "$san_mac" ]; then + echo "SAN MAC preservation [ FAIL ]: peer resolved 100.64.0.51 to" \ + "'$neigh', expected $san_mac" 1>&2 + ret=3D1 +fi +stop_if_error "SAN MAC not preserved on the PRP network" + +# The proxy-announce supervision frame must carry, in order, the life-chec= k TLV +# (type 0x14, len 6) + MacAddressA =3D=3D SAN MAC + the RedBox-MAC TLV (ty= pe 0x1e, +# len 6) + MacAddressRedBox =3D=3D RedBox MAC + the EOT marker (0x0000). +ip netns exec "$SAN" ping -i 0.2 -q 100.64.0.2 >/dev/null 2>&1 & +ping_pid=3D$! +cap=3D$(ip netns exec "$PEER" timeout 5 tcpdump -i pe_a -nn -x \ + "ether proto 0x88fb and ether src $rb_mac" 2>/dev/null || true) +kill "$ping_pid" 2>/dev/null || true +wait "$ping_pid" 2>/dev/null || true + +san_hex=3D$(echo "$san_mac" | tr -d ':') +rb_hex=3D$(echo "$rb_mac" | tr -d ':') +# Reassemble contiguous frame hex: drop the "0x0010:" offset labels and sp= aces. +frame_hex=3D$(echo "$cap" | awk '/^[[:space:]]*0x[0-9a-f]+:/ { + sub(/^[[:space:]]*0x[0-9a-f]+:[[:space:]]*/, ""); + gsub(/ /, ""); printf "%s", $0 }') +if ! echo "$frame_hex" | grep -q "1406${san_hex}1e06${rb_hex}0000"; then + echo "supervision RedBox-MAC TLV [ FAIL ]: missing SAN MAC, Type-30" \ + "payload, or EOT" 1>&2 + ret=3D1 +fi +stop_if_error "PRP RedBox supervision RedBox-MAC TLV/EOT check failed" + +echo "INFO: PRP RedBox (PRP-SAN) conformance checks passed" +exit $ret --=20 2.53.0