From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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 ; Tue, 1 Dec 2026 08:55:28 +0000 (UTC) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3CBE1F000C1; Tue, 1 Dec 2026 08:55:26 +0000 (UTC) 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== Subject: Re: [PATCH net-next v13 3/8] hsr: Add a magic header for sending PTP packets From: netdev-bot+sashiko@kernel.org To: bigeasy@linutronix.de 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 Date: Tue, 01 Dec 2026 08:55:26 +0000 Message-ID: <179611532644.3146.17870747976027282649@kernel.org> In-Reply-To: <20261130-hsr_ptp-v13-3-598326208fc5@linutronix.de> References: <20261130-hsr_ptp-v13-3-598326208fc5@linutronix.de> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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 > #include > #include > +#include > + > #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 instead of , 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