🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #6661

Re: [PATCH net] macvlan: fix passthru promiscuity accounting while down

#6661
From: Hangbin Liu
Date: Fri, 23 Oct 2026 03:06
58 lines
10712 bytes
Hi Yan Xia,
On Thu, Oct 22, 2026 at 05:08:09PM +0800, Xia Yan wrote:
> macvlan_changelink() adjusts the lower device's promiscuity count when
> NOPROMISC changes, even if the passthru macvlan is down. The reference
> is acquired in macvlan_open() and released in macvlan_stop(), so a down
> interface has no reference to change.
> 
> Clearing NOPROMISC while down leaves an extra reference after the next
> open/stop cycle. Setting it while down can remove a reference held by
> another user of the lower device.
> 
> Guard the count adjustment with netif_running(dev). Keep storing the
> requested flags while down so the next open uses the new setting.
> 
> Comparing changelink with open/stop exposed the unmatched count changes;
> the same issue was also described in earlier macvlan reviews. A netlink
> test on UML reproduced both DOWN cases before the fix and verified the
> expected counts afterwards. Repeated flag updates, two open/stop cycles,
> deletion and bidirectional small-frame delivery were also checked.
> 
> Full x86_64 builds completed with WERROR disabled for allmodconfig, and
> WERROR and KASAN disabled for allyesconfig, including the resulting
> dependency changes. Neither comparison showed new diagnostics.
> 
> Fixes: df8ef8f3aaa6 ("macvlan: add FDB bridge ops and macvlan flags")
> Link: https://lore.kernel.org/netdev/179170088566.434549.4699134797461783473@kernel.org/
> Link: https://lore.kernel.org/netdev/20261016003009.2692872-1-kuba@kernel.org/
> Cc: stable@vger.kernel.org
> Signed-off-by: Xia Yan <yanxia@cmss.chinamobile.com>
> ---
>  drivers/net/macvlan.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
> index afad90b..a48c9e6 100644
> --- a/drivers/net/macvlan.c
> +++ b/drivers/net/macvlan.c
> @@ -1664,7 +1664,8 @@ static int macvlan_changelink(struct net_device *dev,
>  	if (data && data[IFLA_MACVLAN_FLAGS]) {
>  		__u16 flags = nla_get_u16(data[IFLA_MACVLAN_FLAGS]);
>  		bool promisc = (flags ^ vlan->flags) & MACVLAN_FLAG_NOPROMISC;
> -		if (macvlan_passthru(vlan->port) && promisc) {
> +		if (macvlan_passthru(vlan->port) && promisc &&
> +		    netif_running(dev)) {
>  			int err;
>  
>  			if (flags & MACVLAN_FLAG_NOPROMISC)
> 
> 

If we discard the MACVLAN_FLAG_NOPROMISC change, should we remove the bit
before calling WRITE_ONCE(vlan->flags, flags)?

Or set extack and tell user that setting this flag with link down is forbidden.

Thanks
Hangbin
Technical Details
Message-ID: <atrKdb1atGzCYka4@fedora>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350886-linux-kernel-netdev=dewy.ru
References: <20261022090809.12019-1-yanxia@cmss.chinamobile.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350886-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] macvlan: fix passthru promiscuity accounting while
 down
Date: Fri, 23 Oct 2026 11:06:57 +0800
Organization: Usenet Network
Message-ID: <atrKdb1atGzCYka4@fedora>
References: <20261022090809.12019-1-yanxia@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="396577"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:HavK2LTX4EwUQ5yOrtWQh/WGLJo= sha256:2AUORuDVHyyFeEs7Ev5zk5XBGUkJ0QL1wyCuQoSmmC4=
	sha1:mpQ0ox/tuHv92zX2h+I7iREJMGo= sha256:XCtj49IndwUNOEO+CA9ppBtBR558fJXmu5EPf/VsXiQ=
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 0AF871113C9; Fri, 23 Oct 2026 06:08:17 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.dev
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 PiiWCXVL6cTq;
	Fri, 23 Oct 2026 06:08:09 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-350886-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id E50FF1113A5; Fri, 23 Oct 2026 06:07:59 +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 16CB0353F2; Fri, 23 Oct 2026 03:07:18 +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=1792724838;
	b=rKHbEdhkteP+M0Pv0GOiFezyWH1jhrCRF68JiPSXbm4o4AJLPrqstTXY+R4ppVm4B61a
	 8ZFuxoBVND/EeZGRNyd/Bl/j+Z0i1N0XOeDJujLFUpbfC99CZHkJleNEtmoTKidoABnqH
	 SVg3hqJMziMqW+J22FMFl386uLfkHlr6kURfYk3Z7OiMgkkKq7htwLo4wcsI1bW1Z7yEx
	 BKiPFTXLCrFCp1n+ck7J1tAWydgLf2ovvpc4iBfOW2GJC4ddhTTlbxHTeI0w8GzKQ+L8K
	 e/C29QR2u44fgmZEHDgU2yyQqr8LVaST9zbZv5MiYmJ3FDISzwFjaNUVYq716YVuW+g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792724838;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow: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=OnaK5kbThapjGVWcJhLkCw2nwI2aKy4NlMeDCe0tH1E=;
	b=dillb1yqi1JP8yAHx0/FJjfaKWE0Ep3+ucJFyXrEJX3/v4b3YXKOfUvAewX/CTKF+7J+
	 lzgv4A1bIc1IuK9DBQPK8TVJZnZTzOT32bz4jGzpf29TWCb48iwt5BeMqEAKv/WPslk2H
	 TE5EMbjgBnO6Ef9Jb2Htfr88pv4iqV82pjFYaO0Q/AJqI2Y6pHvkWe2btOE4JH13UnJ9e
	 7+N7Eb/syAjU3xm/Q1Sez+zoDmGx8iMlsu4W4jGRPYFxuMoTjsLHow3VQPfXV3giCP2xL
	 8BnwB9NkI5lmAr8Rz7aoJ9YmeZL4A/tBwyNeimIch2EnEzO5jJys/0/0ICQrNkEcCcQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=SyHj7fB3;
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	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 DCAFD606A31F;
	Fri, 23 Oct 2026 03:07:17 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=SyHj7fB3
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.231
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792724831;
	b=1h8UEYlfj1MgmlRzhg0GWu5vZoWw5GFgxSDqkQoRvvVuDTHNS4qMDqcnElzLSypFKaD9
	 srOmjacDceKIT/4G+D84KncNiCZBHBy8eaZK3Hm9cRPSIzxG6aMCixKIdTe8LVOSzp4g1
	 hBAQ5hi1egFNVsxYfIgMurUPijxd2ho2NwGV19goWttC9tC3D7zFeJh4K/J9miFm48Krt
	 O0cGW8pnNGfBV8s6Odxwm1tLi0krsoINP6Fsl8X9KfFC35weyO71bE9fRNFvfDJ9H7DkR
	 fxxNJ9ocOO/xGDbNnwdsxf/bTmsNiFT7VjVkiKds+Tgv9MaLQ7DvRQmAi/BgTXzcRcQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792724831;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=OnaK5kbThapjGVWcJhLkCw2nwI2aKy4NlMeDCe0tH1E=;
	b=AxKMVo7hbRlllq9MoNz6gXuCu9X98nrqTEgvhd04agEA9/OUsoYOs9kG+UuWNA+atTJR
	 0NumRYDKZ9vGOKQZxWMMNhpZCF0k+09I/AbNZ2mnMvN6cjr9IK8iOHwaufAZv69oDx/Ui
	 IdGAi2FhPq+P+j5CQGvrBcMfuRGXx2xFs6jDLsQqKQwBwWdjEGYVmJAi4eV3Jn+n/A9sq
	 FtpgUkm9xmMrDHuwJZbtb0VBudQqZLGbhwjOiZt58znNy5WhdUfOmb7NrgGVBwqiKWhQF
	 iEMUXMsJVDMwKAvXKXlkz9zjQBkKttRHTPrnyU5reW1lI4zps8qYT0Roqqd+Wqy5ZQg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=SyHj7fB3;
	arc=none smtp.remote-ip=95.215.58.231
X-Received: from mta1.migadu.com (out-231.mta1.migadu.com [95.215.58.231])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id D78C2606A31A
	for <netdev@vger.kernel.org>; Fri, 23 Oct 2026 03:07:09 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D78C2606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=pd2I5oM/BwmyoWBqQfZA7OoTc66uRFuXEF4QDOOUqVY=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1792724827; v=1; x=1793329627;
 b=SyHj7fB33h5m8LSM96abwe2m9P9eG8AkeQwFTxzmLZye2PUuTjMyxjavCYXs0SqOmUBaEYbu
 PRdgsxdLddi0aWu50YgAXleuh1lsnk3YEUTI+dF1N3g551b43Fv3ez6TW48Ra1o5i+KstZNqaxD
 TTJ5MgPHW9w86H7YE1tqDgbM=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta11.migadu.com with ESMTPS id 98355a6fe4b1d75d;
	Fri, 23 Oct 2026 03:07:07 +0000
X-Mizu-Trace-ID: 98355a6fe4b1d75d
X-Migadu-Flow: FLOW_OUT
X-Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, yana06070@163.com
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: <20261022090809.12019-1-yanxia@cmss.chinamobile.com>