🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #11038

[PATCH net-next v2] ip6_gre: fix changelink conflict checks for L2 tunnels

#11038
From: Xia Yan
Date: Wed, 04 Nov 2026 15:10
95 lines
12539 bytes
ip6gre_changelink_common() calls ip6gre_tunnel_locate(), which only
looks for ARPHRD_IP6GRE devices. The same changelink helper also handles
ip6gretap and ip6erspan devices.

This lets an L2 tunnel change its parameters to match another L2 tunnel,
since the duplicate check looks for an L3 device instead. Incoming
packets can then be delivered to the wrong interface. An L3 tunnel with
matching parameters can also make a valid L2 update fail with EEXIST.

Use ip6gre_tunnel_find() with dev->type, as the newlink paths do. Skip
collect_md entries while walking the bucket: they can coexist with
ordinary tunnels with the same lookup parameters, and their uniqueness
is checked through separate per-net pointers. Keep searching past them
so that a real duplicate later in the bucket is still rejected.

Found while comparing the duplicate checks in newlink and changelink.
Confirmed with ip link commands. For example, with an IPv6 underlay
named under already configured:

  ip link add tap1 type ip6gretap local fd26:106::1 \
      remote fd26:106::2 key 100 dev under
  ip link add tap2 type ip6gretap local fd26:106::1 \
      remote fd26:106::2 key 200 dev under
  ip link set tap1 up
  ip link set tap2 up
  ip link set tap2 type ip6gretap key 100

Before the fix, the last command succeeds and received frames move from
tap1 to tap2. After the fix, it fails with EEXIST and tap2 is unchanged.
The collect_md case was raised during v1 review and confirmed with
namespace tests. The reproducers use existing interfaces without kernel
changes or fault injection.

Tested under UML with standalone namespace tests for ip6gretap and
ip6erspan, including duplicate updates, L2/L3 coexistence, IPv4/IPv6
traffic and normal updates. Additional tests cover both ordinary and
metadata creation orders, all four L2 kind combinations, a real duplicate
behind metadata, and L3 ioctl changes. They reproduce the collect_md
failure with v1 and pass with this change.

Full x86_64 W=1 builds with allmodconfig- and allyesconfig-derived
configurations also pass, with unchanged warning sets.

Signed-off-by: Xia Yan <yanxia@cmss.chinamobile.com>
---
Changes in v2:
- Target net-next and drop the Fixes and stable tags, as requested by
  Ido Schimmel.
- Skip collect_md entries during lookup to avoid rejecting valid updates
  and to find ordinary duplicates behind metadata entries.
- Extend standalone UML validation to cover ordinary/metadata ordering,
  all four L2 kind combinations, and L3 lookup paths.

v1: https://lore.kernel.org/netdev/20261028115710.27806-1-yanxia@cmss.chinamobile.com/

Runtime and build validation used net-next 7b6ab4dbc156.
Kernel selftests were not run.

