mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: yanxia@cmss.chinamobile.com
Cc: netdev@vger.kernel.org, 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
Subject: Re: [PATCH net-next v3] ip6_gre: fix changelink conflict checks for L2 tunnels
Date: Tue, 17 Nov 2026 07:14:44 +0000	[thread overview]
Message-ID: <179489968486.3136.18372818760197436344@kernel.org> (raw)
In-Reply-To: <179455350258.84965.17518172977020586093.ip6gre-v3@cmss.chinamobile.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In ip6gre_changelink_common() (net/ipv6/ip6_gre.c), the new
  `if (!nt->parms.collect_md)` guard (line 2051) skips the duplicate…
- [Medium] After this patch, ip6gre_changelink_common() treats any
  ip6gre_tunnel_find(net, p_p, dev->type) hit on another device as…
- [Low] The patch fixes a user-visible bug in ip6gre_changelink_common()
  (net/ipv6/ip6_gre.c).

--

ip6_gre: fix changelink conflict checks for L2 tunnels

This patch changes ip6gre_changelink_common(). Ordinary devices are now
checked with ip6gre_tunnel_find() using dev->type, replacing
ip6gre_tunnel_locate(), which only searched ARPHRD_IP6GRE devices.
Metadata devices skip the duplicate search entirely. The encapsulation
setup now runs after the conflict and unregistering checks.

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

[Severity: Low]
This fixes a user-visible bug: received frames go to the wrong tunnel.
Could it carry a Fixes: tag?

The L2 changelink path has used ip6gre_tunnel_locate(net, &p, 0) since
the ip6gretap kind was added. That function hardcodes ARPHRD_IP6GRE:

	t = ip6gre_tunnel_find(net, parms, ARPHRD_IP6GRE);

That looks like it would be:

Fixes: c12b395a4664 ("gre: Support GRE over IPv6")

The notes say this was tested on net-next. Whether it should go through
net instead is for the maintainers to decide, since the fix also makes
some previously accepted configurations fail.

> diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
> index b5d6ed8f0c369..0a113bc8def95 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);
>  

[ ... ]

>  	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) {

[Severity: Medium]
Does this guard also remove the existing duplicate check for L3 ip6gre
metadata devices?

Before this patch, every changelink went through
ip6gre_tunnel_locate(net, p_p, 0), which searched ARPHRD_IP6GRE devices.
So an ip6gre external device could not be moved onto the parameters of
an existing ip6gre tunnel:

  ip link add g1 type ip6gre local A remote B key 5
  ip link add md0 type ip6gre external
  ip link set md0 type ip6gre external local A remote B key 5

The last command used to fail with EEXIST. With this guard the search is
skipped and the command succeeds. ip6gre_changelink() then does:

	ip6gre_tnl_change(t, &p, !tb[IFLA_MTU]);
	ip6gre_tunnel_link_md(ign, t);
	ip6gre_tunnel_link(ign, t);

ip6gre_tunnel_link() puts md0 at the head of g1's bucket with
hlist_add_head_rcu(). ip6gre_tunnel_lookup() ignores collect_md and
returns the first score-0 match.

Would md0 then receive the traffic meant for g1?

The commit message gives "A duplicate can receive traffic intended for
the original tunnel" as the reason for the fix. The subject only
mentions L2 tunnels. The message does say metadata devices skip the
search "as newlink does", but it doesn't say this relaxes a check that
L3 ip6gre already had.

Was that intended? If so, could the commit message say so?

The same applies to L2: an ip6gretap or ip6erspan metadata device can
still be changed into a duplicate of an ordinary tunnel of the same type
and take its traffic. So changelink can still create duplicates; the
check only covers ordinary devices.

> +		t = ip6gre_tunnel_find(net, p_p, dev->type);
> +		if (t && t->dev != dev)
>  			return ERR_PTR(-EEXIST);

[Severity: Medium]
Can this reject an update to an ordinary L2 tunnel that doesn't change
its hash parameters, when a metadata device with the same parameters
exists?

For metadata devices, ip6gre_newlink() and ip6erspan_newlink() never
call ip6gre_tunnel_find():

	if (nt->parms.collect_md) {
		if (rtnl_dereference(ign->collect_md_tun))
			err = -EEXIST;
	} else {
		if (ip6gre_tunnel_find(net, &nt->parms, dev->type))
			err = -EEXIST;
	}

So a metadata device can be linked at the head of the same bucket as an
existing ordinary device with identical parms. For example:

  ip link add tap0 type ip6gretap
  ip link add tapmd type ip6gretap external
  ip link set tap0 type ip6gretap ttl 10

In the last command, ip6gre_netlink_parms() zeroes p_p, so laddr, raddr,
key and link all match tapmd. ip6gre_tunnel_find(net, p_p, ARPHRD_ETHER)
stops at the first match in the bucket, which is tapmd. So t->dev != dev
and this returns -EEXIST, even though tap0's hash parameters are
unchanged.

Before the patch the search used ARPHRD_IP6GRE. tapmd didn't match, and
the update succeeded.

The commit message says a match on a metadata device remains a
conflict. Is that meant to cover this case too, where the result
depends on bucket insertion order?

Returning the first match works for newlink, because the new device is
never in the table yet. Changelink needs "any match other than dev"
instead.

> -	} else {
> -		t = nt;
>  	}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179455350258.84965.17518172977020586093.ip6gre-v3%40cmss.chinamobile.com

      reply	other threads:[~2026-11-17  7:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13  7:05 Xia Yan
2026-11-17  7:14 ` netdev-bot+sashiko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179489968486.3136.18372818760197436344@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=xeb@mail.ru \
    --cc=yana06070@163.com \
    --cc=yanxia@cmss.chinamobile.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®