Article View: linux.kernel.netdev
Article #24509[PATCH net-next v13 5/8] hsr: Use the port and header information in hsr_forward_skb()
From: Sebastian Andrzej Siewior
Date: Mon, 30 Nov 2026 08:52
Date: Mon, 30 Nov 2026 08:52
158 lines
15651 bytes
15651 bytes
The upper layer can submit a port on which the skb should be sent and
whether or not a HSR header should be added. Use this information while
forwarding the packet:
- If the port set, deliver it only on the requested port.
- If a header is already present then skip parts of the stack:
- The packet originates from the master port and we don't want to
assign a sequence number to it, it needs to preserve the original
one.
- The existing h_source must be used (and not replaced).
- The node should already exist in the node_db if "other" packets are
exchanged. If the node information is not yet existing then
creating it makes no sense because it is used for deduplication of
incoming packets and this is not used in the PTP case. If no other
packets are exchanged then the node_db will age and then removed.
This is only used in the pure software version. Hardware with any kind
of NETIF_F_HW_* offload support need to be addressed separately.
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
net/hsr/hsr_forward.c | 47 +++++++++++++++++++++++++++++++++++++++--------
net/hsr/hsr_framereg.h | 2 ++
2 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
index f49d962337f8b..1d1d75ed8cd06 100644
--- a/net/hsr/hsr_forward.c
+++ b/net/hsr/hsr_forward.c
@@ -426,7 +426,7 @@ static void hsr_deliver_master(struct sk_buff *skb, struct net_device *dev,
static int hsr_xmit(struct sk_buff *skb, struct hsr_port *port,
struct hsr_frame_info *frame)
{
- if (frame->port_rcv->type == HSR_PT_MASTER) {
+ if (frame->port_rcv->type == HSR_PT_MASTER && !frame->has_hsr_header) {
hsr_addr_subst_dest(frame->node_src, skb, port);
/* Address substitution (IEC62439-3 pp 26, 50): replace mac
@@ -552,6 +552,7 @@ static void hsr_forward_do(struct hsr_frame_info *frame)
hsr_for_each_port(frame->port_rcv->hsr, port) {
struct hsr_priv *hsr = port->hsr;
+
/* Don't send frame back the way it came */
if (port == frame->port_rcv)
continue;
@@ -570,6 +571,20 @@ static void hsr_forward_do(struct hsr_frame_info *frame)
if ((port->dev->features & NETIF_F_HW_HSR_DUP) && sent)
continue;
+ /* If this frame has a specific outgoing port specified (by the
+ * sender) then send it on this port only.
+ */
+ if (frame->req_tx_port != HSR_PT_NONE &&
+ frame->req_tx_port != port->type)
+ continue;
+ /* If this TX frame already has a HSR header then forward the
+ * frame with it and don't add one.
+ */
+ if (frame->has_hsr_header && frame->skb_std) {
+ skb = skb_clone(frame->skb_std, GFP_ATOMIC);
+ goto inject_into_stack;
+ }
+
/* Don't send frame over port where it has been sent before.
* Also for SAN, this shouldn't be done.
*/
@@ -597,6 +612,7 @@ static void hsr_forward_do(struct hsr_frame_info *frame)
else
skb = hsr->proto_ops->get_untagged_frame(frame, port);
+inject_into_stack:
if (!skb) {
frame->port_rcv->dev->stats.rx_dropped++;
continue;
@@ -661,6 +677,13 @@ int hsr_fill_frame_info(__be16 proto, struct sk_buff *skb,
struct hsr_port *port = frame->port_rcv;
struct hsr_priv *hsr = port->hsr;
+ if (frame->has_hsr_header) {
+ frame->skb_std = skb;
+
+ WARN_ON_ONCE(port->type != HSR_PT_MASTER);
+ WARN_ON_ONCE(skb->mac_len < sizeof(struct hsr_ethhdr));
+ return 0;
+ }
/* HSRv0 supervisory frames double as a tag so treat them as tagged. */
if ((!hsr->prot_version && proto == htons(ETH_P_PRP)) ||
proto == htons(ETH_P_HSR)) {
@@ -702,7 +725,8 @@ int prp_fill_frame_info(__be16 proto, struct sk_buff *skb,
}
static int fill_frame_info(struct hsr_frame_info *frame,
- struct sk_buff *skb, struct hsr_port *port)
+ struct sk_buff *skb, struct hsr_port *port,
+ enum hsr_port_type req_tx_port, bool has_hsr_header)
{
struct hsr_priv *hsr = port->hsr;
struct hsr_vlan_ethhdr *vlan_hdr;
@@ -725,10 +749,16 @@ static int fill_frame_info(struct hsr_frame_info *frame,
if (port->type == HSR_PT_INTERLINK)
n_db = &hsr->proxy_node_db;
- frame->node_src = hsr_get_node(port, n_db, skb,
- frame->is_supervision, port->type);
- if (!frame->node_src)
- return -1; /* Unknown node and !is_supervision, or no mem */
+ frame->req_tx_port = req_tx_port;
+ frame->has_hsr_header = has_hsr_header;
+
+ if (!frame->has_hsr_header) {
+ frame->node_src = hsr_get_node(port, n_db, skb,
+ frame->is_supervision,
+ port->type);
+ if (!frame->node_src)
+ return -1; /* Unknown node and !is_supervision, or no mem */
+ }
ethhdr = (struct ethhdr *)skb_mac_header(skb);
frame->is_vlan = false;
@@ -777,10 +807,11 @@ void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port,
struct hsr_frame_info frame;
rcu_read_lock();
- if (fill_frame_info(&frame, skb, port) < 0)
+ if (fill_frame_info(&frame, skb, port, req_tx_port, has_hsr_header) < 0)
goto out_drop;
- hsr_register_frame_in(frame.node_src, port, frame.sequence_nr);
+ if (!frame.has_hsr_header)
+ hsr_register_frame_in(frame.node_src, port, frame.sequence_nr);
hsr_forward_do(&frame);
rcu_read_unlock();
/* Gets called for ingress frames as well as egress from master port.
diff --git a/net/hsr/hsr_framereg.h b/net/hsr/hsr_framereg.h
index 127a3fb64d5f0..dc13819d04098 100644
--- a/net/hsr/hsr_framereg.h
+++ b/net/hsr/hsr_framereg.h
@@ -29,6 +29,8 @@ struct hsr_frame_info {
bool is_from_san;
bool dst_in_node_db;
bool dst_in_proxy_node_db;
+ bool has_hsr_header;
+ enum hsr_port_type req_tx_port;
};
void hsr_del_self_node(struct hsr_priv *hsr);
--
2.55.0
Technical Details
Message-ID:
<20261130-hsr_ptp-v13-5-598326208fc5@linutronix.de>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374039-linux-kernel-netdev=dewy.ruReferences:
<20261130-hsr_ptp-v13-0-598326208fc5@linutronix.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374039-linux-kernel-netdev=dewy.ru From: bigeasy@linutronix.de (Sebastian Andrzej Siewior) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next v13 5/8] hsr: Use the port and header information in hsr_forward_skb() Date: Mon, 30 Nov 2026 09:52:22 +0100 Organization: Usenet Network Message-ID: <20261130-hsr_ptp-v13-5-598326208fc5@linutronix.de> References: <20261130-hsr_ptp-v13-0-598326208fc5@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="1384210"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:2K8Ko3OFVcmnb5zCeFK6GWeyvqU= sha256:lCjnz0SletlrbtSfgDEIyLjcCts32UwgQxCAmu9Y0+4= sha1:6c6Kn4MD+CgGxaLVeX6NNAXKILc= sha256:zw4nCjzzpb9MB+O1nzGZJlXhmIFKYJUmQNtb/eBS24Q= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id E22DE125FD1; Mon, 30 Nov 2026 11:53:08 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.151 X-Spam-Status: No, score=-3.151 tagged_above=-9999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=linutronix.de header.b=HTnyb3vu; dkim=neutral reason="invalid (unsupported algorithm ed25519-sha256)" header.d=linutronix.de header.b=hbQfK5AM X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OO-CsUhYqw63; Mon, 30 Nov 2026 11:53:06 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-374039-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linutronix.de X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id E6112125FCC; Mon, 30 Nov 2026 11:52:52 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id BB86025BB3; Mon, 30 Nov 2026 08:52:45 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796028753; b=zVDteiNVDJjzAmlglGncUYAJvmuKtqsrB2WOZxoEc0HGz6uhqtj8CaTDWlgIqmQMzefq kJF8R9Z6VOvmfQ4L7w9ujqqgX3WBQPlnHpaqCUo3pKB9glYAa5rVrB3IusGO3TKpvGbW3 dBfr4akewxlJ926M6W7hJHGENjgVQLLj+eQvUole7507OoYcE/enX7W9hnMGVPqij2lkm YZOXta/DAklRCFl5p5AU3KI9ZdTjyt1IOtaI1QniDaSrheVID0qP3f239JnNOErby3ujF OQWQVgpeJddzTs3JrHX2hNbc2ImzS5dKvqjiTrp9iXr/SIkcmOiyvOSupJY0eJZpRVQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796028753; h=X-Original-To:Received:DMARC-Filter:From:DKIM-Signature: DKIM-Signature:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=vMhz5wBioPFyCYnw40TBhwFfNGE+6yx/y9Xk7tpAx9A=; b=VCSO/OzScoCPGcwJDgksxS0o0xJ4dwWr4KnbuqXh+kRp9/a9AP/tBp0zzXlR0PuGbHsy 9FT9+Fc+l8uLPn+K1bUgHGmMQfujv4n3viQs2vFnbtu7SaI1/0nsl7wHXCTgVMrgpfVLL +pO9QTF4BD4DTslxzaKrp2R/pJVaabezfGzWryvEC5hVpHjV+GcNSi5byMHuIVkgBeMCs 8Ac924jmU6RE9PC5Q8Nnkn8IokkWxXXhfPw0TXPb1oxXHaCQkD4KHF1FPyH6RlmP1FYXQ ICn0gTP6I5ibA810QCnqRdm/lKks6Lj1OLS8Fj0i598KDmz5mBMUGt3gLU7SomoZFSA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=HTnyb3vu; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=hbQfK5AM; dmarc=pass header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9654606A6BF; Mon, 30 Nov 2026 08:52:33 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=HTnyb3vu; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=hbQfK5AM X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=193.142.43.55 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796028752; b=JxsRXcHb5FLAeQc7woZRYhwVwzO+7YN6zyCQWFLecFGL+rE3JUa31Ym/ZdyWBbhpUkKX 2rjcWlwd8D4FSSn+RelHPYyFlmhE5vYQtX2JjkmUasOUv4WGsrmDgWu8DRc7wLAuYIVC0 Ek3/HoqafI2EQBR7hxoioijibK3a2Q+eK1L7GTFQy3+ocUqkh3gDCRYtsZybM4yltmcK1 kzSfQKJGAQ7tPYhyZ1QRGmJ6BWE0Ge3Y+dskNW3bOP5zrlB2brzPNEDYsQRS8zkD2zC/R UgQBOPw/oQ18gcosoV61/bDmMUC4gxR9OsHoNbelpyRssOoRc9dwIn4am3wtKQL2Fqw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796028752; h=DMARC-Filter:From:DKIM-Signature:DKIM-Signature:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=vMhz5wBioPFyCYnw40TBhwFfNGE+6yx/y9Xk7tpAx9A=; b=Ex4dGpHmNonVhwq9C2FoOAV9RZTHvzRyV9sSo9r1LbdAbZZ+N6OuxpjvWStLSUqmPr1E F6WDRJkIakEA9ZQpYdFQDnFdxS1ASAZgjOJE6Pkt03z7nNEfkKqcmJJrbnv1eyt4xfW4p J7RgIkYHY2B2w8rfk5jqcNkyIopGyIGlcicZGaBx9pU0udPwiNG+fLFpY1FnzRimqTEoC mYkq8iJlDwK2IRlyyK9U0r86T+y/2EVVSYCRyqOS+rt2IQF6bHL/YCp0Kqlj+GhIJHz4a 2Vy15VkedRAnNSWAzbcrONmKtTm7KGJl1slObEyN+3maj47SSBvBSRbdvIKnLEpXqtg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=HTnyb3vu; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=hbQfK5AM; arc=none smtp.remote-ip=193.142.43.55 X-Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 585C0606A69C for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 08:52:32 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 585C0606A69C X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1796028750; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vMhz5wBioPFyCYnw40TBhwFfNGE+6yx/y9Xk7tpAx9A=; b=HTnyb3vuY5d6Jjiy2qIspvVYqj5YXi47I9FKjsPC0NG/bLnBCWN8OksATkfeFaVnVB1dDd 4DJpJTwJkPSsYl7TrZp0ruJxTfk80uO7gTVF641KTpbTxrVp4a8A+bIYR903I7ePR1rgwD tvEQsMJi9ocAbeQ+Qew6h5oqe6aIMEgh4mkm9OfwxFe94wv6Z+NZQo14XpIu50KumvUEku hdhsvwSNhwnO322eh8tEpr40t81Z8Y6sm3kXtTMWt3BQD1txreHzSEur9D/soOxTo4TzT6 qqNcbTMqVBWJwVUEpPINoO2D4FqFK9ZhOwk55nY2ansv1uJGnjp31GfoLyig5A== X-DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1796028750; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vMhz5wBioPFyCYnw40TBhwFfNGE+6yx/y9Xk7tpAx9A=; b=hbQfK5AM9uQ6+0hTFJhr4OoRrzxK5fvO+bD8KEQIcCjug7tfJCbwXxG7PiJi9Enkwxz+k5 e+6WlGXXSFngXkDQ== X-Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>, "(JC), Jayachandran" <j-rameshbabu@ti.com>, Andrew Lunn <andrew+netdev@lunn.ch>, Danish Anwar <danishanwar@ti.com>, Daolin Qiu <d-qiu@ti.com>, "David S. Miller" <davem@davemloft.net>, Felix Maurer <fmaurer@redhat.com>, Jakub Kicinski <kuba@kernel.org>, Neelima Muralidharan <neelima@ti.com>, Paolo Abeni <pabeni@redhat.com>, Praneeth Bajjuri <praneeth@ti.com>, Pratheesh Gangadhar TK <pratheesh@ti.com>, Richard Cochran <richardcochran@gmail.com>, Simon Horman <horms@kernel.org>, Vignesh Raghavendra <vigneshr@ti.com>, Willem de Bruijn <willemdebruijn.kernel@gmail.com>, Daniel Machon <daniel.machon@microchip.com>, Eric Dumazet <edumazet@kernel.org> X-In-Reply-To: <20261130-hsr_ptp-v13-0-598326208fc5@linutronix.de> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-Received-Bytes: 15392