Article View: linux.kernel.netdev
Article #22556[PATCH net-next v12 4/8] hsr: Drop received PTP packets
From: Sebastian Andrzej Siewior
Date: Wed, 25 Nov 2026 14:31
Date: Wed, 25 Nov 2026 14:31
102 lines
13540 bytes
13540 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:
<20261125-hsr_ptp-v12-4-9ddd2a73cb90@linutronix.de>Path:
mbox-mo1.pugleaf.net!srv.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-371401-linux-kernel-netdev=dewy.ruReferences:
<20261125-hsr_ptp-v12-0-9ddd2a73cb90@linutronix.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.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-371401-linux-kernel-netdev=dewy.ru From: bigeasy@linutronix.de (Sebastian Andrzej Siewior) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next v12 4/8] hsr: Drop received PTP packets Date: Wed, 25 Nov 2026 15:31:47 +0100 Organization: Usenet Network Message-ID: <20261125-hsr_ptp-v12-4-9ddd2a73cb90@linutronix.de> References: <20261125-hsr_ptp-v12-0-9ddd2a73cb90@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="228851"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:2EtDTDZw0WylBBDPKIMBw7iNgc4= sha256:aB7aIVGoVG9rJBmePL3nUjIC/bCRl1vCI04sV/1i0Rg= sha1:VRUOXovWX4WlUM1VO9sGbaDFRtk= sha256:7WcZ7wC2e6DhpDiSH39BoYROWnqThzi3Ek0oiOCyx8o= 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 12533125E73; Wed, 25 Nov 2026 17:33:11 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.15 X-Spam-Status: No, score=-3.15 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, URIBL_BLOCKED=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=aXbD/d2/; dkim=neutral reason="invalid (unsupported algorithm ed25519-sha256)" header.d=linutronix.de header.b=mal1/VUV 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 pjxguWs5Cnoe; Wed, 25 Nov 2026 17:33:08 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-371401-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 36AAD125E6E; Wed, 25 Nov 2026 17:32:55 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 92D4360A271; Wed, 25 Nov 2026 14:32:54 +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=1795617170; b=kS1r+Ch+dYAVmSP872cSHHgg+w2MpfgDiM6pO0fPlgeQbEY7/xO+NhmumeQUAvwZ7kds OKIILF55spuoM5QutkJLSgd2frxNmGF8gAlXaM/Z7NXhfgh4T9cKmFugT88GK7bxYf0Pg Cf/5LMesMzH3IkAZ0YG7CxfNTX61epvLe7yygl13T5S1qVUCwFbXk5vb26j6at3aHrS2G cYb+O4XCwGNIgiERohq8tBNNWFTlnMwtG5iG8Wm58WrRyQlRGr/forbC9OLmxcQvJY8Eq w14zw/+l+YCRDtq0aVg6VoVpyku56KFVikzjWwGepS1W0phbLEAbq7zyl+l1S7sIGzw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795617170; 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=C+1n7xBXvEi9keafIuSVjLbAmoF879Sj49vjxYhXJHZNZYELp1C+Vo7Y7nNKiQ5MhIip XQmxZH+WJ6vYTSKJnc6yErzDiawUV+hXU+/io01NXymwaEcbMKJr90OITbux3txmXxhCk jSNb2A9KBzUKA9oqHT3/F4JOy8iVeRmu2iMwily++MVu/LhNBuCXKxVGFp761j5VgWyn5 W7vja85BH5ds0FuwX1uAy/QmHRKwTYZnWgdp6wxysKy1la1Y4pEBZSwh4+50KDVd2aNB3 TJuXTWOy4UWf0lCNiwsotQdCKJx5eeN76Dv1LG+4DOT7OqCj6EwolqURldDKtYteHyg== 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="aXbD/d2/"; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b="mal1/VUV"; 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 A6C75606A68D; Wed, 25 Nov 2026 14:32:50 +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=aXbD/d2/; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=mal1/VUV 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=1795617169; b=QBAU7HeVzNNBXbyEcgc71Gd/wvB02V4AeYn+LWIobmfleREYjLS52ieONe//LGNa+wNP ZRODupCUmwQRgGUUDjX7YJCzYhvWHY6nIl+YYqAUx2cO+zyjIrZCdA1Xy2GM2aSuJFhjQ Nadl2UgJgwCrwV6PM7lbsVo0GFO2Lpw7CWlMJMtMY0UrsKDZbEXzeVgfU4Hl/DW9E8xRU Ovy714mHMVnJI/A+te2HwbNsT7suVfmYmviRsixBRQew9wG6meKYAED2cuHGVC3SdTWeE OYj3ei9bDfRdvHVDleg0bz1xKidFuneGz1EO5S3VWfVFryrHVytKt6uYwDf/K2W/ssw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795617169; 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=1wStnhZxm68dHcTPUZG51iYAA1YvzeWseW+AfQPPoKtH0LH+xgpAbqEYGaPEgQclk0Cm kj0NkJVR8AiDUqijAFohyMmTWOn9wwVA0IH8gxNcu8r0Z1PNN06fKpF8wTEav30teRdo9 Sw5mrUjtv0Mcc1CQVgah6J2W1tvSMlrrLctOiiGeyuquJgyDTqNSS7Yaka+0tzrKWpYMp WXsklO1WLryKP9hYe4z+L2Iecsg3bIJcIYYvgWktPpDTw/v93DqfX+FahmegFqpfO1xt4 YZUARREv54CWiveYtbpcWIZraBmKxy3sscqJn+ZE+N+E35iDIXCMCjOnwENHKPoAaDA== 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="aXbD/d2/"; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b="mal1/VUV"; 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 28080606A32D for <netdev@vger.kernel.org>; Wed, 25 Nov 2026 14:32:49 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 28080606A32D 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=1795617167; 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=aXbD/d2/D0+MjE46nHkz1cHDcN8tU6oKWF7k9hS9rE89qdcks4toFaPJm/yaOcARM8APzy pt+SmcP7eL6y8QKH0Gpd/AhBf3xyr55fYXxXQWI9xOcxIMa+300JRZJ6op8FUzWlRaE6r2 wE/Hv5AwFcVytmzwDDShUwN82zpTapp86eMYEsAt/c8GQWG2I0UNLYnM0DS91IWeCIc2Yq 6OKri4zvvmSGXFkQ0PRrxUwpXnA3AAhwkP4jlZ0LfaGaJ1o+qPC5GwhlYwaPlP8ORO4cDr k+AtAxLzXS9UghNBsYTHvzPQ+Pw+zJzNTu7QzjYxuUDBLVeEBaipEQFVGAabrA== X-DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1795617167; 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=mal1/VUVsT2XwmJmZPt0TyvSPnFQwOd0L40MX9Mi7S5RMfzcA+YfInDxCfhVP3tuUZIm00 08QllvOO9OffGABw== 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: <20261125-hsr_ptp-v12-0-9ddd2a73cb90@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