🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #3922

Re: [PATCH net-next v9 2/8] hsr: Use skb_clone() while adding the HSR header

#3922
From: Sebastian Andrzej Siewior
Date: Fri, 16 Oct 2026 09:41
63 lines
9423 bytes
On 2026-10-16 11:09:40 [+0200], Daniel Machon wrote:
> > diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
> > index 7734a521a96c2..5862c05f52110 100644
> > --- a/net/hsr/hsr_forward.c
> > +++ b/net/hsr/hsr_forward.c
> > @@ -342,33 +341,40 @@ struct sk_buff *hsr_create_tagged_frame(struct hsr_frame_info *frame,
> >  		/* set the lane id properly */
> >  		hsr_set_path_id(frame, hsr_ethhdr, port);
> >  		return skb_clone(frame->skb_hsr, GFP_ATOMIC);
> > -	} else if (port->dev->features & NETIF_F_HW_HSR_TAG_INS) {
> > -		return skb_clone(frame->skb_std, GFP_ATOMIC);
> >  	}
> >  
> > -	/* Create the new skb with enough headroom to fit the HSR tag */
> > -	skb = __pskb_copy(frame->skb_std,
> > -			  skb_headroom(frame->skb_std) + HSR_HLEN, GFP_ATOMIC);
> > +	skb = skb_clone(frame->skb_std, GFP_ATOMIC);
> >  	if (!skb)
> >  		return NULL;
> > -	skb_reset_mac_header(skb);
> >  
> > -	if (skb->ip_summed == CHECKSUM_PARTIAL)
> > -		skb->csum_start += HSR_HLEN;
> > +	if (port->dev->features & NETIF_F_HW_HSR_TAG_INS)
> > +		return skb;
> > +
> > +	/* Ensure the cloned skb has enough headroom to fit the HSR tag */
> > +	if (skb_cow_head(skb, HSR_HLEN))
> > +		goto err;
> >  
> >  	movelen = ETH_HLEN;
> >  	if (frame->is_vlan)
> >  		movelen += VLAN_HLEN;
> >  
> > -	src = skb_mac_header(skb);
> > -	dst = skb_push(skb, HSR_HLEN);
> > -	memmove(dst, src, movelen);
> > +	/* The entire header area needs to be linear */
> > +	if (!pskb_may_pull(skb, movelen))
> > +		goto err;
> > +
> > +	skb_push(skb, HSR_HLEN);
> > +	skb_postpush_data_move(skb, HSR_HLEN, movelen);
> > +	skb_set_network_header(skb, HSR_HLEN + movelen);
> >  	skb_reset_mac_header(skb);
> > +	skb_reset_mac_len(skb);
> 
> It took me some time to realize why skb_reset_mac_header() and the
> csum_start adjustment were removed, and why skb_cow_head(),
> skb_set_network_header() and skb_reset_mac_len() were added. Could the
> commit message say why? Or maybe a comment.

If this is important, I could add to the patch description. The removed
skb_reset_mac_header() should be obvious.
The csum_start() removal and so on was mostly sashiko complaining about
one thing at at time and memove() got replaced with
skb_postpush_data_move() in the last iteration which I just learned
about myself ;) That looks like a nice clean up.

> /Daniel

Sebastian
Technical Details
Message-ID: <20261016094118.Mq6pgtly@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-347240-linux-kernel-netdev=dewy.ru
References: <20261014-hsr_ptp-v9-0-2d20a2a0f816@linutronix.de> <20261014-hsr_ptp-v9-2-2d20a2a0f816@linutronix.de> <20261016090940.a2ztkv6p3wtysk57@DEN-DL-M70577.microsemi.net>

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-347240-linux-kernel-netdev=dewy.ru
From: bigeasy@linutronix.de (Sebastian Andrzej Siewior)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v9 2/8] hsr: Use skb_clone() while adding the
 HSR header
