🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27053

Re: [PATCH net-next v14 5/8] hsr: Use the port and header information in hsr_forward_skb()

#27053
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 17:55
168 lines
14158 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

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 commit message says the new behaviour "is only used in the
  pure software version" and that HW offload "need[s] to be addressed…
- [Low] Only hsr_fill_frame_info() (net/hsr/hsr_forward.c:680-686)
  handles the new has_hsr_header flag.

--

hsr: Use the port and header information in hsr_forward_skb()

With this patch, hsr_forward_skb() honours an egress port and an existing
HSR header supplied by the upper layer. A frame with a requested port is
sent only on that port. A frame that already carries an HSR header is
cloned and sent unchanged, skipping sequence number assignment, source
address substitution and the node_db lookup.

> diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
> index f49d962337f8b..1d1d75ed8cd06 100644
> --- a/net/hsr/hsr_forward.c
> +++ b/net/hsr/hsr_forward.c

[ ... ]

> @@ -570,6 +571,20 @@ static void hsr_forward_do(struct hsr_frame_info *frame)
>  		if ((port->dev->features & NETIF_F_HW_HSR_DUP) && sent)
>  			continue;
>  
> +		/* If this frame has a specific outgoing port specified (by the
> +		 * sender) then send it on this port only.
> +		 */
> +		if (frame->req_tx_port != HSR_PT_NONE &&
> +		    frame->req_tx_port != port->type)
> +			continue;
> +		/* If this TX frame already has a HSR header then forward the
> +		 * frame with it and don't add one.
> +		 */
> +		if (frame->has_hsr_header && frame->skb_std) {
> +			skb = skb_clone(frame->skb_std, GFP_ATOMIC);
> +			goto inject_into_stack;
> +		}
> +

[Severity: Medium]
The commit message says "This is only used in the pure software version",
but is that enforced anywhere in the code?

hsr_dev_xmit() parses the inline header for every ETH_P_1588 skb. It does
not look at hsr->fwd_offloaded or at the NETIF_F_HW_HSR_* features of the
slaves:

net/hsr/hsr_device.c:hsr_dev_xmit() {
    ...
	if (skb->protocol == htons(ETH_P_1588) &&
	    hsr_ptp_parse_header(skb, &has_hsr_header, &req_tx_port))
		goto drop;
    ...
	hsr_forward_skb(skb, master, req_tx_port, has_hsr_header);
    ...
}

The req_tx_port filter above then leaves only one slave. On a DSA user
port with NETIF_F_HW_HSR_DUP, though, the tagger adds the other HSR port
back:

net/dsa/tag.h:dsa_xmit_port_mask() {
    ...
	if (IS_ENABLED(CONFIG_HSR) &&
	    unlikely(dev->features & NETIF_F_HW_HSR_DUP)) {
		...
		dsa_hsr_foreach_port(other_dp, dp->ds, hsr_dev)
			mask |= BIT(other_dp->index);
	}
    ...
}

The full path is:

hsr_dev_xmit()->hsr_forward_skb()->hsr_forward_do()->hsr_xmit()->
    dev_queue_xmit()->DSA tagger->dsa_xmit_port_mask()

Would a PTP frame requested for port A only then go out on both ring
ports, with a TX timestamp reported for only one of them?

Slaves with NETIF_F_HW_HSR_TAG_INS raise a similar question. A frame with
has_hsr_header set skips hsr_create_tagged_frame() and is handed to
hardware that may insert its own tag. This depends on the hardware, but
could the frame end up with two HSR tags?

Nothing in this commit or later in the series appears to reject the
inline header when offload is active. The follow-up commit "hsr: Move
struct hsr_ethhdr to a global header" only exports the header so drivers
can handle this later.

Should hsr_dev_xmit() reject the request when the slaves have HSR offload
features, rather than quietly giving it different semantics?

[ ... ]

