🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #14855

[PATCH net-next v2 1/2] ipvlan: fix RX byte accounting for local traffic

#14855
From: Xia Yan
Date: Thu, 12 Nov 2026 02:56
51 lines
10657 bytes
For traffic between ipvlan devices on the same lower device,
skb->len already includes the Ethernet header. Adding ETH_HLEN
again in ipvlan_rcv_frame() overcounts rx_bytes by 14 bytes per
packet. ipvlan_process_multicast() does the same for local broadcast
and multicast traffic.

Packets received from the lower device have had the Ethernet header
pulled by eth_type_trans(), so their counters still need ETH_HLEN.

Use the existing local and tx_pkt flags to distinguish these paths.

Found during a code review of the ipvlan receive paths.

Sending five IPv4 UDP packets with 32-byte payloads between ipvlan
devices in separate network namespaces increases rx_bytes by 440
instead of 370. With this change the count is 370. External RX byte
counts are unchanged in the same tests.

Tested before and after the change with custom IPv4 and IPv6 UDP
tests in UML, covering L2 unicast, broadcast and joined multicast,
and L3 unicast.

Fixes: 2ad7bf363841 ("ipvlan: Initial check-in of the IPVLAN driver.")
Signed-off-by: Xia Yan <yanxia@cmss.chinamobile.com>
---
 drivers/net/ipvlan/ipvlan_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c
index 7ad12dc78..ba646293a 100644
--- a/drivers/net/ipvlan/ipvlan_core.c
+++ b/drivers/net/ipvlan/ipvlan_core.c
@@ -276,7 +276,7 @@ void ipvlan_process_multicast(struct work_struct *work)
 			if (!(ipvlan->dev->flags & IFF_UP))
 				continue;
 			ret = NET_RX_DROP;
