🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #14635

Re: [PATCH net] amt: tear down every amt device on an unregistering lower

#14635
From: Simon Horman
Date: Wed, 11 Nov 2026 17:21
54 lines
10179 bytes
On Thu, Nov 05, 2026 at 11:23:02PM +0000, Omar Ramadan wrote:
> amt_device_event() acts only on the amt device that
> amt_lookup_upper_dev() returns, which is the first amt device bound to
> the event's lower. Several amt devices can share one lower, for
> example two gateways.
> 
> On NETDEV_UNREGISTER, only the first device is unlinked and
> unregistered. The others stay upper-linked to the lower, and
> unregister_netdevice_many_notify() warns, because the notifier chain
> must detach every upper device. They also still hold a reference on
> the lower, so each is torn down only when netdev_wait_allrefs_any(),
> called from netdev_run_todo(), rebroadcasts NETDEV_UNREGISTER. By then
> the lower's sysfs directory is gone, so unlinking it trips a kernfs
> WARN, and unregistering it from inside the rebroadcast trips the WARN
> in __rtnl_unlock(). On NETDEV_CHANGEMTU, only the first device is
> resized.
> 
> Walk every amt device in the lower's netns and act on each one bound
> to the lower. On NETDEV_UNREGISTER, queue them all and unregister them
> in one batch. amt_dellink() unlinks each device but leaves it on the
> netns device list until unregister_netdevice_many(), so the walk stays
> valid under RTNL.
> 
> To reproduce:
> 
>   ip link add lower0 type dummy
>   ip link add amtg1 type amt mode gateway local 192.0.2.1 \
>           discovery 192.0.2.2 dev lower0
>   ip link add amtg2 type amt mode gateway local 192.0.2.1 \
>           discovery 192.0.2.2 dev lower0
>   ip link del lower0
> 
> Without this patch, the last command logs:
> 
>   WARNING: net/core/dev.c:12773 at unregister_netdevice_many_notify+0x13e5/0x1940, CPU#3: ip/216
>   kernfs: can not remove 'upper_amtg2', no directory
>   WARNING: fs/kernfs/dir.c:1784 at kernfs_remove_by_name_ns+0xc9/0xd0, CPU#0: ip/216
>   WARNING: net/core/rtnetlink.c:141 at __rtnl_unlock+0xb2/0xf0, CPU#0: ip/216
>   WARNING: net/core/rtnetlink.c:141 at __rtnl_unlock+0xb2/0xf0, CPU#0: ip/216
> 
> With it, the commands log nothing and remove both amt devices, and
> tools/testing/selftests/net/amt.sh passes on a KASAN and lockdep
> kernel.
> 
> Found by a selftest for our upcoming AMT offload RFC, which deletes a
> lower carrying two amt gateways, on our 6.18-based driver. The
> commands above reproduce it on net.
> 
> Fixes: b9022b53adad ("amt: add control plane of amt interface")
> Assisted-by: LLM
> Signed-off-by: Omar Ramadan <omar@blockcast.net>

Reviewed-by: Simon Horman <horms@kernel.org>
Technical Details
Message-ID: <20261111172108.GH18859@horms.kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361197-linux-kernel-netdev=dewy.ru
References: <20261105232302.494171-1-omar@blockcast.net>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361197-linux-kernel-netdev=dewy.ru
From: horms@kernel.org (Simon Horman)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] amt: tear down every amt device on an unregistering
 lower
Date: Wed, 11 Nov 2026 17:21:08 +0000
Organization: Usenet Network
Message-ID: <20261111172108.GH18859@horms.kernel.org>
References: <20261105232302.494171-1-omar@blockcast.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="906436"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:VNuAcfWEuZ4+LdPAqxgsPs1hmEk= sha256:zpXxjpbQRdxSnYydhv65tsOAQXQuRhhSe67lLHSE5CI=
	sha1:H3OEy/kSuwmdjXuKUnZbmtWPTso= sha256:sZ/1CP/OSkL/T1X+Md6JuCzfeXU/747eLYgKXT1mBIs=
