From: netdev-bot+sashiko@kernel.org
To: kuniyu@google.com
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, dsahern@kernel.org, idosch@nvidia.com,
horms@kernel.org, steffen.klassert@secunet.com,
herbert@gondor.apana.org.au, kuni1840@gmail.com,
netdev@vger.kernel.org
Subject: Re: [PATCH v2 net-next 7/7] ip_tunnel: Support per-netns device unregistration.
Date: Fri, 11 Sep 2026 02:44:25 +0000 [thread overview]
Message-ID: <178909466550.219967.12590792953773467699@kernel.org> (raw)
In-Reply-To: <20260909234422.2416506-8-kuniyu@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider:
Critical: 0 · High: 1 · Medium: 0 · Low: 0
- [High] In `ip_tunnel_ctl()` (net/ipv4/ip_tunnel.c:930-933) the newly
added gate `if (!itn->fb_tunnel_dev) { err = -EBUSY; goto done; }`…
--
ip_tunnel: Support per-netns device unregistration.
This switches __ip_tunnel_dellink() to unregister_netdevice_queue_net() so
ip_tunnel_delete_net() can queue cross-netns devices for per-netns
unregistration, and adds ip_tunnel_unregistering() checks so
ip_tunnel_changelink()/ip_tunnel_dellink()/ip_tunnel_ctl() skip devices
that are already queued. It also adds a NULL check on itn->fb_tunnel_dev
in ip_tunnel_ctl().
> diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
> index 9ad63f1af37a6..b07cc453e28be 100644
> --- a/net/ipv4/ip_tunnel.c
> +++ b/net/ipv4/ip_tunnel.c
[ ... ]
> @@ -920,6 +927,11 @@ int ip_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm_kern *p,
>
> mutex_lock(&itn->tunnels_lock);
>
> + if (!itn->fb_tunnel_dev) {
> + err = -EBUSY;
> + goto done;
> + }
> +
[Severity: High]
Is itn->fb_tunnel_dev == NULL a reliable indicator that the netns is
dying?
ip_tunnel_init_net() leaves fb_tunnel_dev permanently NULL for a perfectly
live netns:
net/ipv4/ip_tunnel.c:ip_tunnel_init_net() {
...
if (!ops || !net_has_fallback_tunnels(net)) {
struct ip_tunnel_net *it_init_net;
it_init_net = net_generic(&init_net, ip_tnl_net_id);
itn->type = it_init_net->type;
itn->fb_tunnel_dev = NULL;
return 0;
}
...
}
net_has_fallback_tunnels() returns false for all non-init netns when
net.core.fb_tunnels_only_for_init_net == 1, and for every netns including
init_net when it is 2 (or the fb_tunnels=none boot arg is used). That
sysctl is mode 0644 in net/core/sysctl_net_core.c, so it is runtime
settable.
In those configurations, does this new gate make all four legacy ioctls
fail with -EBUSY on ipip/gre/gretap/erspan/vti devices? On the parent
commit, with fb_tunnel_dev == NULL:
- SIOCGETTUNNEL skips the "dev == itn->fb_tunnel_dev" branch and does
memcpy(p, &t->parms, sizeof(*p)) with t = netdev_priv(dev)
- SIOCADDTUNNEL reaches ip_tunnel_create(net, itn, p), which only needs
itn->rtnl_link_ops (assigned before the early return above)
- SIOCCHGTUNNEL takes the "dev != itn->fb_tunnel_dev" branch
- SIOCDELTUNNEL reaches __ip_tunnel_dellink()
The path is reachable per device without any fallback device existing,
since ipgre_netdev_ops, ipip_netdev_ops and vti_netdev_ops all install
.ndo_siocdevprivate = ip_tunnel_siocdevprivate:
ioctl(fd, SIOCGETTUNNEL, {ifr_name="gre1"})
-> ip_tunnel_siocdevprivate()
-> dev->netdev_ops->ndo_tunnel_ctl(dev, &p, cmd)
-> ip_tunnel_ctl()
So does "ip tunnel show/add/change/del" on a netlink-created device stop
working after this change when fallback tunnels are disabled? The
SIOCGETTUNNEL branch has no capability check, so this is reachable
unprivileged as well.
Is the gate needed for NULL-safety at all? Every remaining dereference
of itn->fb_tunnel_dev inside ip_tunnel_ctl() is guarded by a
"dev == itn->fb_tunnel_dev" comparison, so its only role appears to be the
dying-netns policy described in the commit message.
Would an explicit "itn is being destroyed" flag (or the
ip_tunnel_unregistering() semantics added by this same patch) work better
here, given that fb_tunnel_dev == NULL cannot distinguish "this netns
never had a fallback device" from "this netns is going away"?
Other in-tree code already treats a NULL fb_tunnel_dev as a normal state
for a healthy netns:
net/ipv4/ip_vti.c:vti_init_net() {
...
itn = net_generic(net, vti_net_id);
if (itn->fb_tunnel_dev)
vti_fb_tunnel_init(itn->fb_tunnel_dev);
...
}
> switch (cmd) {
> case SIOCGETTUNNEL:
> if (dev == itn->fb_tunnel_dev) {
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260909234422.2416506-1-kuniyu%40google.com
prev parent reply other threads:[~2026-09-11 2:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 23:43 [PATCH v2 net-next 0/7] ip_tunnel: Support per-netns device unregistration Kuniyuki Iwashima
2026-09-09 23:43 ` [PATCH v2 net-next 1/7] ipmr: Call ->dellink() to remove DVMRP tunnel device Kuniyuki Iwashima
2026-09-09 23:43 ` [PATCH v2 net-next 2/7] ip_tunnel: Set itn->fb_tunnel_dev to NULL in ip_tunnel_delete_net() Kuniyuki Iwashima
2026-09-11 2:44 ` netdev-bot+sashiko
2026-09-09 23:43 ` [PATCH v2 net-next 3/7] ip_tunnel: Don't pass rtnl_link_ops to ip_tunnel_delete_net() Kuniyuki Iwashima
2026-09-09 23:43 ` [PATCH v2 net-next 4/7] ip_tunnel: Centralise ip_tunnel_del() to ip_tunnel_dellink() Kuniyuki Iwashima
2026-09-09 23:43 ` [PATCH v2 net-next 5/7] ip_tunnel: Unify error paths in ip_tunnel_newlink() and ip_tunnel_changelink() Kuniyuki Iwashima
2026-09-09 23:43 ` [PATCH v2 net-next 6/7] ip_tunnel: Protect ip_tunnel_net.tunnels[] with mutex Kuniyuki Iwashima
2026-09-11 2:44 ` netdev-bot+sashiko
2026-09-09 23:43 ` [PATCH v2 net-next 7/7] ip_tunnel: Support per-netns device unregistration Kuniyuki Iwashima
2026-09-10 17:13 ` Ido Schimmel
2026-09-10 17:35 ` Kuniyuki Iwashima
2026-09-11 2:44 ` 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=178909466550.219967.12590792953773467699@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=kuniyu@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=steffen.klassert@secunet.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.