Article View: linux.kernel.netdev
Article #19748[PATCH net-next v11 4/8] hsr: Drop received PTP packets
From: Sebastian Andrzej Siewior
Date: Fri, 20 Nov 2026 10:17
Date: Fri, 20 Nov 2026 10:17
102 lines
13557 bytes
13557 bytes
Receiving PTP packets via the HSR interface does not make sense. The HSR
stack will forward one copy to the user and ignore the duplicate from
the other port. The PTP stack is however interested in both copies since
they will have different content (due to different processing times
within the HSR ring) and different timestamp information which is not
forwarded at all.
Forwarding a PTP packet by the HSR stack is undesired because the
forwarding takes time, it is not accounted in the packet and this makes
the outgoing PTP packet inaccurate and therefore useless.
Drop all received PTP packets. For the PRP configuration it is the
ether type, for HSR configuration it is the encapsulated protocol, that
is checked. A PTP stack that is doing PTP over a HSR network needs to
retrieve the PTP packet on the original slave interface where it was
received. The PTP packet is dropped with RX_HANDLER_CONSUMED meaning it
won't be visible by packet sockets bounded to protocol ETH_P_1588. It
works for sockets bound to ETH_P_ALL which is what linuxptp is doing.
L3 packets (PTP over UDP) is not considered because it is not part of
the HSR specification.
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
net/hsr/hsr_slave.c | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/net/hsr/hsr_slave.c b/net/hsr/hsr_slave.c
index 5274ba6dd36e6..a5b47f016abd7 100644
--- a/net/hsr/hsr_slave.c
+++ b/net/hsr/hsr_slave.c
@@ -23,6 +23,7 @@ bool hsr_invalid_dan_ingress_frame(__be16 protocol)
static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb)
{
+ struct hsr_ethhdr *hsr_ethhdr;
struct sk_buff *skb = *pskb;
struct hsr_port *port;
struct hsr_priv *hsr;
@@ -44,8 +45,7 @@ static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb)
if (hsr_addr_is_self(port->hsr, eth_hdr(skb)->h_source)) {
/* Directly kill frames sent by ourselves */
- kfree_skb(skb);
- goto finish_consume;
+ goto finish_free_consume;
}
/* For HSR, only tagged frames are expected (unless the device offloads
@@ -64,15 +64,28 @@ static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb)
skb_reset_mac_header(skb);
if ((!hsr->prot_version && protocol == htons(ETH_P_PRP)) ||
protocol == htons(ETH_P_HSR)) {
- if (!pskb_may_pull(skb, ETH_HLEN + HSR_HLEN)) {
- kfree_skb(skb);
- goto finish_consume;
- }
+ if (!pskb_may_pull(skb, ETH_HLEN + HSR_HLEN))
+ goto finish_free_consume;
skb_set_network_header(skb, ETH_HLEN + HSR_HLEN);
}
skb_reset_mac_len(skb);
+ /* PTP packets are not supposed to be forwarded via HSR as-is. The
+ * latency introduced by forwarding renders the time information
+ * useless. Userland needs to capture the packet on the original
+ * interface instead of hsr.
+ */
+ if ((!hsr->prot_version && protocol == htons(ETH_P_PRP)) ||
+ protocol == htons(ETH_P_HSR)) {
+ hsr_ethhdr = (struct hsr_ethhdr *)skb_mac_header(skb);
+ if (hsr_ethhdr->hsr_tag.encap_proto == htons(ETH_P_1588))
+ goto finish_free_consume;
+ } else {
+ if (protocol == htons(ETH_P_1588))
+ goto finish_free_consume;
+ }
+
/* Only the frames received over the interlink port will assign a
* sequence number and require synchronisation vs other sender.
*/
@@ -84,7 +97,10 @@ static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb)
hsr_forward_skb(skb, port, HSR_PT_NONE, false);
}
-finish_consume:
+ return RX_HANDLER_CONSUMED;
+
+finish_free_consume:
+ kfree_skb(skb);
return RX_HANDLER_CONSUMED;
finish_pass:
--
2.55.0
Technical Details
Message-ID:
<20261120-hsr_ptp-v11-4-264c88f4f1d0@linutronix.de>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367849-linux-kernel-netdev=dewy.ruReferences:
<20261120-hsr_ptp-v11-0-264c88f4f1d0@linutronix.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367849-linux-kernel-netdev=dewy.ru From: bigeasy@linutronix.de (Sebastian Andrzej Siewior) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next v11 4/8] hsr: Drop received PTP packets Date: Fri, 20 Nov 2026 11:17:00 +0100 Organization: Usenet Network Message-ID: <20261120-hsr_ptp-v11-4-264c88f4f1d0@linutronix.de> References: <20261120-hsr_ptp-v11-0-264c88f4f1d0@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="3131419"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:heW8hVw8vwkCcpr5hSAfq6xmcKs= sha256:mRZXD3Ts24wvCeld5yRYmpkbPMik9zyYvoZ4pJCqmn4= sha1:mJsLw9g84nhCZg2N/w2Ckewv5O4= sha256:Hq+q78rB7bKd8WDOflQzivaha0c/TwT+jNy8prtsVSs= 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 55E5B11594E; Fri, 20 Nov 2026 13:17:49 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 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.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=zLkDLwEX; dkim=neutral reason="invalid (unsupported algorithm ed25519-sha256)" header.d=linutronix.de header.b=s9vh6g42 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 CWPRNFPr6DYy; Fri, 20 Nov 2026 13:17:46 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-367849-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id C1336115947; Fri, 20 Nov 2026 13:17:32 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 1060634829; Fri, 20 Nov 2026 10:17:23 +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=1795169834; b=cyAdDcCLe5peh52eMNG0A18WKe34Bvd45/IUUk1hp3DT75n7d9KYGx7QG4hOsrCEHui6 LWm/eLQsHSQYVeptJNY7CSQ0QVpRv8nR+FGPGeVxg1cuswCGKIxilm9DbwQuiLGgKwHW6 qaVK7h+OwfF1o03xnZ+rjtSZZQtlK2eJ57w5QR/egpWV3yOwcpqY4qj2GZ3ZKOr1ku84f VZ+WLcSoCoR0nq/zOqIUPxfEqW1uYVB0yjTShl37Fe3NSDLPLMR1E6GBpGXukUR6Whrbb 4qImO+tfn6jySIBrl8r+OlO76/oN1rzHl0YqpjQ33juWKoOcnfif1D1ZHOpEsSxktww== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795169834; 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=TxSFGvzroXMP1yCKj5gXKh91OPMqff9Hzouu/ZStk84=; b=ONYpOIkA1fqbf1sxpCsjL4xVChGZcM3mhoRBViOvJ/KRoM62Vjvcz/6FyjzPOaiHWrRv fdyMAnPOPbr3nUstAkcWZzzQNcUzR4RsvsDuAfEDJ4CGdagYFAL5lORPwqLRb/TgJhHeK wYYAdTaGpwmToCq9CQf/2nriK+UB0JLeEX1XYBCU/JO43M4kJMxkovPeXwyvSfiGCkkee PYrf87aFbbkff6BwQT7cOMA2EheAWi8DsycbWai6ndo6mC2lAA8hlC2i1s74La9hnAFzs xSk+AO6+TfJ+oZ0AZCJcjcwnzbqX2Ox5kpSIJsPDtSCk5THWPPdV1zWqM5I0Bq20AJw== 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=zLkDLwEX; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=s9vh6g42; 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 3130B60A2625; Fri, 20 Nov 2026 10:17:14 +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=zLkDLwEX; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=s9vh6g42 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=1795169833; b=a2aX+BkALLS7tWUv/9T+ixtxeokeGpiQE4Bpq9OrAF3LA8hHgtB/6yvdQ6SZ1HIHpsfY ck4+dfsPv73BpvoZTip7Tynz/Fba3NaW7ZFbSO5PFvminNNUr3euNCOHtRHYfZeipLJ2z /fmgo23mU1tlvqSB2qssLtHRiTEsj0mVFrD+OhzdhwcR6izReQjNHFneKMw/wT5Y+rmuc L0oR/V3IxfT0CDZgEue1uuX/3udmvKH/idxb4my6O7SktPcPPsxYvdk9IieKcBwnYPwiF /OZbdeE+6w1SNDdDv2JGDUgdTmvqI67TJoRnFFGEY6Y8creqHWg3PYQWGNFsMxOtPPg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795169833; 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=TxSFGvzroXMP1yCKj5gXKh91OPMqff9Hzouu/ZStk84=; b=OZEbessnhch+mJKUq+5Rqk2DW/hRu/xrfnXpjkE/bvSA1YQjl6XGDPVYDvtXP6UnPfUx WMg0hj2hPlRjSu61H3QoId6E3a/uYD1/LPT3RVXoYCXA+o/j6qY7P3GYfUzeNJJ63515B Uhs1MDgZlr9W4DaZ+nM9EH319Mr0oOuwm0nGNObayy96HR/tyExnGo6ZLeGIKrI4KzzwT VCVpju/eLPZ6ohsQSTZOKa0o9GNOSJzCAWOohz53ZQDSKfI0Xity6q62LvWdZN/aq1GOr cabb3IawJxOKfVOdjuP1Xh3q761iGFFd0VeL/OGwUi/YDsNA8js2hG6Qjyk00rJ39xA== 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=zLkDLwEX; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=s9vh6g42; 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 3A253606A336 for <netdev@vger.kernel.org>; Fri, 20 Nov 2026 10:17:12 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3A253606A336 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=1795169830; 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=TxSFGvzroXMP1yCKj5gXKh91OPMqff9Hzouu/ZStk84=; b=zLkDLwEX8J6dR8052tprVYnIvT5Y/bvwq+gKm9NNe/Qxd4JR0GUoF96GKElPxFSVpeyfYU 0Om8GyMjl/88JlsNI+ET/0xdbN4lRsIuS6TjUuiE5/2G2Jp4vG4QKMtHlHRcCJNUQh85kK roAmnEHlNkCANIpqdoQcbCP0hIPrrEfT0YyO/YXUp4E90xK5iUYgw0O7BwLdJC6oxlxCsi Vkwo6a0d57L6vxj1wpec0nALuHzKjhQ/wDo34spykRLEDOhOyLhlbX3ufQJiMwLy9n2/ks kFJGpJRQVzRLa7kXCLpETeZ2E44WXWq94RHx9SfIvXjP+G0tC5e8N3E6zeDxqQ== X-DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1795169830; 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=TxSFGvzroXMP1yCKj5gXKh91OPMqff9Hzouu/ZStk84=; b=s9vh6g427ul6mWj5yZvaOUPwrw4aHWW3/Vj6ZOGw/xZG87ljNv9tbHBn4Y2R2z5Cb+IKV1 yGD+Jo9kelwpxWAQ== 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: <20261120-hsr_ptp-v11-0-264c88f4f1d0@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