Article View: linux.kernel.netdev
Article #25096Re: [PATCH net-next v13 3/8] hsr: Add a magic header for sending PTP packets
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 08:55
Date: Tue, 01 Dec 2026 08:55
219 lines
16201 bytes
16201 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 2
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The new UAPI `struct hsr_inline_header`
(include/uapi/linux/hsr_ptp.h) is undocumented and only partly…
- [Low] `hsr_dev_xmit()` in net/hsr/hsr_device.c now drops every skb with
`skb->protocol == ETH_P_1588` unless `hsr_ptp_parse_header()` finds a…
- [Low] The changelog says the inline header is "mandatory if the ether
type is ETH_P_1588" and that "PTP packets missing this information…
--
hsr: Add a magic header for sending PTP packets
This adds a UAPI struct hsr_inline_header that userspace must prepend to
ETH_P_1588 frames sent through the hsr device. The header carries the
requested TX port and whether the frame already has an HSR header.
hsr_dev_xmit() parses and strips it, drops PTP frames that lack it, and
passes the parsed values to hsr_forward_skb().
> diff --git a/include/uapi/linux/hsr_ptp.h b/include/uapi/linux/hsr_ptp.h
> new file mode 100644
> index 0000000000000..95e905441ebdc
> --- /dev/null
> +++ b/include/uapi/linux/hsr_ptp.h
> @@ -0,0 +1,20 @@
[ ... ]
> +#define HSR_INLINE_HDR 0xaf485352
> +#define HSR_INLINE_HDR_PORT_A 1
> +#define HSR_INLINE_HDR_PORT_B 2
> +
> +struct hsr_inline_header {
> + __u8 req_tx_port;
> + __u8 has_hsr_header;
> + __be32 __pad0;
> + __be32 magic;
> + __be16 __pad1;
> + __be16 eth_type;
> +} __attribute__ ((packed));
> +
> +#endif
> diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
> index 59df647d2fd45..7e79d5b34e8bb 100644
> --- a/net/hsr/hsr_device.c
> +++ b/net/hsr/hsr_device.c
> @@ -12,6 +12,8 @@
> #include <linux/etherdevice.h>
> #include <linux/rtnetlink.h>
> #include <linux/pkt_sched.h>
> +#include <uapi/linux/hsr_ptp.h>
> +
> #include "hsr_device.h"
> #include "hsr_slave.h"
> #include "hsr_framereg.h"
> @@ -221,26 +223,81 @@ static netdev_features_t hsr_fix_features(struct net_device *dev,
> return hsr_features_recompute(hsr, features);
> }
>
> +static int hsr_ptp_parse_header(struct sk_buff *skb, bool *has_hsr_header,
> + enum hsr_port_type *req_tx_port)
> +{
[ ... ]
> + skb_reset_mac_header(skb);
> + if (!skb->sk)
> + return -EINVAL;
[Severity: Low]
The commit message says PTP packets without the inline header will be
dropped. This check also drops any ETH_P_1588 frame that has no skb->sk.
Could the changelog mention this socket requirement too?
The commit message justifies the drop by saying that sending PTP via hsr is
pointless because the requested timestamp is not routed back. That is true
for event messages. General messages such as Announce, Signaling or
Management (for example pmc -2 over hsr0) don't need a TX timestamp. Is it
intended that those get dropped as well?
Existing ETH_P_ALL packet socket senders are also affected. In
net/packet/af_packet.c, skb->protocol is set from the socket protocol only
when it isn't ETH_P_ALL:
if (proto != htons(ETH_P_ALL))
skb->protocol = proto;
Otherwise packet_parse_headers() falls back to the device header_ops:
if (!skb->protocol && sock->type == SOCK_RAW)
skb->protocol = dev_parse_header_protocol(skb);
Before the earlier "hsr: Add header_ops::parse_protocol" change, these
senders had skb->protocol == 0 and their frames were forwarded. Now they
reach the new ETH_P_1588 check in hsr_dev_xmit() and are dropped. The only
trace is the tx_dropped counter. PRP devices use the same path.
Should the changelog list every condition under which frames are now
dropped, and explain why breaking these senders is acceptable?
> +
> + /* need to access the magic header */
> + if (!pskb_may_pull(skb, sizeof(struct hsr_inline_header)))
> + return -EINVAL;
> +
> + hsr_inline_hdr = (struct hsr_inline_header *)skb_mac_header(skb);
> + if (hsr_inline_hdr->magic != htonl(HSR_INLINE_HDR))
> + return -EINVAL;
> +
> + *has_hsr_header = hsr_inline_hdr->has_hsr_header;
> + *req_tx_port = hsr_inline_hdr->req_tx_port;
> + if (*req_tx_port != HSR_PT_SLAVE_A && *req_tx_port != HSR_PT_SLAVE_B)
> + return -EINVAL;
> +
> + if (hsr_inline_hdr->__pad0 != 0 || hsr_inline_hdr->__pad1 != 0)
> + return -EINVAL;
> +
> + hdr_len = ETH_HLEN;
> + if (*has_hsr_header)
> + hdr_len += HSR_HLEN;
[Severity: Medium]
struct hsr_inline_header becomes permanent ABI once merged. Is it validated
and specified tightly enough?
has_hsr_header is copied straight into a bool, so any value from 1 to 255
counts as true. The pad fields must be zero, but this byte is not limited
to 0 or 1. If userspace ships with arbitrary non-zero values, can this byte
ever be used for flags later?
eth_type is never checked. It sits at offset 12, which is where
eth_header_parse_protocol() reads. For ETH_P_ALL raw sockets it therefore
has to be 0x88F7. Otherwise the ETH_P_1588 check in hsr_dev_xmit() never
fires, and the 14-byte inline header goes onto the wire as an Ethernet
header. Should the UAPI header or the changelog document this?
req_tx_port is compared against HSR_PT_SLAVE_A and HSR_PT_SLAVE_B, which
come from the internal enum hsr_port_type. The exported
HSR_INLINE_HDR_PORT_A and HSR_INLINE_HDR_PORT_B are never used, and no
BUILD_BUG_ON ties the two sets of values together. Reordering the internal
enum would silently change the ABI. Would it be better to validate against
the UAPI constants and map them to the internal values?
What does has_hsr_header mean on a PRP device? PRP has no HSR tag, but
HSR_HLEN is added here regardless of hsr->prot_version. That pulls 6 extra
bytes and puts the network header at offset 20.
Later in the series, prp_fill_frame_info() ignores the flag and the frame
is sent without an RCT. The "hsr: Assign a socket for cloned skbs" commit
also says PRP is not considered.
Two smaller points: hsr_device.c includes <uapi/linux/hsr_ptp.h> instead of
<linux/hsr_ptp.h>, and there is no Documentation/ text for the new ABI.
[ ... ]
> static netdev_tx_t hsr_dev_xmit(struct sk_buff *skb, struct net_device *dev)
> {
> + enum hsr_port_type req_tx_port = HSR_PT_NONE;
> struct hsr_priv *hsr = netdev_priv(dev);
> + bool has_hsr_header = false;
> struct hsr_port *master;
>
> rcu_read_lock();
> master = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
[ ... ]
> + if (!master)
> + goto drop;
> +
> + skb->dev = master->dev;
> + if (skb->protocol == htons(ETH_P_1588) &&
> + hsr_ptp_parse_header(skb, &has_hsr_header, &req_tx_port))
> + goto drop;
[Severity: Low]
The changelog says the inline header is "mandatory if the ether type is
ETH_P_1588" and that "PTP packets missing this information will be
dropped". Does this check catch VLAN-tagged PTP frames?
The check only looks at skb->protocol. For an ETH_P_ALL SOCK_RAW sender
that value comes from eth_header_parse_protocol(), which returns only the
outer h_proto. A VLAN-tagged or priority-tagged PTP frame therefore reports
0x8100 and skips the check.
The same applies to sockets bound to, or sending with, an sll_protocol
other than ETH_P_1588. In that case skb->protocol is whatever userspace
chose.
These frames take the old path and are forwarded on both slave ports
without TX timestamp routing. VLAN and priority tagging is standard in the
substation PTP profiles (IEC 61850-9-3, C37.238) used with HSR/PRP.
Should the changelog be reworded, or should the check also look at the
encapsulated ethertype?
> +
> + skb_reset_mac_header(skb);
> + skb_reset_mac_len(skb);
> + spin_lock_bh(&hsr->seqnr_lock);
> + hsr_forward_skb(skb, master, req_tx_port, has_hsr_header);
> + spin_unlock_bh(&hsr->seqnr_lock);
> rcu_read_unlock();
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-hsr_ptp-v13-0-598326208fc5%40linutronix.de
Technical Details
Message-ID:
<179611532644.3146.17870747976027282649@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer04.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374864-linux-kernel-netdev=dewy.ruReferences:
<20261130-hsr_ptp-v13-3-598326208fc5@linutronix.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer04.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374864-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v13 3/8] hsr: Add a magic header for sending PTP packets Date: Tue, 01 Dec 2026 08:55:26 +0000 Organization: Usenet Network Message-ID: <179611532644.3146.17870747976027282649@kernel.org> References: <20261130-hsr_ptp-v13-3-598326208fc5@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1665787"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:PjoF5IapbW2l7LXKe81xKXSRYW0= sha256:SwJnzz3IVL9ABQJORN+JNPKN9QNTXP6XYXP6/+eQ3X4= sha1:uq9B6UVdOL18ZXoyk02dF1EPzcg= sha256:e31tmKvFJOkV/Q2NCe5D6bOY0HSn2B+Xw6THMVEYy1s= 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 5AA641172E2; Tue, 1 Dec 2026 11:55:43 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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=kernel.org 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 tbxepqVyq5wC; Tue, 1 Dec 2026 11:55:39 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-374864-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 475E91172DC; Tue, 1 Dec 2026 11:55:30 +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 7763B25DE9; Tue, 1 Dec 2026 08:55:29 +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=1796115329; b=fbO8SBG1xUjA1L/JeeUMTyUAJnxKf/Is6BDOWHWoshKrt6qlXKA8qWGJ9MTtOZgvBrrA kcaGoWdjwZT7fuGN88IjyJkRPOGnjff2lmdQ9IdE13FFeI8Tjtgq4QhJnI/zTXb5A23hx Q8EQa9kdTC7JoJWthVJex4BJ0SZVk+6cdI2V0DuxAnNUfBrsTpRUa7+doEkHocb2pCsY9 i5Q+Ylv0n11YNnUUWohIuJppeSyzJwEmcwGsWOzWmwpIqH4tl41+z0Hf7mqR9hpQh3cEJ ia22AVEFx6dP6548EsjBUed+4VrVE++PxqLBSrIE6SeW71Y/M+tzpMNG26vGMKpSU6A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796115329; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=7RNKuUiQRvEjWKWHjaaoMbQONm0wEEDwc8jHHLVmqic=; b=fJqK9EFFiMDwUy11rIpx4POiJ5p55iuFEHkuVF3PISO4zf5HWCVbSbZY5h9dmmoZ9Kdf PW8xw9lnrkbJTnhKadUJiRx0Qtt6mKOajOyAHOLoTUudhOApRdbmU0hQQ1YSDxKeMXx94 Gsy3kH4I7ubQhVte93v5f7ZnT4pYVYXLF7SzFSdVSBcakg2P4SDu9jvDZTrOq2B6v5Z7Y rvWqdS5F7Y7sjtTuj1jCYs/RC6BvWIzZq6SSBQWMOGVg7wq26Fafyl4AxvlkxlsSloF9P 9RfYlJtTcJurUuAj9ig+gNJj8R3kVOWFpYBYMRfm0mJrHp8VoMfkwVVv3bkRSswFgzw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oXATGULS; 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 3881F606A32A; Tue, 1 Dec 2026 08:55:29 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oXATGULS X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796115328; b=yTmTzA+zhvsMd/vD4JsoZnDGEW21TqPOvPr3xtyf5JF08e6Lvtziy4Auxyv9BIyGpu+m /JRUx6n60XYUl+cAg7qzc3NpqlbmV7IlQtCe2DHFoidseyT6M6W974eDRiM++Wy0G2UHj J12unUg+eOUDBexE/cAfHAdnyK8YhaXjAz9l5uB/SUeFrEYZ6b67b3toku5mLTzMYBVoj RHuwjHkD7KxrWMf1tVF2dGmqlx+JcKB3g83nNrLnBht37E3VixLOhFrAKodsazGSDYy02 Tn9bL6Tq2LJcaMpnu40O8TtKG8KkxZaYbixR5QO38rQR8EMs4hNeS5Dg6tGeGoo8l/A== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796115328; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=7RNKuUiQRvEjWKWHjaaoMbQONm0wEEDwc8jHHLVmqic=; b=y6s4OwYy1puIAy26TFNHHCHvr4DMHfudk5na9HzDjXURt3Lje7M4UonE5JD1ZOYxI4Tv m9qemHJ/4b7LQWYDnAxLZcBnF+XbzIw7hxwtLfAX0vLSRni3WZndJ22BrJh1wWCkn86gF 8+9E+Wu7gMdmcqpdHQxVEEOgjxBdJqGa1GMKyJK4xPFrZZwNv4zI7mLtI4exgJlWEREFA K7X5zzaT//Z62zz/6m2+7kzlIGm82D+7jmh3gr1k47TyaRDroz7XsxNcnZKBRFc80VQ5u zCwm2eJfkP23TYl0zCV5osfEklqxpNY7Dw5CdPQ6S4/atG5LvtmLIkTHusKOsw50A2Q== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oXATGULS; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57414606A332 for <netdev@vger.kernel.org>; Tue, 1 Dec 2026 08:55:28 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3CBE1F000C1; Tue, 1 Dec 2026 08:55:26 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796115328; bh=7RNKuUiQRvEjWKWHjaaoMbQONm0wEEDwc8jHHLVmqic=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=oXATGULSFmqRpOaUV3hX9Vr+LBQJoeQ0/ffqqOk8aflh0i4UjEtHvRUjom2UYmxFw d9KkaO3inh+9AUEp7ron+gEwVFUZA5XRzXmKjbrXqmet+Hp6ZaAsQue4aZpp3wwYWd 14p/Gqn9Kpa21qsToNlziYc5aP9rL50/ZF5T7ei/57S7WRs55DsrkwEqzkO7U7NW7b zH1paLR6V6sZREnfCSVQtYmwf2itWZwDmLfs/TvkhIquPW+N2+FAF40puRd4VenFl0 mTwB7wIePL9+uEfB5mK4ywZO+9n1Q/l0xIVSt72uGcMXUWWelo2LbhhIuI8NMeBzA3 tYdNZbitEX6nw== X-Cc: netdev@vger.kernel.org, j-rameshbabu@ti.com, andrew+netdev@lunn.ch, danishanwar@ti.com, d-qiu@ti.com, davem@davemloft.net, fmaurer@redhat.com, kuba@kernel.org, neelima@ti.com, pabeni@redhat.com, praneeth@ti.com, pratheesh@ti.com, richardcochran@gmail.com, horms@kernel.org, vigneshr@ti.com, willemdebruijn.kernel@gmail.com, daniel.machon@microchip.com, edumazet@kernel.org X-In-Reply-To: <20261130-hsr_ptp-v13-3-598326208fc5@linutronix.de> X-sashiko-severity: Medium 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 X-Received-Bytes: 15942