Article View: linux.kernel.netdev
Article #3932Re: [PATCH net-next v9 5/8] hsr: Use the port and header information in hsr_forward_skb()
From: Sebastian Andrzej Siewior
Date: Fri, 16 Oct 2026 09:56
Date: Fri, 16 Oct 2026 09:56
103 lines
11175 bytes
11175 bytes
On 2026-10-16 11:24:16 [+0200], Daniel Machon wrote:
> > 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.
> >
> > Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> > ---
> > net/hsr/hsr_forward.c | 45 ++++++++++++++++++++++++++++++++++++---------
> > net/hsr/hsr_framereg.h | 2 ++
> > 2 files changed, 38 insertions(+), 9 deletions(-)
> >
> > diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
> > index 2b8ae9723bd7f..534798da48d53 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_foreign_header) {
> > hsr_addr_subst_dest(frame->node_src, skb, port);
> >
> > /* Address substitution (IEC62439-3 pp 26, 50): replace mac
> > @@ -547,11 +547,12 @@ bool hsr_drop_frame(struct hsr_frame_info *frame, struct hsr_port *port)
> > static void hsr_forward_do(struct hsr_frame_info *frame)
> > {
> > struct hsr_port *port;
> > - struct sk_buff *skb;
>
> Is this needed, or just cleanup?
Sort of cleanup. It is still used in the loop where it is used. The NULL
init is not needed so It could stay as-is where it is.
> > bool sent = false;
> >
> > hsr_for_each_port(frame->port_rcv->hsr, port) {
> > struct hsr_priv *hsr = port->hsr;
> > + struct sk_buff *skb = NULL;
> > +
> > /* Don't send frame back the way it came */
> > if (port == frame->port_rcv)
> > continue;
> > @@ -570,6 +571,17 @@ static void hsr_forward_do(struct hsr_frame_info *frame)
> > if ((port->dev->features & NETIF_F_HW_HSR_DUP) && sent)
> > continue;
> >
> > + /* PTP TX packets have an outgoing port specified */
> > + if (frame->req_tx_port != HSR_PT_NONE && frame->req_tx_port != port->type)
> > + continue;
>
> This checks that if the frame is directed and that the frame is only send to the
> directed port. Maybe the comments could be more clear about that.
Oki.
…
> > diff --git a/net/hsr/hsr_framereg.h b/net/hsr/hsr_framereg.h
> > index 127a3fb64d5f0..e5e6363c0466f 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_foreign_header;
> > + enum hsr_port_type req_tx_port;
>
> The same flag is hsr_hdr in the uAPI, has_header in hsr_dev_xmit(),
> has_hsr_header in hsr_forward_skb() and has_foreign_header here. The
> port is tx_port in some places and req_tx_port in others. Could the naming be
> aligned?
I could align it with has_hsr_header probably.
> > };
> >
> > void hsr_del_self_node(struct hsr_priv *hsr);
>
> /Daniel
Sebastian
Technical Details
Message-ID:
<20261016095611.x_Nm0lpH@linutronix.de>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347249-linux-kernel-netdev=dewy.ruReferences:
<20261014-hsr_ptp-v9-0-2d20a2a0f816@linutronix.de> <20261014-hsr_ptp-v9-5-2d20a2a0f816@linutronix.de> <20261016092416.5ssargoekf74pcwn@DEN-DL-M70577.microsemi.net>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347249-linux-kernel-netdev=dewy.ru From: bigeasy@linutronix.de (Sebastian Andrzej Siewior) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v9 5/8] hsr: Use the port and header information in hsr_forward_skb() Date: Fri, 16 Oct 2026 11:56:11 +0200 Organization: Usenet Network Message-ID: <20261016095611.x_Nm0lpH@linutronix.de> References: <20261014-hsr_ptp-v9-0-2d20a2a0f816@linutronix.de> <20261014-hsr_ptp-v9-5-2d20a2a0f816@linutronix.de> <20261016092416.5ssargoekf74pcwn@DEN-DL-M70577.microsemi.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="2735030"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:msx6raO066lgY1ICCEDhcorC3GA= sha256:be52ZXgSWnShpKGkCqL09LooZNy2g93NBHQR650Wglo= sha1:9AWKxkBEUVLYAN1jTXrJLKYZZHs= sha256:3+HjBmACmkKPOH2s9WqH4S9mdqU129BK6RlsIS/d/74= Content-Disposition: inline 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 36CAF11201E; Fri, 16 Oct 2026 13:00:53 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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=UOKCmCom; dkim=neutral reason="invalid (unsupported algorithm ed25519-sha256)" header.d=linutronix.de header.b=cpWDeT5p 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 2ETaKS7tuLAS; Fri, 16 Oct 2026 13:00:50 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-347249-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 85A77C001C; Fri, 16 Oct 2026 13:00:32 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 55244307CD; Fri, 16 Oct 2026 09:56:25 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D26935CB6B; Fri, 16 Oct 2026 09:56:24 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="UOKCmCom"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cpWDeT5p" X-Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 809F8337BB8 for <netdev@vger.kernel.org>; Fri, 16 Oct 2026 09:56:20 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792144583; cv=none; b=cTYOTNn9yBDKDgGp7EbCDy2IQUpYlJ43lBQVVIgcZL+Ckp0dsuBBYeHp2zpdN0A5NNkkAExQNAJ7HUU9LWL89TNnUsn3athm2QmA0Jrk4PwtfiBmsaIdYx7fXGGSIzxoHNkh7+tRFA+RwyZoV4PSHyY9Eo+nPUPmuZTbPZfq/vs= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792144583; c=relaxed/simple; bh=KS+hyG8c1op4kAF/V5/p31OA1NEKdfCe5DgHHpZ9sjw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=B0HF6hbX0yqOtrCDo/YFLIuO15LgvRGGmVp+OfFUbaQDdNhVL1MqUMMOZLYNLfS/m3x6IsnkXnScB1Blx31x3Vs25z8+KFw3b1RgFD2ySzSWq13OXgXQEIbev44eN2vZ1yR9Lkwm8PIHWQnZlVaDooZdHx8vgiA36SltaYkmzkE= X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=UOKCmCom; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=cpWDeT5p; arc=none smtp.client-ip=193.142.43.55 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=1792144572; 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=TQPC4olfHWFHQdUeCdi2r09y8heMXe015t/8jgh07KA=; b=UOKCmComBwA2vTZAW6nDIWyDE9TY5QhDwAx1wUBVMOx+0xvBPT+UUto/xsLjXi7D0GswMM Kee5lNYb1xYvsElmzAhGmoAizxf/JwEffPEWex/V2hcNRSgr8/dJNV8/41rp7tJiiQcZ0i sCr1jzCH0N2+i+P2iV2Wuarwd8N8GQLErXdYCyP1rW68ZXEngswfhB2IhwcNfhNr6B5+Zw 1mipnNhubX0sfCnbwcUOu+6cvUaGmYCuIPoTNkfvdmD9OzBBBwKs0TvewZbv5E9V19KSLK Xr1Kjln1OXmQcl2oI9tcSUhhjlfQtLumaUGKbtwr8g+YLY2utmUiuVy/cF67Ww== X-DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1792144572; 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=TQPC4olfHWFHQdUeCdi2r09y8heMXe015t/8jgh07KA=; b=cpWDeT5pSXPIYJshKpcNoP+kCMq5bghlprss+B+9PyACwKyV5YmOtr7+hKtHVic47GOIwM CviwHIapeXcYKkAw== X-Cc: netdev@vger.kernel.org, "(JC), Jayachandran" <j-rameshbabu@ti.com>, Andrew Lunn <andrew+netdev@lunn.ch>, Chintan Vankar <c-vankar@ti.com>, 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>, Eric Dumazet <edumazet@kernel.org> X-Precedence: bulk X-Mailing-List: netdev@vger.kernel.org X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-In-Reply-To: <20261016092416.5ssargoekf74pcwn@DEN-DL-M70577.microsemi.net>