-			len = skb->len + ETH_HLEN;
+			len = skb->len + (tx_pkt ? 0 : ETH_HLEN);
 			nskb = skb_clone(skb, GFP_ATOMIC);
 			local_bh_disable();
 			if (nskb) {
@@ -331,7 +331,7 @@ static int ipvlan_rcv_frame(struct ipvl_addr *addr, struct sk_buff **pskb,
 	bool success = false;
 	struct sk_buff *skb = *pskb;
 
-	len = skb->len + ETH_HLEN;
+	len = skb->len + (local ? 0 : ETH_HLEN);
 	/* Only packets exchanged between two local slaves need to have
 	 * device-up check as well as skb-share check.
 	 */
Technical Details
Message-ID: <20261112025619.563195-2-yanxia@cmss.chinamobile.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361471-linux-kernel-netdev=dewy.ru
References: <20261112025619.563195-1-yanxia@cmss.chinamobile.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361471-linux-kernel-netdev=dewy.ru
From: yanxia@cmss.chinamobile.com (Xia Yan)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v2 1/2] ipvlan: fix RX byte accounting for local traffic
Date: Thu, 12 Nov 2026 10:56:18 +0800
Organization: Usenet Network
Message-ID: <20261112025619.563195-2-yanxia@cmss.chinamobile.com>
References: <20261112025619.563195-1-yanxia@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="995322"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:FkJNMiK0MpuVBrej2Kt1EnMB51s= sha256:/DThNoKolDF3VuxWFhABy68D18DvqYHnHwjTbVw/QTA=
	sha1:N4msSTkaSRDWu5raIS+y6tC90po= sha256:FO4E4POuPfvSq2kfmqF47SR5TlN6pCDqrt93NSxgen0=
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 654B71140DB; Thu, 12 Nov 2026 05:59:26 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.751
X-Spam-Status: No, score=-2.751 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_INVALID=0.1, DKIM_SIGNED=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=fail (1024-bit key)
	reason="fail (body has been altered)" header.d=cmss.chinamobile.com
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 a2MQ3Lbl63nE;
	Thu, 12 Nov 2026 05:59:22 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-361471-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=cmss.chinamobile.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id F017F1140D2; Thu, 12 Nov 2026 05:59:12 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 5C81D32020; Thu, 12 Nov 2026 02:57:05 +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=1794452207;
	b=FI9c8j6KqK8CM4vQjq5clWq+I+wbJkY2KYSICtOiPxaCgXh79gt5OA3i1JcVI8sW57nc
	 xAASqTwg7bAjKbo0JIASAjkuHzftDdR0Sa6Yq/2RvqVy+bl7nw6sooxdTxRdreA6lh6SQ
	 qDKlsqJIQaojNZGQZvginckgRBcsH/zi341vKHAuyAcdOhPRNnjPqSrd5ql4EOY3PhfKt
	 Lb4Brv+vvxP55fDqSJwV3Sn+5PXQkYes/i/HdlKBml6WLE3eKdsLsoiI5hFcEqMEroRJE
	 ul2+ApKe56DpJEtZHtWFDnehwutWs2Y9SNlNb7OZCj+Ma8dJ0ZwwvNrOKT2Q2Seu7Ag==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794452207;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-RM-TagInfo:
	 X-RM-SPAM-FLAG:Received:X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:
	 Received:X-RM-TRANSID:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=oUPs9GlYH0/nBK76LefvoNogcOj2nXvq9zmlvxCeq5I=;
	b=U7gFymQjt+JAMBClDV4o/7eeu6+0lFhngosS2xRUxyWnQVC7iBf10ZiH+zS8ShfRNIG+
	 Yu5DAEl2KlLDMAZ5KWkEHj6nPsZjP75TwyUKO9D/F7VE9KsIISw1U9/66tEaqT34Reqvp
	 DfImZ2+QRE94XOg+jRjshFt2NV4N614ofMAuRpl4jcDHJ4pUepLy4Po+hBD0RsF0D+jsl
	 ecCHY3X5QCpCvCoY4z3Ui8Bh9H64q6lg5W881FQjm/bXp7bDzoGZqQYSNuFC2KtW0yj6h
	 s1zYR87ELBW5ILQW79AsC9qrbZBwJ9js8K4XIVAlPxV0cZTx/wc+E80ppGgkE6MVSCg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=Ap6VbWm9;
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	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 8EAC3606A333;
	Thu, 12 Nov 2026 02:56:47 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=Ap6VbWm9
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.151
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794452201;
	b=XXnXMdL0WbPgYQ4lmZZMxYtB3GRN08DDPefqKsrfQ+vhfvhUKJpy4tlvRQzuQTcNIOAJ
	 9Rx5oa61qMaHgSahI3S+32azcpqPIR5dB1YBUJbvw+t3os2iuogRb540agaLE6vnmPe/n
	 EbbqboNAWYQ3mBlCq1/Asv/HbwQTCTZIZ+UJm8b1xosjaZQY4qO/HedoigU2uzE9i8h4e
	 FH4WP4E3T0D9MwUbbzbQ6Jg+1214Dv0evwgRzKBhBM1fMa/cO9+Zz2B7a5Fwbg01GztbR
	 kvbdg3pNg+gEVQMbn8UHa+UvycUHDkAt+aYADkWhJGeniQ607Vf9Tm3NeBCoVxFy9pQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794452201;
	h=DMARC-Filter:DKIM-Signature:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:
	 X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:X-RM-TRANSID:From:
	 To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:
	 MIME-Version:Content-Transfer-Encoding;
	bh=oUPs9GlYH0/nBK76LefvoNogcOj2nXvq9zmlvxCeq5I=;
	b=sJ1sYPR115cMRzTpsOVDhfcytbkNGW+A/Xbjni7xLzYNvIuqzTlysSnZ88RfzAC3Zxdv
	 DqFfnPQ0B7cfliR8tieaHNLAkx2MzKwZ6SRYl5bUt48CSaVnC6stO5aoBOQEn6lANMFoa
	 IwmnDiPsRVCYu/UtYDVokjML4H1iQW2p/jf46CkXi0LNkV50eKKYd6IEM0jnOGB6272Ur
	 b7SLN6Cj0XNr0+aNNivdjJhToqn6ko0AplA5tBVShPO09pJCb82yYJumvJT7W3lsDXOws
	 xUksucua3qVxO9ChNVsIa/sEOYsSUEbBcdg25Wi01s9XSq10bigY3218XXHwTaFXC4A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=Ap6VbWm9;
	arc=none smtp.remote-ip=111.22.67.151
X-Received: from cmccmta8.chinamobile.com (cmccmta8.chinamobile.com [111.22.67.151])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 90C76606A324;
	Thu, 12 Nov 2026 02:56:39 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 90C76606A324
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=cmss.chinamobile.com; s=default; l=0;
	h=from:subject:message-id:to:cc:mime-version;
	bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=;
	b=Ap6VbWm9CIT6GBzEHWQ6wNH0IWYcbSfH/6WszoeknFHTIdtF47Ar94Q4WqyFUunwIWfzcAzW4j1iq
	 Gm6FYdVxz6YMlq4tHxVKJKqDuAbGUde/ehDyDk0RkEBlmNn8zfad1rw+MwaVp4lhdQPiaxyv4ER8bV
	 OmYQ72AGG54sRGng=
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from spf.mail.chinamobile.com (unknown[10.188.0.87])
	by rmmx-syy-dmz-app06-12006 (RichMail) with SMTP id 2ee66af52ae0ada-a981c;
	Thu, 12 Nov 2026 10:56:32 +0800 (CST)
X-RM-TRANSID: 2ee66af52ae0ada-a981c
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from  (unknown[223.108.79.101])
	by rmsmtp-syy-appsvr09-12009 (RichMail) with SMTP id 2ee96af52adee4f-f02eb;
	Thu, 12 Nov 2026 10:56:32 +0800 (CST)
X-RM-TRANSID: 2ee96af52adee4f-f02eb
X-Cc: andrew+netdev@lunn.ch,
	davem@davemloft.net,
	edumazet@kernel.org,
	kuba@kernel.org,
	pabeni@redhat.com,
	maheshb@google.com,
	arnd@arndb.de,
	kaber@trash.net,
	dskr99@gmail.com,
	linux-kernel@vger.kernel.org,
	yana06070@163.com
X-Mailer: git-send-email 2.43.0
X-In-Reply-To: <20261112025619.563195-1-yanxia@cmss.chinamobile.com>
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