The allmodconfig- and allyesconfig-derived builds had WERROR, KASAN and
KCSAN off. The allyesconfig-derived build also had KUNIT_ALL_TESTS,
MCTP_TEST and MCTP_TRANSPORT_USBLIB_TEST off. The full default-to-derived
configuration diffs and the unchanged before/after warning sets are
retained in the validation archive.

 net/ipv6/ip6_gre.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index b5d6ed8..07f7220 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -306,6 +306,9 @@ static struct ip6_tnl *ip6gre_tunnel_find(struct net *net,
 	head = __ip6gre_bucket(ign, parms);
 
 	hlist_for_each_entry(t, head, hash_node) {
+		if (t->parms.collect_md)
+			continue;
+
 		if (ipv6_addr_equal(local, &t->parms.laddr) &&
 		    ipv6_addr_equal(remote, &t->parms.raddr) &&
 		    key == t->parms.i_key &&
@@ -2055,7 +2058,7 @@ ip6gre_changelink_common(struct net_device *dev, struct nlattr *tb[],
 
 	ip6gre_netlink_parms(data, p_p);
 
-	t = ip6gre_tunnel_locate(net, p_p, 0);
+	t = ip6gre_tunnel_find(net, p_p, dev->type);
 
 	if (t) {
 		if (t->dev != dev)

base-commit: 7b6ab4dbc156e2f96419715130b3d5738a306c93
-- 
2.39.0.windows.2
Technical Details
Message-ID: <20261104150330.70963-1-yanxia@cmss.chinamobile.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356530-linux-kernel-netdev=dewy.ru

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-356530-linux-kernel-netdev=dewy.ru
From: yanxia@cmss.chinamobile.com (Xia Yan)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v2] ip6_gre: fix changelink conflict checks for L2 tunnels
Date: Wed,  4 Nov 2026 23:10:18 +0800
Organization: Usenet Network
Message-ID: <20261104150330.70963-1-yanxia@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3418050"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1://0+Gf/jlmilLaQbvwYqCvQNmRA= sha256:bphtiLuK243CVUVysPNxwXzFt5iqx5TurRfA/4iVE28=
	sha1:W88FUqpdfhWSBfcYPFhCKqdh7Ys= sha256:2K12tMVkOHna7kckOCjXwpEQdbUx8/UF7jLDaNsEZsU=
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 EDC52112C32; Wed,  4 Nov 2026 18:19:00 +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 GTfR1nFU60tl;
	Wed,  4 Nov 2026 18:18:55 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-356530-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id B2C9B112BE8; Wed,  4 Nov 2026 18:18:40 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id C3EEE29B5D; Wed,  4 Nov 2026 15:11:15 +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=1793805061;
	b=goymLvQcPR5livKiaxnUupP8uXI/uefNsw3sMhr6J+Ls6ERJrpRsgg2oR6AGV5Eoa4Qf
	 Y/nZuoj9fttcvbjEWVkGNCRCW9XbKc983+LC+wgwAmiUql/GWYGP/4BHH5agKG0ul5ycD
	 6TKDKXXdp+XYPOqDV1cPXWw5K/aoK59ttKd9245sQvcMkFLh5bIccVaXhpUoK3ncpXgB7
	 bLq4b1DyNzMyukDjMrgrdhvzKIqP7QH4/Ado/4xFByEJjRR84fyQ8Akh/L3z4cO3l26lP
	 b/d0GEB0SS55RgAvJ446bA1P8Wj3Z59HKoKtTpzzstd7csHQYvtLbHZ8dObzAQihzWw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793805061;
	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:
	 X-Mailer:X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=INoEaO6i1XuDk1klXJSyLtLXz/khjGFC70VaxLfFDy4=;
	b=0UC0Exmlm6DmAPRYxb+7EYoHCz2S1cvP2qj0ZI1w/XgAO0BWIewUB24PzODDoVzKnSd3
	 /X4JiKMA/A0eCXRpUjlXIRXN29IkzFMfhxI1Zm7u2I2UZGUTSUDyqSM/i1TyKfFyGO5L1
	 TML4EpIBMjqbTPrOW6RTu17mLAw8TYcGCmoFYI9SK/tQKm/hFZC81R6NFlCZT1/gh8VoU
	 NZOSoY4Nw3mxQnNxy9/oIDT0HeRd8H2iEHyqoNkbbmPlxUSNmxie8msaOTMdPTcH0s+Ws
	 k0QqFuKMF2n7+0ieri9/wweI0ZaBc1YwIvcMFwOTagg2HvXTfoBsyenc3R9R3mu6Nsw==
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=ITte3e9L;
	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 DB5DD606D827;
	Wed,  4 Nov 2026 15:11:00 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=ITte3e9L
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=1793805042;
	b=Q3efE86M1ZEVdpxXkUvRg4VDcrIxp6tpAzplHuyRVfPOE24e41rDCBzfGEeQ67Vez4fQ
	 5Kj8QRxNV4RWQw6wzv1nfHD/Hkjwam1FTGQn3yKXPS0TVzIhACCjutBH1Jci713r9BgVY
	 2Al+F469N4dCVGpAs6gPetxjFc6dm/MzaLJWaPEPl0PphLWweP/QrFZxMfR2jEBrLwvJJ
	 N8M/sVASAmuoqOwwHmQgG8tiMK/LMdCdjhDpGVmxV1af62Wpwp813i/UJZGhNQ8PEaL2V
	 JLJUJmol+vbVM+mV+7bW1cxilt9pb+e9yifHO/if3R1NdmpyAddffevTyNTB39SeTxA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793805042;
	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:X-Mailer:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=INoEaO6i1XuDk1klXJSyLtLXz/khjGFC70VaxLfFDy4=;
	b=3ek7RwcbcwhGAhfyIDR46JMjk6JBiAsXKerxhA2oT7L8Y+9Xi2Nzl1jLvQISbjygAKdz
	 sgAKTtdbXL8Sp7fHOg2n1zT/zrgFoETFB+hwwSpXJO+kDbhRaChHKHBy1qPdwFGCUZEtd
	 KuhjeN3+Wd8x3FEdByAUzsE1w9wD2V2/hwUs6AW3ZfMV481/VbibZSh8zkGL6s1gKT/Qa
	 EYeFOPlAsRacwK8ggJ69/VnqNMhISPWBTmELYbbwDK4457jo+RdgL+zAMZMlDhVYGzsmb
	 GNnxaZlMD6Xyuc/NbmL28hUwb/85qcmmOf1RXMreyHezzwocgB3Ms7GPuiUwaQNFzTw==
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=ITte3e9L;
	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 190EA606A31B;
	Wed,  4 Nov 2026 15:10:39 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 190EA606A31B
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=ITte3e9LXd+Hmk4ifU53fesRV4BbUy+MVBm9O9OqoX63jBa3sTckbxL1wexF9PMCvHsWYOVurdTEe
	 E8YLzQpVfy5FmaUqwCokozq9vS75ozaLuWOFVgd3n/yWEwDKXSgFdIXOjkSzlufy/5GLkkjaDJbmTM
	 n2ek/gkO4Lg1rVNw=
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 2ee66aeb4ae768a-6aea1;
	Wed, 04 Nov 2026 23:10:31 +0800 (CST)
X-RM-TRANSID: 2ee66aeb4ae768a-6aea1
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from localhost.localdomain (unknown[112.23.104.16])
	by rmsmtp-syy-appsvr06-12006 (RichMail) with SMTP id 2ee66aeb4ae444a-257ec;
	Wed, 04 Nov 2026 23:10:31 +0800 (CST)
X-RM-TRANSID: 2ee66aeb4ae444a-257ec
X-Cc: dsahern@kernel.org,
	idosch@nvidia.com,
	davem@davemloft.net,
	edumazet@kernel.org,
	kuba@kernel.org,
	pabeni@redhat.com,
	horms@kernel.org,
	linux-kernel@vger.kernel.org,
	kuniyu@google.com,
	xeb@mail.ru,
	yana06070@163.com,
	netdev-bot+sashiko@kernel.org
X-Mailer: git-send-email 2.43.0
X-Mailer: git-send-email 2.43.0
X-Mailer: git-send-email 2.43.0
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