🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19017

[PATCH net-next 0/4] tap: do not hold RTNL in open(), release() and queue ioctls

#19017
From: Eric Dumazet
Date: Thu, 19 Nov 2026 07:22
53 lines
9657 bytes
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
Technical Details
Message-ID: <20261119072258.3157902-1-edumazet@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366808-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366808-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <20261119072258.3157902-1-edumazet@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2816801"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:FMw1jnI0edBxKHCDqvqqtiEj32Q= sha256:TF6/GFZfBnWXe8+otWXEXusf+7et9FWbFMe5VWI5YfE=
	sha1:cu+d+yiAHsODKUrsv7LB2L7gORE= sha256:IFuQLV8wdYBIYNVOIxbmujT6oHAKQ4OrCkAMaSW0Ihs=
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 27158115547; Thu, 19 Nov 2026 10:23:23 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
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 Fm0pcdfcFydD;
	Thu, 19 Nov 2026 10:23:20 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-366808-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 1FADA115541; Thu, 19 Nov 2026 10:23:11 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id B69A1269CF5; Thu, 19 Nov 2026 07:23:06 +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=1795072985;
	b=Pew2sC4C6qi2R/V/tch85naWhwVdrBdtcLo4dsX3uqm9t5yrjcmP8hn9bw4kmans9TS5
	 mxRdDxqZ9fX7EIHsEK6pltOqANySblAglkYzE6v3lEZ0BcIugb2lEkpVKpjCkYwwxxCZD
	 UGxiBkwPv5Dhm5qTC0El5bOAXhwnvyVG7ShZlNuIjhD02cx/rtZb2UVy1QVuZ1UGxJiGH
	 Ym4AsQ+3/DKW7ToQEMZGdLqGmM0ysq7/+dGN0NoaKj6cgXTNdrrqRZhi0Tgh06VJewYQN
	 lgjgTNXYac+GB4vScd8Owq5StPDQmQI1WsqNOT7em+fVIjd8GbEdcmceTpQFfb2hKuQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795072985;
	h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=FY0bM6rMJRNlv/rmOvosKosENUh1Se46gZI10r3xmxU=;
	b=TVIxGncnVxa2YutiqdwImUtjUVXOAKaRWpqLvukHnUxirCVpeNUF/4hWGZw6qcIbR+z5
	 Wc/hzsZJZvdx3nWNpeNsS2H2c7WUGuO7M7TnOf3H8cDEB7GzRG7gNAUmjk1T+SW0MyLqQ
	 k8Vp18ZjYwHpKf6UTjkUy3yI5JzWJt5lUgF7ZPEoafePiS37f/9U02dtKDw2awEViBvp/
	 /FOsfGkfhmlCRqGbZssh79xOxq3Ge8ZAx3Z+J+1UWryoLIDtw+2gUwOgwyoNeA7d3ntm6
	 8gbREzTg4fysHOeSpGpwlPg6kV0OjgnWSRJkS34V/02mLQ+HbIYocm5xavCCJ8SqEPA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=B1Ljg4xU;
	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 CB048606A326;
	Thu, 19 Nov 2026 07:23:05 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=B1Ljg4xU
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795072985;
	b=UV8uwN/OrP0sFdBZKfCRB5S5vbeGHwcremppZX/MFhNPYdY2pJPCPWCU7tD/Er7zKCIK
	 Sy/5c3a9V7m6gUOFhnOaWVHyA7+T1DVYEpJq80uN5MFRpxtfylnrr4cc9R6uSKrni+sXg
	 2+ZpfV9jCD83IFl0UHzWa88+X6MKusWJqOEXtP6ZWg7AtCcqjNO7FJ3l1LhtXlrLpiD2W
	 8bDZRF0xYHDUPFrhEX5mdVUD17NCTdWivd/qq8iu5TJPk1Tt44kcRq1PXKfebhQ3Lj6qg
	 oITai63Vo5JT6SNsXCBq5hs+xToPpbhb8FwbmX15dylvgGz2EvX6socic5DymQPoiaw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795072985;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 MIME-Version:Content-Transfer-Encoding;
	bh=FY0bM6rMJRNlv/rmOvosKosENUh1Se46gZI10r3xmxU=;
	b=IdFmy6eoY9YxqUV75mSSnBkQoI145IYBpg7DId6qQRCpWb5t7ybzGC3LrvcXc8Zx/hhr
	 AbNaRlGDMc8MltY+yURnuRhavB0U/Wb1POyLJUIGzkJJ+0o9k7KRO4GNMn8dTQMvReUw4
	 tOEYihMjOZqkO9xyNpbrShbvJOhNSa1wbEoGiqRg3qhETgMLdkQYUwUIskp3r4t3gjer+
	 e5UWorZnL3B12NYBEr+r5zfuQFygZ79xx+Hy1yEop8sRsKSpylw1Si94aZVC5ZC6JV5O3
	 zGkc4c+qDJszaviyPc+fl9u6yyBGp69cn+8fBM4dni0JJ3VxuD7l7ERpBpJ5ZhCLxsg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=B1Ljg4xU;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5C47606A320
	for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 07:23:04 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92E2B1F000C4;
	Thu, 19 Nov 2026 07:23:02 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795072984;
	bh=FY0bM6rMJRNlv/rmOvosKosENUh1Se46gZI10r3xmxU=;
	h=From:To:Cc:Subject:Date;
	b=B1Ljg4xUX/HK7nOCuMNu/kHeQ6b63SUmtytxpSIC7AHUK7RHkzREfRhzzjafjGki3
	 02X5LgvqsT0pTCMnDtWOU0YWAr12EsPzwGHh3MUI0sE2il69uDYJbABeNoONEY7QJS
	 NDifPj4adTnjHRyFrgLKdhCW+AhjtR4mlwAlobVTTet4xZbUS6Y92H2yNl/KNGA9Jj
	 v5Wo9zGDhaCoKiugFzoL8Lv4+fdIX5IGQtaUD8Y2gU9s7MvAkYCBQUZh1HYH1DAuJT
	 9oGcbz8D+TQilyAtB4SkTgD0cgkZwaa0KeiHiH7WviM7HQIt3dZK2x9pA4Fh8HX0sw
	 0qguvRLIjJF7g==
X-Cc: Kuniyuki Iwashima <kuniyu@google.com>,
	Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org,
	Eric Dumazet <edumazet@kernel.org>
X-Mailer: git-send-email 2.53.0
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