> @@ -661,6 +677,13 @@ int hsr_fill_frame_info(__be16 proto, struct sk_buff *skb,
>  	struct hsr_port *port = frame->port_rcv;
>  	struct hsr_priv *hsr = port->hsr;
>  
> +	if (frame->has_hsr_header) {
> +		frame->skb_std = skb;
> +
> +		WARN_ON_ONCE(port->type != HSR_PT_MASTER);
> +		WARN_ON_ONCE(skb->mac_len < sizeof(struct hsr_ethhdr));
> +		return 0;
> +	}

[Severity: Low]
Only the HSR fill_frame_info op handles has_hsr_header. What happens on a
PRP device? prp_fill_frame_info() has no matching branch:

net/hsr/hsr_forward.c:prp_fill_frame_info() {
	struct prp_rct *rct = skb_get_PRP_rct(skb);

	if (rct &&
	    prp_check_lsdu_size(skb, rct, frame->is_supervision)) {
		frame->skb_hsr = NULL;
		frame->skb_std = NULL;
		frame->skb_prp = skb;
		frame->sequence_nr = prp_get_skb_sequence_nr(rct);
		return 0;
	}
	handle_std_frame(skb, frame);
    ...
}

hsr_dev_xmit() passes has_hsr_header down without checking
hsr->prot_version. fill_frame_info() also skips hsr_get_node() for these
frames whatever the protocol is. On PRP, the outcome therefore seems to
depend on the payload.

If the payload does not end in a valid RCT, handle_std_frame() uses up a
sequence number (hsr->sequence_nr++) that the transmitted frame never
carries. The clone shortcut in hsr_forward_do() then sends the frame
unmodified.

If the payload does end in a valid RCT, skb_std is NULL, so the
"frame->has_hsr_header && frame->skb_std" shortcut is skipped. The frame
goes through prp_register_frame_out()->prp_drop_frame()->
prp_create_tagged_frame(), and prp_set_lan_id() rewrites the trailer that
the user supplied.

This does not crash: node_src is NULL, but none of the PRP paths
dereference it. Still, the "header already present, send untouched"
behaviour described in the commit message only holds for HSR. The
follow-up commit "hsr: Assign a socket for cloned skbs" says PRP is not
considered, yet the PRP device still parses the inline header and acts on
it.

Should has_hsr_header be rejected for PRP devices, or should
prp_fill_frame_info() handle it the same way as hsr_fill_frame_info()?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203-hsr_ptp-v14-0-1511ffd4c362%40linutronix.de
Technical Details
Message-ID: <179640695343.3146.6076172404925884597@kernel.org>
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377520-linux-kernel-netdev=dewy.ru
References: <20261203-hsr_ptp-v14-5-1511ffd4c362@linutronix.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377520-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v14 5/8] hsr: Use the port and header information
 in hsr_forward_skb()
