Article View: linux.kernel.netdev
Article #15659[PATCH net-next v3] ip6_gre: fix changelink conflict checks for L2 tunnels
From: Xia Yan
Date: Fri, 13 Nov 2026 07:05
Date: Fri, 13 Nov 2026 07:05
102 lines
12280 bytes
12280 bytes
ip6gre_changelink_common() calls ip6gre_tunnel_locate(), which only looks
for ARPHRD_IP6GRE devices. For ip6gretap and ip6erspan, this lets an
update create a duplicate L2 tunnel or makes a valid update fail because
of an unrelated L3 tunnel. A duplicate can receive traffic intended for
the original tunnel.
Use ip6gre_tunnel_find() with dev->type for ordinary devices. A match on
another device, including a metadata device, remains a conflict. For
metadata devices, update the device itself without the ordinary
duplicate search, as newlink does. Leave the shared find helper,
newlink, legacy ioctls and receive lookup unchanged.
Check conflicts and unregistering before applying encapsulation
parameters, so these rejected requests leave the encapsulation unchanged.
Found during code review of the newlink and changelink duplicate checks.
Reproduced under UML with an IPv6 underlay named under:
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. With the fix, it fails with EEXIST and tap2 is unchanged.
Custom UML tests covered both L2 kinds, metadata updates with ip6gre0
present, receive interfaces and tunnel metadata, legacy ioctls, and
encapsulation state after a rejected update.
Signed-off-by: Xia Yan <yanxia@cmss.chinamobile.com>
---
Changes in v3:
- Keep the shared ip6gre_tunnel_find() unchanged, including metadata
matches, so newlink and legacy ioctls keep their existing behavior.
- Skip the ordinary duplicate search when updating a metadata device,
as suggested by Jakub.
- Reject an ordinary update that matches another device, including a
metadata device, without changing receive lookup or allowing new
same-key combinations.
- Check conflicts and unregistering before changing encapsulation.
v2: https://lore.kernel.org/netdev/20261104150330.70963-1-yanxia@cmss.chinamobile.com/
Review: https://lore.kernel.org/netdev/20261110205838.2246603-1-kuba@kernel.org/
Tested on net-next c88fd6989aea9237a60a4859139a265bfb7ddc0b with
W=1 UML builds of the baseline and this patch. Runtime checks used
custom netlink, ioctl and packet tests; kernel selftests were not run.
net/ipv6/ip6_gre.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index b5d6ed8..0a113bc 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -2046,28 +2046,25 @@ ip6gre_changelink_common(struct net_device *dev, struct nlattr *tb[],
if (dev == ign->fb_tunnel_dev)
return ERR_PTR(-EINVAL);
- if (ip6gre_netlink_encap_parms(data, &ipencap)) {
- int err = ip6_tnl_encap_setup(nt, &ipencap);
-
- if (err < 0)
- return ERR_PTR(err);
- }
-
ip6gre_netlink_parms(data, p_p);
- t = ip6gre_tunnel_locate(net, p_p, 0);
-
- if (t) {
- if (t->dev != dev)
+ if (!nt->parms.collect_md) {
+ t = ip6gre_tunnel_find(net, p_p, dev->type);
+ if (t && t->dev != dev)
return ERR_PTR(-EEXIST);
- } else {
- t = nt;
}
- if (ip6gre_tunnel_unregistering(t))
+ if (ip6gre_tunnel_unregistering(nt))
return ERR_PTR(-ENODEV);
- return t;
+ if (ip6gre_netlink_encap_parms(data, &ipencap)) {
+ int err = ip6_tnl_encap_setup(nt, &ipencap);
+
+ if (err < 0)
+ return ERR_PTR(err);
+ }
+
+ return nt;
}
static int ip6gre_changelink(struct net_device *dev, struct nlattr *tb[],
base-commit: c88fd6989aea9237a60a4859139a265bfb7ddc0b
Technical Details
Message-ID:
<179455350258.84965.17518172977020586093.ip6gre-v3@cmss.chinamobile.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362465-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362465-linux-kernel-netdev=dewy.ru
From: yanxia@cmss.chinamobile.com (Xia Yan)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v3] ip6_gre: fix changelink conflict checks for L2
tunnels
Date: Fri, 13 Nov 2026 15:05:02 +0800
Organization: Usenet Network
Message-ID: <179455350258.84965.17518172977020586093.ip6gre-v3@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="1314077"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:VNT3+1YwujeVfrwYOTftUDEB7wg= sha256:PdP4SqNAM35JtfttM8rTrstOozWT/WIBWYpgqKDnU+A=
sha1:IjLTzpKNsJ4cwt4W6aKAItpoyqo= sha256:htroCxtFN5u+9ENYTX71HZyRHt4pI32WvpVDW8/bilQ=
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 79A9D113DFA; Fri, 13 Nov 2026 13:08:06 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.85
X-Spam-Status: No, score=-2.85 tagged_above=-9999 required=6.31
tests=[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,
URIBL_BLOCKED=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 KKVPPB9XEmK1;
Fri, 13 Nov 2026 13:07:54 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-362465-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 A5520113DF9; Fri, 13 Nov 2026 13:07:43 +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 476141261C4; Fri, 13 Nov 2026 07:05:47 +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=1794553531;
b=VmsinkngbinphV6lCFUnHu9hDYI6d3UZGqDjykNT9YNTCkTHl+zfx4jrHIhychx1rm4X
wSK9W2cQvOWStrpKVcKMwUo5r0Uc3Ytektaz4aOk/MxmsilrQjiCUehg9ehCPFPTLQ47a
vm272W3MAlGDBtUk41OZM/WN1wKeJYaEEwG6/kB4L0DcNjR3w+2paWMLYK79HjRJb/hFs
LY+bAsO8L3JKiykYI1Z8Ek5edB3Y8KOBngzXtpIxQLuPlZs9JxNXkWJP4lVqpc0j8bqpd
fZj3KejU4I5TeIhNgp2mgGQcu9z+0kuOyz63CbTKKVtEhYommRDlbvXM/B7v5xlO6FA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794553531;
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:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding:Date:
Message-ID;
bh=PL2JrQrlFCZkPDlSoBfHNnVP+PHI384lIjGURt26NKY=;
b=5PZv1g/lB+LQbQsQVB36/hnD9bcLEdVAVcHf0DMlozIEQYzsu4plveIwLuCVDCK7HMLx
dsXjXQcJk503tlO80lPqRwPeWm7cmHhhfFAwXYLQWPECZAkTcjcaFrKHRQAgZmYCrrHIx
G5eyxn+SsSKrGWEvxbl9Itn8Js1UZrMYPbIWHkdiBPo37dW1Pb9sJSxZpcA9iDeaG72XM
L+y0mbz++W6f/yPNmwPxs9tcepNFqT+HzdPxQbi8qamDfoz7GBCzHDjuiWY+z+ikCOk9G
j6moE36DpJQbSLv/28gAIXdJ/WlVfRoKMKd5029BSKZCw8eCv33i2ot/yhZ1AW4sKNg==
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=dZs+UKLK;
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 7DFFA606A894;
Fri, 13 Nov 2026 07:05:31 +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=dZs+UKLK
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.139
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1794553525;
b=wkXs4c6KlbdBTRkbQRr6d5A42qoixU9Bm0Nlh9TH5rUw+WukfkFbKRfIM8w/XZsp4oMK
wsgHr9vqkIMtFW1JsPAUAvyQsU0qzZ1z4gQAP1cjQeg92sVeMP2u7vDeB2ResOy4roTmN
vS2y0lVR9VcwAaUn0rK7OQ1aQVFXFSrU8EZRGRH1/lk/ERWiQ5cUr0Xlf5W40thv2aUw8
21RuQLZJ8LPRWjhWfF3TSs3GNfsc9N9GPwcPEcc2MdDV2MgA1h4HZ5ht+BEchmYx1qWdq
OE3IL1clokq49NH8HkYQUUfsN1kaVYF8wF4GaoKIQ0NjnjxAyfyiyuu4+rCgHSWn1zQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794553525;
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:MIME-Version:Content-Type:Content-Transfer-Encoding:
Date:Message-ID;
bh=PL2JrQrlFCZkPDlSoBfHNnVP+PHI384lIjGURt26NKY=;
b=dkjxVwj3Han8EtxomsYsgB9pe5ZPqlAUzwgNWwBlYD8jKN7YSLuzJug1cQVNuHvtSHeQ
/af3EjPczZGxaIYFXpN8OtK7EW9o0TwMsvF5G//mEN4mDEpTlJ08qMGUW7plJfe4qW9bo
YK/1RGaTuixv2S0REuLofjYW4iMW+Raaf2+Aictga2FVT1/VQRv+HKE3QUUFYGngrfuWr
6Jk4ANGlW030h1pMmg1X5TqvolUx5qjOkS3nLZzegxiNelW9tunvTFoHC+OyvXiiJJfMZ
FFtHTeKt1+VQTQIrUMStcixwtZW2YK2LV2jCBkxSf5A3dAnpC3GD/JboPvDPeM5sMBw==
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=dZs+UKLK;
arc=none smtp.remote-ip=111.22.67.139
X-Received: from cmccmta6.chinamobile.com (cmccmta6.chinamobile.com [111.22.67.139])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 908BD606A882;
Fri, 13 Nov 2026 07:05:21 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 908BD606A882
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=dZs+UKLKx+GGQ9ZfipaY7BmrMPy+PSlxKvealr0KCY2mGcABMir3FpOQHgXQhZBxk/PcLi1bzPyIJ
eIl5Kbg7GEO2lLZhfcK0pHuxAt7D6TXCOxXf0Aaew08YtaOCu5w+NZplvBYvuWBt6HJlmaWpHM3KT9
AR/N4AySI1eTGoWI=
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-app05-12005 (RichMail) with SMTP id 2ee56af6b6aff86-e66ec;
Fri, 13 Nov 2026 15:05:20 +0800 (CST)
X-RM-TRANSID: 2ee56af6b6aff86-e66ec
X-RM-TagInfo: emlType=0
X-RM-SPAM-FLAG: 00000000
X-Received: from [198.18.0.35] (unknown[223.108.79.101])
by rmsmtp-syy-appsvr03-12003 (RichMail) with SMTP id 2ee36af6b6ae209-1aa50;
Fri, 13 Nov 2026 15:05:19 +0800 (CST)
X-RM-TRANSID: 2ee36af6b6ae209-1aa50
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-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