Article View: linux.kernel.netdev
Article #3273[PATCH net-next v9 4/8] hsr: Drop received PTP packets
From: Sebastian Andrzej Siewior
Date: Wed, 14 Oct 2026 14:43
Date: Wed, 14 Oct 2026 14:43
98 lines
10677 bytes
10677 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.
VLAN tagged packets are not considered. L3 packets (PTP over UDP) is not
considered because it is not part of the HSR specification.
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:
<20261014-hsr_ptp-v9-4-2d20a2a0f816@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-346317-linux-kernel-netdev=dewy.ruReferences:
<20261014-hsr_ptp-v9-0-2d20a2a0f816@linutronix.de>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-346317-linux-kernel-netdev=dewy.ru From: bigeasy@linutronix.de (Sebastian Andrzej Siewior) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next v9 4/8] hsr: Drop received PTP packets Date: Wed, 14 Oct 2026 16:43:58 +0200 Organization: Usenet Network Message-ID: <20261014-hsr_ptp-v9-4-2d20a2a0f816@linutronix.de> References: <20261014-hsr_ptp-v9-0-2d20a2a0f816@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="2319041"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:eHKXkU8GTLX1JSdmTKtTXTfmYOA= sha256:3kHNjMmsScgx2cxLG/uI4S2u0Sl4aQOe0OJukoJ24Zg= sha1:O6Jse9f/0NScOB0xgDqA+wxZj7Y= sha256:QJxtIwHP0FAxROQvCiCKwLpztGdCBw4hGM7z6toYy48= 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 D0D3B110143; Wed, 14 Oct 2026 18:06:00 +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=KHi8YSbd; dkim=neutral reason="invalid (unsupported algorithm ed25519-sha256)" header.d=linutronix.de header.b=pigbROkG 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 wDxsCbu-7ixg; Wed, 14 Oct 2026 18:05:57 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-346317-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 13BB41100AD; Wed, 14 Oct 2026 18:05:44 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id 8FF512DB74; Wed, 14 Oct 2026 14:44:17 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9C2954B1BA; Wed, 14 Oct 2026 14:44:14 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="KHi8YSbd"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pigbROkG" 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 5471A54B1C5 for <netdev@vger.kernel.org>; Wed, 14 Oct 2026 14:44:09 +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=1791989054; cv=none; b=kOWVToHPn3vKf6XukBB0xKHdP6l8cAHFws6CgiEtUiuzVhmOcBVB1kmNvR93Nj5XpFwmBIwoeyvNNJRTLHcqHaHDm7U3OsyLbqFx8ADWGZEJ8ZPtJZsC+lNgvwIBgPE61pAHDWMGKFQXjNyq2BNg02RM0Y4REry6AzCNrtF8xMU= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791989054; c=relaxed/simple; bh=ItHZWa8f9H6c4EcHSDVx7iABp/1/RYlL9cKJ1ujkKAM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oil6mBnOlDuwF4SDTHXLV4p6cujaULodIhkdqFKXAaySf6IXFxr3TV8NZI6H0hFnXadFa/gFC5uzsnJ3PIJZc0DXWNq/yvi+MFdWSQmGIskDAYiaVMAE3CtlP1Y5N/ky6Wqq+VxrtatZ/VYwuUcM4dTxWYoS68OkzzcwbxrvgzY= 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=KHi8YSbd; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=pigbROkG; 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=1791989048; 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=vsPJvjOHxsnXO3qbskSb575mE9fZ07WzDedy1v2sTnA=; b=KHi8YSbdumTXgQk0sKRboABGZwEyV+bhybKdPt0HhFmLLT/kl2Bnjhx8xItNWQNdVtf0Co Z4Ym2xb+O3UmzwqrsJcfl63x/xZ+te7XGqkvIDZNBM/Ai4XB84guyE6V7Ui44uCC4irE0P pBawCa95BdF2DYJn3u4q7QTaPSQWni6SaveGK6Ows+vbzT9HR0uXlFtf18Bs4z+XIVAsRs jQ6UAH+u+SPutQqu3dl/M54Q5iQ4G38tZ5C8/UF0hOxzbdsk0VlWLZb/giBvlUjE9gWQhm tJ6Av/JHfRElSdDb7R8HYLdfGSiQP26p/f7KJkNQRYGLB6QTI5jp22VzoNoPlw== X-DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1791989048; 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=vsPJvjOHxsnXO3qbskSb575mE9fZ07WzDedy1v2sTnA=; b=pigbROkGYkiXScIjPa4sDthg4+my7I7Yu8Flx1n3fKk5+l+jijj1Xn+4peg5U6V514T6/9 zu1CBIkeZ5jSrIDA== X-Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>, "(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>, Daniel Machon <daniel.machon@microchip.com>, Eric Dumazet <edumazet@kernel.org> X-In-Reply-To: <20261014-hsr_ptp-v9-0-2d20a2a0f816@linutronix.de> 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>