🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #13400

[PATCH net-next v2 5/5] hv_netvsc: let the core take XDP off a netvsc device that is going away

#13400
From: Jakub Kicinski
Date: Mon, 09 Nov 2026 19:48
72 lines
10822 bytes
netvsc_remove() lets the VF go, taking the XDP program back from it,
takes the program off the channels, then frees the channels and clears
nvdev, and only then unregisters the netdev. dev_xdp_uninstall() still
finds the program in netvsc's xdp_state[] at that point and asks
netvsc_bpf() to remove it, which fails with -ENODEV for the lack of
nvdev. That trips the WARN_ON() in dev_xdp_uninstall() on every unbind
or hot-remove of a netvsc device running native XDP, and
dev_xdp_install() returns before it drops the program from the XDP
dispatcher, which then holds on to it for good. The WARN came with
commit 7f0a838254bd ("bpf, xdp: Maintain info on attached XDP BPF
programs in net_device"): the core used to ask netvsc for its program
first, and netvsc reported none once nvdev was gone, which left the
program with the dispatcher all the same.

Accept the removal once there are no channels and no VF left to take the
program off. If suspend parked the program for netvsc_resume() to put
back, drop it from there, or resume would bring back a program the core
no longer knows about. This also lets the program be removed from a
netvsc device without a VF which lost its channels to a failed
reconfiguration, rather than fail. The core is about to record the
programs uppers propagate as well, which would bring the same to a
netvsc device enslaved to a bond running XDP.

Spotted by AI while reviewing the XDP propagation series. Untested.

Cc: stable+noautosel@kernel.org # LLM report + LLM fix, untested
Fixes: 7f0a838254bd ("bpf, xdp: Maintain info on attached XDP BPF programs in net_device")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
v2:
 - drop the program suspend parked for resume rather than refuse the
   removal, which still tripped the WARN with the config a failed
   suspend leaves behind (Sashiko)
 - commit msg: the dispatcher kept the program before 7f0a838254bd too,
   name the function which skips the dispatcher, and mention devices
   which lost their channels to a failed reconfiguration
 - Tested-by tags from v1 not carried over, the code changed
v1: https://lore.kernel.org/20261001014131.310771-6-kuba@kernel.org
---
 drivers/net/hyperv/netvsc_bpf.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hyperv/netvsc_bpf.c b/drivers/net/hyperv/netvsc_bpf.c
index 143fc0c12841..14bb520b44ed 100644
--- a/drivers/net/hyperv/netvsc_bpf.c
+++ b/drivers/net/hyperv/netvsc_bpf.c
@@ -206,7 +206,21 @@ int netvsc_bpf(struct net_device *dev, struct netdev_bpf *bpf)
 	int ret;
 
 	if (!nvdev || nvdev->destroy) {
-		return -ENODEV;
+		struct netvsc_device_info *saved;
+
+		if (bpf->command != XDP_SETUP_PROG || bpf->prog || vf_netdev)
+			return -ENODEV;
+
+		/* The channels and the VF are gone, and so is the program,
+		 * except for the reference netvsc_suspend() keeps for
+		 * netvsc_resume().
+		 */
+		saved = ndevctx->saved_netvsc_dev_info;
+		if (saved && saved->bprog) {
+			bpf_prog_put(saved->bprog);
+			saved->bprog = NULL;
+		}
+		return 0;
 	}
 
 	switch (bpf->command) {
-- 
2.56.0
Technical Details
Message-ID: <20261109194843.1353592-6-kuba@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359581-linux-kernel-netdev=dewy.ru
References: <20261109194843.1353592-1-kuba@kernel.org>

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!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359581-linux-kernel-netdev=dewy.ru
From: kuba@kernel.org (Jakub Kicinski)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v2 5/5] hv_netvsc: let the core take XDP off a netvsc device that is going away
Date: Mon,  9 Nov 2026 11:48:43 -0800
Organization: Usenet Network
Message-ID: <20261109194843.1353592-6-kuba@kernel.org>
References: <20261109194843.1353592-1-kuba@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="436830"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:hT0g/JWCjnuziQMwyEF6e1MNsXg= sha256:+zFplpJmS+0+8u1pkI9BaWQ5lzRajz6/g5i0bVEwn4M= sha1:DXHh/LKgo2u6V8eWpbIM+pGI2Ok= sha256:xFdVcTgbxnL375mK2m4pB+NNjgLwaEPybdKA6HL9lMU=
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 8ADD61138C2; Mon,  9 Nov 2026 22:50:52 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[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 8mdUSuNhSvqw; Mon,  9 Nov 2026 22:50:41 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-359581-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 89480113907; Mon,  9 Nov 2026 22:50:33 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 14D3561DA2C; Mon,  9 Nov 2026 19:48:58 +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=1794253733; b=qX0fllpJAPOmvXHeWUz5kk5yFCIS2G4mh6Z21afD+nSKhqI/mMMX163nhSXFlQvRALgm Gfc98145BPtYn/rjbirj6j/qkTc9taF35UV8aRXC0N7T9l4xPb0RwZ1is8JTCJD7RvugT 46zOwn9Blr8IsbEfeFoUh7/ksYbxzOowrKCi0ym46N4lXq2JJnVQdQ/cFI2HEOxgNwL8Q /Ze+76ifkJONjhuhGTOQ7+6fzsSFOtvz4xFG9SJUK1VNSgJCxX5r1hL97XmQ+eQ6MUv2Q dZLRc4lz2SkvIWDJ285bHkR5xMcY5mFHM4bVzwQUE5sfYesGfkUQEOvg4TU1kWwRHiQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794253733; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding; bh=Eyd9veasL+1zYHn5ojY0wOfd1QwDacZa46cZ6SG2zHg=; b=SaMhNM/t49ClRzMyDzmO3xjOHicqjb5FSy3q63PqMS3MgPsKQDb1sdVuc2F/CPQ3r5F+ NlnM2MY9oqoi18CHCd58JaLX06PbY/0ZZIIGifMdC5/D+DPcR8TP82ZFJGN8V4gR57yqd 0YB++acHKzppkMsrCAFpwZXC+/VA47WP6XXRv4B9OajEg00va/xl5cEwfZ3Osn34tj81N o0py/b0oxX0Scf6Cvj0Oyix1K3wXK6s4/a4o5niKpdgYldJJRzoBLUEUaUxfkLm2NtGOB QtKYKHF13VymsgPGKwGNZzqfZaaTNQcG7TbSzUredIaj8MemPJO44WN72cD5OcDSreQ==
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=aaJTdBmy; 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 CAC6E60A2610; Mon,  9 Nov 2026 19:48:53 +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=aaJTdBmy
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=1794253733; b=ePeCt6JNA5q4YORDS1/wRRRmMXnaqTwx9ZdORxhmFeui73McmUQT+Ac+Z1fdMO5zZ9kZ VY+7g8r1RAkjfXySVYSo+zaZXvohvMXnKSJpsY5zUzCIU/UIz5xYDIBnZtDk4FQM/Ahou PwrfITBSRg18cR7a5aZYq3S22OXIrBRv0EFqbH7agrC/YQRJKJkpORn1TYfc0HHqbDID0 OMYebTM/Hxi8xBP+Xi8jMgN62kYAMdF/pxIs+nFbVSt+eNCFPgVj4pHFC3z1KjivMQbDu HGtMkVaVERxPTy0Wsu/Kw22vnTpj1KsecZi9zOoWJTRU+mZwHy5ns1AfurGdSKUA77w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794253733; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=Eyd9veasL+1zYHn5ojY0wOfd1QwDacZa46cZ6SG2zHg=; b=spRy6jbbtvHurG3a2Z90MTazgzVfvHPzWAnXKivKdfIh5LyGxcroy2dCmrinjSJv6HK2 AVLpEYrPwB1CwTxOzI6BjPiz6ziqSBiRjIZ6vOmjCV+q3jLC94GOUe7wBDJYLLhMaNYUe nHytj1WVGxaiXTRsgvrLVrP9oktEv4+gK3kcUDSsdyorEEsb64LxNIRkd7QXRDSXmgctR 2LZ50iQnU9XiUEGe96O2KQ88sAjR2RM3C3OaQOrXsiI23S1uxmDeJBOMi2/l4O8f7B63U NWpt4JyqLLUI6OGI5yTQL2+Be/f4+nAaf1hHuqCsPRNiR5/pK/ID7sDF8O1ITA5e4rQ==
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=aaJTdBmy; 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 AF0C160A2607 for <netdev@vger.kernel.org>; Mon,  9 Nov 2026 19:48:52 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBE061F008AB; Mon,  9 Nov 2026 19:48:51 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794253732; bh=Eyd9veasL+1zYHn5ojY0wOfd1QwDacZa46cZ6SG2zHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aaJTdBmynzbjnQFsI7eGeOOluMCh0GBRbCRHUlELV87AZZ5QetuMrlUdrZXnoAvlU ecp5/wMLK29XxqqjNt7+p7vI71jRy/784qWtM/l+IrMhZoLnSyrNlfTAWC2gGM9w7v 2HWmLLFjeWGjeLn/nv6Mx3DrD7LY9KAnNHh2v415KLDJiwlonteDGXiQfP2M2QvpNj uXuTL4+dma6AnM7iIbSlzmjWhMs8pvU9vzCBgMPkk/pljk/XQyV7F2AtUukiejFp9L 0QmzN12M+P6/PgfCH4lPNhWNum9CLrYYa2dRz+RM6o5N4wFSy51IxsuGup7t3H3k+P gX4ueX8ODuwBQ==
X-Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, kameroncarr@linux.microsoft.com, ernis@linux.microsoft.com, Jakub Kicinski <kuba@kernel.org>, stable+noautosel@kernel.org
X-Mailer: git-send-email 2.56.0
X-In-Reply-To: <20261109194843.1353592-1-kuba@kernel.org>
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