Content-Disposition: inline
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 5B691113F79; Wed, 11 Nov 2026 20:58:37 +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 lMbUQhXqOGTv;
	Wed, 11 Nov 2026 20:58:33 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-361197-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 79B56113F61; Wed, 11 Nov 2026 20:58:24 +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 D391D1A282E; Wed, 11 Nov 2026 17:21:33 +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=1794417679;
	b=4pC6q0aJ3uogujd4TtTyvjORAunAF9Qy1oye9jM5CAhHR3eroX0BpRJC9Tzrf71Gq9tF
	 ouAT52a6dCkZk7rd/44i/0LNX+Ojc7Y3MWnRQSzMTnFDsLTBBEzGZ0SYiHhiOYXuUY0tl
	 nA+u9GB4rtQVk5vcxNtoTnFOOXkIs2UcHsnrq+i2/qgmQPmrmYbGXHnHPZ23iJMffFEzD
	 56qdr0K13UA5uDYXr4ds/QMtbgjci/6N4S9G/nrKjRxWA+SR3judGv7e9F4T3nb1mPN2P
	 OJ281h6iEHRVJyg2FFHBrQ28XnM2CgDDRgJHil/Lb1SEPyIyxb3gp6Cn6lmxqa2s4ow==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794417679;
	h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=EE8+MCsRagBoohqcIiB5gvCk84/vK5Bw9WsOjn/UPac=;
	b=oLIcxWfah+mCXEyyG2bwjzBkCitnhdm5xySH/b84BfFBgsh7pIqUouHTlHjtKZwtAApK
	 sbzq5e0KA7exMQkhsMDKBp6S7GUNPoFJsJVUiVzLbyNUIwW4+hdRKhPVmxKqjwBx6GSSd
	 Yo33c1KR+Q4i7+BD02ox+tycu/rxSWQSNUbhm85/k9kCWZOTbQsLMTh7oWga5dkkbiLvk
	 FibCT7pzHfjZIGieBnET6DasXJvuz7JrP6c5ljXSdN2sXhcHZSNgYNBtv8px66lwBaEJW
	 gQ/IX7z98SvNSF3Oc63HzfMWdCg7mfrsisDcO+gSsRjbTaUIG/PUq5dlNCa5x6/cO4g==
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=ocsjFEby;
	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 23DB1606A899;
	Wed, 11 Nov 2026 17:21:19 +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=ocsjFEby
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=1794417673;
	b=LMrJHgLbG6Sq16QWoYvKUegD8x0A8Ama+XvzsH1cWydXq2BpiSGaSQMpI4kx3hJuW/9D
	 CohVQo1QqoRDpx6tBohy65nEgcNryC3rp8f1xqdBMCnlG3mvtyMiIpJV2OrBPJ0hZB82o
	 fXPbGz1lsCWFFYZ0C6WukvTPC77adKMCIwyvPYn2jFV4TBj5JTZKBUeG/fRiRCW3+zHY+
	 UPdzoYrSJ/mG4lCb5U2Vl+S9IsvZ5FhdhYxEVeTP1xQqmMqgPXpXFQsWlqKvKmiTjuE0M
	 PZFkIXBCLnBeisH6JnLvtE91YACZ5uOeIcgnNz2iHYj8S22Zi9yUOZwzd4vd7U4H3xg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794417673;
	h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=EE8+MCsRagBoohqcIiB5gvCk84/vK5Bw9WsOjn/UPac=;
	b=GLg4VTfMvF5rrX9tPUNR8JzsOjkoKGxJjAeg1aIZpmDL03b+YVTt9mWNTLsy/pisnADP
	 9QwEm3waONXQ6dAAaXDNw5wKo0onAPjAZFUU0+8JNpcccbDcPePvYgFvTHrLQuAftgtKI
	 z0IX/yBYOdioOaKM9g8+O4gQ2H1SQaa7TCBVbwuH2PxqbxiO1vH4uFc5JLg38iMTISsUV
	 /5VXDWnfy0yuNfv2F7Sb4Uzy765v4VWtnyRp5d8eEiIcXeL2mBH0i/LFG6IJAWM+/tzcX
	 44T1yBvFG6R+8s/YEHmIlLjDSuv2znrM0AS19ydDXWPYxiOvuS19gRxsyWuUlVNvxWA==
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=ocsjFEby;
	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 417CE606A326;
	Wed, 11 Nov 2026 17:21:12 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18E311F00A05;
	Wed, 11 Nov 2026 17:21:10 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794417672;
	bh=EE8+MCsRagBoohqcIiB5gvCk84/vK5Bw9WsOjn/UPac=;
	h=Date:From:To:Cc:Subject:References:In-Reply-To;
	b=ocsjFEbyh9BoOTNj4Cy9BmB7U7bPo+QAuvW4Gs0cvMxQbshyxudiUz1zoJKnrIJqB
	 BLxEOAlryk+aoE2UEq+egeLHN586qS5bm9uzG+OmEG1l/8ruAcLk2E/alX6vOg4lcj
	 1OYQNUt4fKgZUXkk9XVa5+rS0laJLK71XdfFjCpR1dpxftdyvZuHagqM0u+de2Efmh
	 rU9ZNScve7e6MafiYeS/Y1hpF7Sod9bmxCpVc69HG9/Vx+5B0q0Sh0uY2857dzxJO0
	 Fr4whhPw0fLfkToYaYl1CyyF583QgSYk9KGXRMfpm9+/uDIxhT69ll3TSqfersTVuY
	 J10/36edbhDpQ==
X-Cc: Taehee Yoo <ap420073@gmail.com>, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.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
X-In-Reply-To: <20261105232302.494171-1-omar@blockcast.net>