Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next v5] ip6_gre: fix changelink conflict checks for L2 tunnels
@ 2026-11-22 13:42 Xia Yan
  2026-11-22 15:12 ` Ido Schimmel
  0 siblings, 1 reply; 2+ messages in thread
From: Xia Yan @ 2026-11-22 13:42 UTC (permalink / raw)
  To: netdev
  Cc: dsahern, idosch, davem, edumazet, kuba, pabeni, horms,
	linux-kernel, kuniyu, xeb, yana06070, netdev-bot+sashiko

ip6gre_changelink_common() calls ip6gre_tunnel_locate(), which only
looks for ARPHRD_IP6GRE devices. The same helper also handles ip6gretap
and ip6erspan devices.

An L2 tunnel can therefore change its parameters to match another L2
tunnel, and incoming packets can 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. This
also matches the device-type check in IPv4 ip_tunnel_changelink().

Found while comparing the duplicate checks in newlink and changelink.
Reproduced under UML using existing netlink interfaces, without kernel
instrumentation or fault injection. 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.

Tested on net-next under UML with W=1 builds before and after the change.
Standalone tests covered duplicate and valid updates for ip6gretap and
ip6erspan, including receive-interface and payload checks, plus an L3 GRE
control. Kernel selftests were not run.

Signed-off-by: Xia Yan <yanxia@cmss.chinamobile.com>
---

Notes (ip6gre-v5-mail):
    Changes in v5:
    - Return to the minimal one-line v1 change, as requested by Ido Schimmel.
    - Rebase onto current net-next.
    
    v4: https://lore.kernel.org/netdev/179491056935.741041.1816208847037703396.ip6gre-v4@cmss.chinamobile.com/
    Review: https://lore.kernel.org/netdev/20261122123555.GA2812544@shredder/
    
    Current UML build and runtime baseline: eb6d6c80d35449c27471b1874f13066c09a8964d.
    The v1 x86_64 W=1 allmodconfig- and allyesconfig-derived full builds used
    net 7076f684d513. Those full builds were not repeated for this rebase.

 net/ipv6/ip6_gre.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 26c0e1c4de18f8b44ceb05d01673aaadfbcbd5ef..9f1e58f9326afd27d097431ffe62efb0aaaaf58a 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -2064,7 +2064,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: eb6d6c80d35449c27471b1874f13066c09a8964d
-- 
2.43.0




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-22 15:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22 13:42 [PATCH net-next v5] ip6_gre: fix changelink conflict checks for L2 tunnels Xia Yan
2026-11-22 15:12 ` Ido Schimmel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox