Article View: linux.kernel.netdev
Article #11036[PATCH net-next v10 4/8] hsr: Drop received PTP packets
From: Sebastian Andrzej Siewior
Date: Wed, 04 Nov 2026 15:10
Date: Wed, 04 Nov 2026 15:10
101 lines
13527 bytes
13527 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.
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:
<20261104-hsr_ptp-v10-4-2c4a38ad973c@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-356537-linux-kernel-netdev=dewy.ruReferences:
<20261104-hsr_ptp-v10-0-2c4a38ad973c@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-356537-linux-kernel-netdev=dewy.ru From: bigeasy@linutronix.de (Sebastian Andrzej Siewior) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next v10 4/8] hsr: Drop received PTP packets Date: Wed, 4 Nov 2026 16:10:40 +0100 Organization: Usenet Network Message-ID: <20261104-hsr_ptp-v10-4-2c4a38ad973c@linutronix.de> References: <20261104-hsr_ptp-v10-0-2c4a38ad973c@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="3417806"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:KQLAQvCrUtZ/aBaZ8I6/yX+8pmU= sha256:2vaKH+Qxbsl3irVmCHekeT1y7FC6wcpNpZLaxZ15LkQ= sha1:1M4sHZOm84AAqKmG3tklSDivnjs= sha256:5cbP65am/2k0trC3R41WTwc2Gcb+35JkRSF9Mku2Nws= 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 DCB4E112C30; Wed, 4 Nov 2026 18:18:19 +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=Pd69AWE9; dkim=neutral reason="invalid (unsupported algorithm ed25519-sha256)" header.d=linutronix.de header.b=ZIj+z0Qc 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 5qoD2QrxSzcR; Wed, 4 Nov 2026 18:18:17 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-356537-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 DCC9F112BE8; Wed, 4 Nov 2026 18:18:03 +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 BCF8F27C44; Wed, 4 Nov 2026 15:11:16 +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=1793805061; b=zop1jJoF8XWLdkrC7prXNCnEBu70tF/JM58Sfzgq1sT6nCjr6uDIL9wJXgHRGKjtVFLI 2dvFFZ4ON4IlVVnH+OxIjIm3Qb4Q8ZvkfP9pjRP9vd3JTK6Sux7KqVlPxYi025RKF2c9w macgoS/8QVQ4Oi1thk87XD/DZGQLryL9wDrlRMfLusfdGomAliAoXJzZu5Wt9riAUmaK6 DqddhcqjMg4lQFHF/Rg3ucM8/QYTwE/Z5PwLW1Bz1SYkSIoMCjGsljUv5KCv+Ks7Tms09 Bxfpbyk66h40BiF4RUIPjUkb5T0vnNjpq35d6llecKS5ycx5T/hDrZFepQUx5U+wOBg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793805061; 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=B3GJZaJfM7BaQoOKyyMag0j1vgRY7QSdAOOCj79Pwwg=; b=Wr749kOC9DhcsJD5QpKpPnJUYq4gZI11E1hDmwpNFvq3XmK1YrrstwcUSWjNHKQEOR43 bILH9WV04Z5kieCMSeOWj1bOSNY3xh09JwD0wGdEKmfFG2oinzRUlZ5s9btDyokGTIz+K xJ98K6+i6VzlVj6l88eC9StUcodjp+Nd07yZgYsafJis/lcvOLIOlukXXkDw9wA1+LHjX R8I74rKqAczDwbHQb6itODeHR6xwRfdOQlKUc6ccrtqdDWWNGZv/JOW3X2EqvUyI4xFCb L8FXTN6d1N3KpKb+X3z/FsJpQEdLlfswW8oxD8hPmolmWesD2w6E+n6pqeFfxXxQoIA== 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=Pd69AWE9; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=ZIj+z0Qc; 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 2D57A606A32E; Wed, 4 Nov 2026 15:11:01 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=Pd69AWE9; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=ZIj+z0Qc 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=1793805055; b=XSqsd2EMXajn/lx67MjeibBoXwd45UK6WjmWeooj78yJAvvbsKukAdMbHinDVkHjUTz7 8vzd4yogBRhixxc+OCIANiFGRzY9LvVTITyKEfgbbzkgCbXxocxGPerve9+q8yNCiXKim 6RNGkUQm88TGjLcD78+Gv7eYsXpWgvkN9e5mtOBcVDBIh0KWur9mJ4iGSN0gNKV60tIsO SYZIb7ayjvHt9/k6XNv8Azy99qWvI+IeIghsi6jEkGLW0b4MqjpCu9nu58eMlIeLlHxi1 YtKoVoKmcB3vUD2bhrMCDTpw0FTBSuWughlj2b9Q5aquhu/n1CyijhumIVuy1VVm0nw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793805055; 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=B3GJZaJfM7BaQoOKyyMag0j1vgRY7QSdAOOCj79Pwwg=; b=Y5N6l3ds56mrtp8uKa4UKMzd/rNjdqKDByLMjfBTLPlVJx8FxFhYMHxKPM2ZNa+90K8j JIRGZpNc3ZWVOCjiBssnGTPzTTF/9r6OsfmC3JJuSzyTtRjA9R+AOrYdzH+ZXjx4wvM8r Y6QCwS6HOayPVMQ3hOZLWft688QZGzfTzE3qGVXMe4CZ2NBm7LDf2RAGbcL7wIRlSF7am 2lCFdcpAn3ZYwkAw9HD0YaBRg0iFpXj9hec+3ayOYRc+Vpg1quPjXQw35xU7S2rK+0RYG Dxv0WQNZ+ZdKWaF1+Mc39dsd4yZmHklTOr4cJnHXLq1L9ud5UaLkGi0U1QgDti4+6Tw== 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=Pd69AWE9; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=ZIj+z0Qc; 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 9B4E8606D802 for <netdev@vger.kernel.org>; Wed, 4 Nov 2026 15:10:54 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9B4E8606D802 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=1793805052; 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=B3GJZaJfM7BaQoOKyyMag0j1vgRY7QSdAOOCj79Pwwg=; b=Pd69AWE9lXhZW7tRh15AXww/np3Z/04F2bpLlLt+/36R/6ZcqB3BCOwJX4ixwYazVjhQ1R em7RsuDtmJNxKZLB/Iibuh75V3hQeo2/EXviheqxLjfBYxAmSVagyTte2CWAGtYlPDNdPE H0mHsqKtp/I0OwjdtZw8sfcPoRcz86E53L3aQBUA+d6MapE2CDZpJ5cHL0HWVXSbqXeoKG y0B4K2jpSv2E+82WWcICtBVP5xBeUUCqr9NReE6gCcCx5FWBGnr/DAgc1MhmLLNyOoTSgL 8w4T1NxrSGnFrtj1EnUYhdVoNVw0W5w2V5BvxFFMWNLLnnLunPgcSs3KF1WB2A== X-DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1793805052; 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=B3GJZaJfM7BaQoOKyyMag0j1vgRY7QSdAOOCj79Pwwg=; b=ZIj+z0Qc+QRYMKys35dUCq4FlzB9/AiIgfzUu7BCaxVvUvHIN+c415OdujQfboXJJ6q+O9 Hnd/0yLRafQBv9Bg== 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: <20261104-hsr_ptp-v10-0-2c4a38ad973c@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