Date: Fri, 04 Dec 2026 17:55:53 +0000
Organization: Usenet Network
Message-ID: <179640695343.3146.6076172404925884597@kernel.org>
References: <20261203-hsr_ptp-v14-5-1511ffd4c362@linutronix.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2823564"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:DoMqJV7kNDD6ZKOZoU9Xe7ev3a8= sha256:da2hz3unh4x6KnInT9eyAE12kv8+vzVRelr608flNTk=
	sha1:FFriUFToQc8Wn2uoCTIFMTE9c2Q= sha256:Cra87POm6yhCstbdflSfXO5zC1bSVvp7Kxx+PZ+KhpM=
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 45E82117C89; Fri,  4 Dec 2026 20:56:14 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.542
X-Spam-Status: No, score=-3.542 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.142, 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 hHsgeaxji7Ga;
	Fri,  4 Dec 2026 20:56:10 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377520-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 44003117C79; Fri,  4 Dec 2026 20:56:01 +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 71F7C67454; Fri,  4 Dec 2026 17:55:56 +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=1796406956;
	b=ibDyMu/yu57OCB/D5QaVUyE2LG5jzoM+Jif661FAB+hnNy0zf7xDF+A/dc1LzB5t9gI7
	 3o8UZFEkGA7/9AW/XKlq2O1rTN75uFEhXLm7hqvgCndYgTmkeor88Xo2gidFm8Gvthtwe
	 +tHqU53csDelA5GEpZiMEq84+L71uq9Tlec3l7kaFpkx+c5jvqzQ8w4wXOEIVFZH/mDnJ
	 GCcJ5JL2BIAetH/yn1298vAmneINJD+QfoCPwMie3gEM6mcH/JTuxqSGT3xTGcncnTi1d
	 2hG03S3H9wci3yAZkZFJN+yaL9y8I3Cwo8X1r8iqACAOVli1f+8pITPRO5U0G4M3CKw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796406956;
	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=o1mPc2+HCqmNQ+kJuVIR0c2yc2H9kZEPKjeUBf86KmY=;
	b=Vj41NWb9GGsBeXkbkNd7x+YK4nlTgc6sFzzAvFSkcXYTLV+Dzw/GLMcIplreV9W3igaH
	 cLgHDylBfDMbvR9rC1GeKWkCHE2BSeuga6khm1WFPrY3xdrsPK2keinYz/SQaxpa7SiN9
	 +WIlCcEo10yv1EtxBqehJ+epSmQAAJP0qYfsZfSUeDWo6GzBR3n5y3Af7Isui4K0eOOXj
	 uJ0/7YpckVuRSYDzix8WscUKxny+vMk0MK07rd4BMN9ETLCs9qkgxej+Td6qfub1T1z5B
	 MeLQ3yn2V9huZ1txqjpuDRT0DubBqeoJyniDX5Q7G2EHKNwqzYOb/IeCJOZxu581LQw==
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=XTbCp+bu;
	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 49388606A32C;
	Fri,  4 Dec 2026 17:55:56 +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=XTbCp+bu
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=1796406955;
	b=WWErr0sqqZ0zLwlbEgQMdP4siKi38Lv6KM6gCdXZ3AfYAAd4eC3IwmFoggQ0Pd9x0sRX
	 YY33x0b3N4g9BkBNNWBRN39iDd8291tShiPXNnp/16zXb4hfz0E1b4CJJ3FOcRKeIzBV4
	 YL32we/tF0Yf1G54iVnapRvBRwSt+AIYNTql1r4WdzL/EmcPZNtBZuwQAujzjdmmaDNTM
	 IrejU/j89adpXXWiRgM2w5vjbtENpjTFVDnULA9jaIAuf+ey3v5UpSkQDw33trvvPjEmr
	 noGBy+UFGqhhQTjkUF7tR5+HypBD7vVqfXdpVhJ5feAn+1Pt3l5zp9GI/HOjhgUJWIQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796406955;
	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=o1mPc2+HCqmNQ+kJuVIR0c2yc2H9kZEPKjeUBf86KmY=;
	b=3B5TjbRB8rwnhYqxQ6Km264S8zRV3rXy2trr7e/j4MBhFw2nU95gXqLb7NKGyzuKTdK2
	 kN9MSlewGzXxKGgyq9w6omLLWO4jxJbSRsQvx6FkRxXv9f9wFInNAPNJ+bU5F3ySVkYFq
	 67exWuYjag9cZx6XASZHiAF6R7MLUOFJh31bz1G/auCDlsMpzjOvUNF7bNnGCoB6xbiER
	 m6JoP+6y38Ofs0/g/XWmq35fN4SlzhF3CYIrrdbZx+t8XqpTbXMxJxD+Mjw/0JdmoO2/x
	 +PBa8DWIDN3aYgPHX4SJ3Kt6ewRQn5qcmb1YjEKY8PjZ/OZIvdEh2HhtvqShugyfzgg==
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=XTbCp+bu;
	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 65889606A332
	for <netdev@vger.kernel.org>; Fri,  4 Dec 2026 17:55:55 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE7141F00936;
	Fri,  4 Dec 2026 17:55:53 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796406955;
	bh=o1mPc2+HCqmNQ+kJuVIR0c2yc2H9kZEPKjeUBf86KmY=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=XTbCp+bue5U6II6iaVBfBqZwP/VlvEr0JOQROVDJn5iuHC8Hy0RhHwBeNNfSEB9Be
	 p9+fJT8mJGktVCPLQdVBpzjLSrsXcyMiwyU4b4Ib4Q4K1tBQ8Ry3I3MHj/RuUl3+aa
	 mwvn5JZbbpL+FikWDWxkRXknF4cXNVZZHLo6GzLQ3mk5IlxuS/o3U0FG0AeR3FYgbs
	 4pNUyPlzdXUX5dgxCvSwMTuEwfby+zOCMRfJrMBJYRmunU60PbZ1I3WQmTM2jYlYCa
	 9OwAKTJnnHO0HS307hScm1uPRy+mmROH9pqCMxbmBbYJM+rzPzTHiUhs0m9GpE1Tus
	 Z4hmMVEa+kK7A==
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: <20261203-hsr_ptp-v14-5-1511ffd4c362@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