Date: Fri, 16 Oct 2026 11:41:18 +0200
Organization: Usenet Network
Message-ID: <20261016094118.Mq6pgtly@linutronix.de>
References: <20261014-hsr_ptp-v9-0-2d20a2a0f816@linutronix.de>
 <20261014-hsr_ptp-v9-2-2d20a2a0f816@linutronix.de>
 <20261016090940.a2ztkv6p3wtysk57@DEN-DL-M70577.microsemi.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Injection-Info: usenet.network;
	logging-data="2731167"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:4xYOTIOvySZxa75m5g97acV2cuE= sha256:m0p9roi+nsR9HrjujU0PpzgJgX/1Houqu8/ezoDSvgM=
	sha1:OhHRgnxx3fKB1GvF9gLng5H5CzU= sha256:TVFQoDlg2ptZzgezaWUiTe8fdJBLUudwHmvR+JUdGZs=
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 BC6D51104CC; Fri, 16 Oct 2026 12:41:42 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -0.85
X-Spam-Status: No, score=-0.85 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1,
	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=E3e4cKmj; dkim=neutral
	reason="invalid (unsupported algorithm ed25519-sha256)"
	header.d=linutronix.de header.b=7pidpLK6
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 4X490LMbBLUX;
	Fri, 16 Oct 2026 12:41:40 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-347240-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 2015511048C; Fri, 16 Oct 2026 12:41:27 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sto.lore.kernel.org (Postfix) with ESMTP id 00E56601FF7; Fri, 16 Oct 2026 09:41:25 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 634AE3E558F;
	Fri, 16 Oct 2026 09:41:23 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="E3e4cKmj";
	dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="7pidpLK6"
X-Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D42D3009F2
	for <netdev@vger.kernel.org>; Fri, 16 Oct 2026 09:41:21 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1792143683; cv=none; b=pGGwykkBO1tuk3/RGyB+3/THbnEOHeNeICsU4SJ5yuXSfbWj06km5MJ3ZPVoeCkhp47WWjbUg91lHEGD/TM8bYSqaDz4AMgleCVdSaAYCx5N3VFmIiaX0bFQUrllooKA4sx5BG0+D0Lpr0FcOGkKUH9G3i0uNtHwoynHzVf5dy0=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1792143683; c=relaxed/simple;
	bh=gJCiGoLLKOmJpmZ9OZW7ZdzxjAATVbpJAQVVgRHL6xI=;
	h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:
	 Content-Type:Content-Disposition:In-Reply-To; b=MFIrgZdc0wcDzAMUxcoI7AYbQgh6BCLFhwiFd/IHo64l9DxjkRIUjmSml2Nz6eaXuLgWJ9o/gRHuAJbpK1yaPLBxmFlGwfdea7ew0kvWABcY07dZJD41JAiDbu0/DtqismA2tNS7LSFjlKYAvCw1XVz6yXPO+qa1wmgFDk76fmY=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=E3e4cKmj; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=7pidpLK6; arc=none smtp.client-ip=193.142.43.55
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=1792143680;
	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:
	 in-reply-to:in-reply-to:references:references;
	bh=Rm26KGue4PPLs6eD1Ge0A1+Hag972Tgpim1O9AKYkhU=;
	b=E3e4cKmjvUzHTzsEQ0Vjou7YGZvsjy9QVWJyvTtZ4mWJ9gecOKJVu/yknUk+y23eAqk8qE
	qmbexMfzM7owDchetwHv0QzH/IzOaZNXE4xQHVayocL87bJZH8PR2J9L08uPQbuE3DG738
	IaSR1jjJD+UAFpn3MtDaei1MrliqGIatevIezu11ooiVkDdGoiIGXLRCzMJxDbI3JvsV7w
	oX419ysh8/pw3sL0WPyW5HnyDUvJE26+3bK50PuayuSo3Gz7HLqxDVwsFhBNAjN27fI56w
	nTwYRS6ux7tpvRHNPJd0S8qNI8TmZCRglLOdQQvkuQ28tPKHnyb89s/w/TWPYw==
X-DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de;
	s=2020e; t=1792143680;
	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:
	 in-reply-to:in-reply-to:references:references;
	bh=Rm26KGue4PPLs6eD1Ge0A1+Hag972Tgpim1O9AKYkhU=;
	b=7pidpLK6Solet0vvJY0JOtguG7IhM4NSD3sY0USzUIEyEByGYKcL9dZrnmOIB5c+CcDMAy
	6TM31pMe7bgJ47BQ==
X-Cc: netdev@vger.kernel.org, "(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>,
	Eric Dumazet <edumazet@kernel.org>
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-In-Reply-To: <20261016090940.a2ztkv6p3wtysk57@DEN-DL-M70577.microsemi.net>