From: Eric Dumazet <edumazet@kernel.org>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>
Cc: Kuniyuki Iwashima <kuniyu@google.com>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, Eric Dumazet <edumazet@kernel.org>
Subject: [PATCH net-next 0/4] tap: do not hold RTNL in open(), release() and queue ioctls
Date: Thu, 19 Nov 2026 08:22:54 +0100 [thread overview]
Message-ID: <20261119072258.3157902-1-edumazet@kernel.org> (raw)
Opening or closing a macvtap/ipvtap char device acquires RTNL, as do
the TUNSETQUEUE and TUNGETIFF ioctls, although they only manipulate
the list of queues attached to the device, which is private to tap.
Hosts starting and stopping many virtual machines thus add contention
on RTNL for no good reason.
This series protects the queue list with a per-device mutex, and
stops taking RTNL in these four paths.
Patch 1 makes sure tap_del_queues() is called for every unregistered
device, and that no queue can be attached afterwards. Both properties
are currently provided by RTNL being held in tap_open().
Patch 2 adds tap->lock and takes it wherever the queue list is used,
still under RTNL.
Patch 3 removes RTNL from open(), release(), TUNSETQUEUE and TUNGETIFF.
Patch 4 removes a device reference that is not needed by the ioctls
still running under RTNL.
TUNSETOFFLOAD, SIOCGIFHWADDR and SIOCSIFHWADDR still take RTNL, since
they call into the core stack. The datapath is unchanged.
Testing: selftests net/tap and net/ipvtap_test.sh pass. A test program
(not part of this series) checking the queue limit, attach/detach,
txqueuelen change, rename, netns move and device or lower device
removal with open queues gives the same results before and after the
series. The same program was used to run open/ioctl/read/write/close
loops against concurrent link add/del/rename/netns moves for macvtap
and ipvtap, on a kernel with lockdep, PROVE_RCU and KASAN enabled,
without any splat. No test was done with vhost-net or real VM.
Eric Dumazet (4):
tap: detach queues from the NETDEV_UNREGISTER notifier
tap: add a mutex to protect queue management
tap: do not hold RTNL in open(), release() and queue ioctls
tap: remove tap_get_tap_dev() and tap_put_tap_dev()
drivers/net/ipvlan/ipvtap.c | 23 ++++--
drivers/net/macvlan.c | 3 +-
drivers/net/macvtap.c | 24 ++++--
drivers/net/tap.c | 184 ++++++++++++++++++++++++++------------------
include/linux/if_macvlan.h | 2 +
include/linux/if_tap.h | 12 +++
net/core/dev.c | 1 +
7 files changed, 161 insertions(+), 88 deletions(-)
base-commit: 66726ba54a01a2951688a56f5eb4d13d063acbea
--
2.53.0
next reply other threads:[~2026-11-19 7:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 7:22 Eric Dumazet [this message]
2026-11-19 7:22 ` [PATCH net-next 1/4] tap: detach queues from the NETDEV_UNREGISTER notifier Eric Dumazet
2026-11-19 7:22 ` [PATCH net-next 2/4] tap: add a mutex to protect queue management Eric Dumazet
2026-11-19 7:22 ` [PATCH net-next 3/4] tap: do not hold RTNL in open(), release() and queue ioctls Eric Dumazet
2026-11-19 7:22 ` [PATCH net-next 4/4] tap: remove tap_get_tap_dev() and tap_put_tap_dev() Eric Dumazet
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=20261119072258.3157902-1-edumazet@kernel.org \
--to=edumazet@kernel.org \
--cc=davem@davemloft.net \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.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