Article View: linux.kernel.netdev
Article #25362Re: [PATCH net-next v13 3/8] hsr: Add a magic header for sending PTP packets
From: Sebastian Andrzej Siewior
Date: Tue, 01 Dec 2026 16:35
Date: Tue, 01 Dec 2026 16:35
92 lines
13154 bytes
13154 bytes
On 2026-12-01 08:55:26 [+0000], netdev-bot+sashiko@kernel.org wrote: > Critical: 0 · High: 0 · Medium: 1 · Low: 2 > … > - [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… > > -- … > > + > > + /* 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? I think so. > 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? It is intended to be false/ true. > 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? It pretends to be a PTP packet so ETH_P_1588 is expected. > 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? Hmm. The ABI is fix/ exported via uapi. The reorder would break the parsing here. I would prefer the HSR_PT_SLAVE_A+B constants and the BUILD_BUG_ON() to link it. Is this something I should resend the whole series and send a follow-up later? > 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. It should not be used for PRP. > 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. I am not aware that uapi/ header must not be included in kernel code. Yes, no other documentation. Sebastian
Technical Details
Message-ID:
<20261201163528.clIypeY6@linutronix.de>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375211-linux-kernel-netdev=dewy.ruReferences:
<20261130-hsr_ptp-v13-3-598326208fc5@linutronix.de> <179611532644.3146.17870747976027282649@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375211-linux-kernel-netdev=dewy.ru From: bigeasy@linutronix.de (Sebastian Andrzej Siewior) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v13 3/8] hsr: Add a magic header for sending PTP packets Date: Tue, 1 Dec 2026 17:35:28 +0100 Organization: Usenet Network Message-ID: <20261201163528.clIypeY6@linutronix.de> References: <20261130-hsr_ptp-v13-3-598326208fc5@linutronix.de> <179611532644.3146.17870747976027282649@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="1766112"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:zdyNw638WZjwVd8BIN+JDffYvdk= sha256:GBPBKXikqHRUxkoqKQ+QC9RIjROF2FpaOdkdTpYxg1M= sha1:AN/Wxzlf4LzXoLlThANmPIO2y3k= sha256:NGy5uo6R2+/p1QOThdKnqwXBLVJgKgTRAbZA2cA5tt8= Content-Disposition: inline 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 2EC62117413; Tue, 1 Dec 2026 19:35:59 +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=L76lsOMF; dkim=neutral reason="invalid (unsupported algorithm ed25519-sha256)" header.d=linutronix.de header.b=R1LDukuW 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 mGSyU2P8CTyl; Tue, 1 Dec 2026 19:35:51 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-375211-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 2DDDF11740F; Tue, 1 Dec 2026 19:35:37 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 7A60827659; Tue, 1 Dec 2026 16:35:34 +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=1796142934; b=wTigeRI89ceaYbL6vi49U1VpIv/RHaZ5Dt4dPHc5/IfK+PRPobz4Cug+BEWxEm8DKCqx nZyA4392tw+F972TylIKjoWgDLWSJWJCqVM5PfVS0FCNTpVmMmGTNAJVyo4ILs7qUziyC 4ViJbICKIx9FGqe7qhLblvX84Ps0GhgVj9cgFwtY4aJzIjQxg0d/wZ5duCAkyKttUy1p9 aw1aMTzif7VS0bVItg9Rsc43EblDY6dfeF7wA5Wm/q/hcbnZT2kxos2JiGY9Y50Dzys/A 76uTHllY+jyEq3S40NB90MPzobDlA1gsBq1Atm852pKWuMOfTFATIpVJcd0sd7OjJMw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796142934; h=X-Original-To:Received:DMARC-Filter:Date:DKIM-Signature: DKIM-Signature:From:To:Cc:Subject:Message-ID:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Disposition:Content-Transfer-Encoding:In-Reply-To; bh=6yaIYA2qgS7y9GUdX0oVz+HjByMhid4aRgyinE/kPdE=; b=yz5IOL51J9ESOckGJFxFiELaxBuUHkZlHNxM8aoTtmWvwAgzt9LldHaEuuYSxEscG2wM BY8V15YWsMES8lVTBNQ32xkcuNY0D1xwwzu0jPPBaH45TKsux58Nnubfask9u3+TSrWj5 GXkxF+/aYAxNS5gre6hJ0IBsCYc4T1pPbnoXCNZqYyB2NEza+2Qkght/2A3BcKXnLStKU WirKyZUqjOMo8PdNxAknnmFaGIvTY2WZFaTelVD6UTRdkZk9M3ML/dWEvJxMF18L031fv +2B5YQRdl6FvZqjFQsIRDBDGzczZAJ5vBAEDC2ZwFE7yp7sO/OosuEmUVQv2SUDeSgg== 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=L76lsOMF; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=R1LDukuW; 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 E2F9C606A32A; Tue, 1 Dec 2026 16:35:33 +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=L76lsOMF; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=R1LDukuW 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=1796142933; b=jBhmT1GhEypfUXeZ/OWJYYKkztvAr56r2kIsafL+FSIkBsKVZkAi4CyMcxpWtipMzDmw r1Lh5xQbB5Sr2IHAif5sqcrjmBetU+5Tp+MgNPh2URsKaVWccRWldDkeSTnsEcXI5LpVp GQRR59QiSW6/gkzPXbbxyOzr18rgE2M2ZJ5xHDBTawd0sqj7pHAaDIG6fADGtTaLDhO+B IoMviw5WwaC+tdtwmqW8EEnkQlmmsjYWcsvvnmgyvuVUfXBqxPyNzcvejxb5QM64K7yfT 3dxN0QqprhEgmnXuV1qzT9D0kjj339rEJeRR5DIZpxsY3FcJy3LCxkHF12x5zyvbRdA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796142933; h=DMARC-Filter:Date:DKIM-Signature:DKIM-Signature:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=6yaIYA2qgS7y9GUdX0oVz+HjByMhid4aRgyinE/kPdE=; b=uyZX4ol+AqHxiTK8oELnoWiz/a0LVrNoCf0mFw3TZFNr2kZmqbcRjYxduw67sEJW60Ji M0vFkxVHs+bc79GN/SukFUpZRNptmuRjJbUb1ZOLq7UJV/SWKnyA3GizDDFnbl7boOX4O a+YiuD1+Lu9M4LYjvzxZEOQ/PeBHPpdFt32TSHaPOWtPaHfgAszl3tO6FpSy/0NnVEg2J ALF9sDhQJL08KQcvAPuruYA0qZKLZ+WdaDwc87YDqSqRtqLlA3fewkUhS00lA7KMicU/o RmwyzJU3rhc4vsS0cgQ6gmXQMDUcylFKi91mMc1jJBZUttW1/REmzw/4tXt5pfgluXA== 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=L76lsOMF; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=R1LDukuW; 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 8A4DD606A31A for <netdev@vger.kernel.org>; Tue, 1 Dec 2026 16:35:32 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8A4DD606A31A 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=1796142930; 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=6yaIYA2qgS7y9GUdX0oVz+HjByMhid4aRgyinE/kPdE=; b=L76lsOMFrbltnkblJFDRejWXCVj/+BKjelrMlX+AlwdR2SPG+0JCIHaDT5xSVW8IKR+yRW UxweWt/loczUgx8vJ5D37rNqnuw4Lk71w5T1YMIMJJsdXMz6noEEO0lftnyNr1j4Lplylk BjH0NtRm2uyTwFGFmithAFPrH8eS4uQ/q4rJbs0LiFquxgkTs8iWsKDh9Wj9x/nx9Xsrex ug/5iWqctJzY47HJ3YfmT1Ph0/nmLaW8EyNvNeLy5lqzh8JZ2oK4uMNDLCWahjlDoTQN7a +NEyRJie0FwMCDznrDQIzTiBYexO3d0bynT3eCXwl2dNItoX23hPxb/ibD2MqQ== X-DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1796142930; 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=6yaIYA2qgS7y9GUdX0oVz+HjByMhid4aRgyinE/kPdE=; b=R1LDukuWNHOpCRqO3tKBPKAjRIOos8qf8K8QHmuXO2svhz+DhcmzlWFxy40RS15yYzLKb7 HpEG0J7TaBTcKPBw== 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-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-In-Reply-To: <179611532644.3146.17870747976027282649@kernel.org>