🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #15031

Re: [PATCH net] net: hsr: clean up synced addresses and allmulti in hsr_del_port()

#15031
From: Hangbin Liu
Date: Thu, 12 Nov 2026 09:41
86 lines
12227 bytes
On Thu, Nov 12, 2026 at 02:44:59PM +0800, Wenbo Sun wrote:
> Hi Hangbin,
> 
> Thank you very much for the Reviewed-by and for raising this question!
> 
> On Thu, Nov 12, 2026 at 09:05:41AM +0800, Hangbin Liu wrote:
> > Sorry. I just got a question.
> >
> > hsr_del_port() is called via dev unregister or hsr_dellink() -> hsr_del_ports().
> > The hsr_dellink() also calls unregister devices.
> >
> > The unregister process will stop a device if it's up. And hsr_dev_close() has
> > called dev_uc_unsync() and dev_mc_unsync().
> >
> > Could you share more details on how you performed the testing?
> 
> Here is why hsr_dev_close() does not clean them up in those paths, and
> how the test reproduces it:
> 
> 1. Call order in hsr_dellink() (net/hsr/hsr_netlink.c):
>    hsr_dellink() calls hsr_del_ports(hsr) *before*
>    unregister_netdevice_queue(dev, head). Inside hsr_del_ports(), every
>    port is removed from hsr->ports via list_del_rcu(&port->port_list)
>    and freed. When unregister_netdevice_many_notify() later invokes
>    netif_close_many() -> hsr_dev_close(), hsr_for_each_port_rtnl(hsr,
>    port) sees an already-empty list, so dev_uc_unsync() and
>    dev_mc_unsync() are never called on the slaves.

Oh, since dev_uc_unsync() and dev_mc_unsync() is never called by
hsr_dev_close(), should we remove them from there?

On the other hand, the comment of dev_uc_unsync() said it is intended
to be called from the dev->stop.

So we need to chose one place for these undoes. I personally agree to
add it in hsr_dellink() as all the hsr info is remove in hsr_dellink.

> 2. Similarly, when a slave is unregistered directly while hsr0 is UP,
>    hsr_netdev_notify() (NETDEV_UNREGISTER) calls hsr_del_port(port)
>    before any close/dellink takes place.
> 3. Also, hsr_dev_close() never calls dev_set_allmulti(port->dev, -1)
>    (and dev_close() preserves IFF_ALLMULTI), so the allmulti refcount
>    leaks even if hsr0 is brought down before deletion.

Yes, I see the allmulti is not called in hsr_dev_close.

> 
> Here are the exact test steps I ran in UML (using veth pairs):
> 
>   ip link add veth0 type veth peer name veth0p
>   ip link add veth1 type veth peer name veth1p
>   ip link set veth0 up && ip link set veth0p up
>   ip link set veth1 up && ip link set veth1p up
>   # Create hsr0 with slave1=veth0, slave2=veth1 (RTM_NEWLINK)
>   ip link set hsr0 up
>   # Set IFF_ALLMULTI (SIOCSIFFLAGS) and add 01:00:5e:00:12:34 (SIOCADDMULTI)
>   # Verify IFLA_ALLMULTI on veth0 == 1 and /proc/net/dev_mcast has 01005e001234
>   ip link del hsr0
>   # Re-check IFLA_ALLMULTI on veth0 and /proc/net/dev_mcast
> 
> Observed results on unpatched kernel:
>   [BEFORE DEL] veth0 allmulti_refcnt=1, synced_mcast(01005e001234)=1
>   veth0: left promiscuous mode
>   veth1: left promiscuous mode
>   [AFTER DEL]  veth0 allmulti_refcnt=1, synced_mcast(01005e001234)=1
> 
> Observed results with this patch:
>   [BEFORE DEL] veth0 allmulti_refcnt=1, synced_mcast(01005e001234)=1
>   veth0: left promiscuous mode
>   veth0: left allmulticast mode
>   veth1: left promiscuous mode
>   veth1: left allmulticast mode
>   [AFTER DEL]  veth0 allmulti_refcnt=0, synced_mcast(01005e001234)=0

Thanks, this reproducer is more detailed. Would you please
add this info in the --- part of next patch?
> 
> I will also send a v2 with an updated commit message noting explicitly
> that hsr_dev_close() sees an empty port list (along with your
> Reviewed-by). Please let me know if you have any further questions.

Please drop my reviewed by tag if the code changed.

Thanks
Hangbin
Technical Details
Message-ID: <avWJrwDyT8HJHWSN@fedora>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361666-linux-kernel-netdev=dewy.ru
References: <20261111060143.183670-1-sunwenbo@cmss.chinamobile.com> <avULIJLRzOEoefJI@fedora> <avUQ5dAMMRlUTNzq@fedora> <20261112064459.81535-1-sunwenbo@cmss.chinamobile.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361666-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] net: hsr: clean up synced addresses and allmulti in
 hsr_del_port()
Date: Thu, 12 Nov 2026 17:41:03 +0800
Organization: Usenet Network
Message-ID: <avWJrwDyT8HJHWSN@fedora>
References: <20261111060143.183670-1-sunwenbo@cmss.chinamobile.com>
 <avULIJLRzOEoefJI@fedora>
 <avUQ5dAMMRlUTNzq@fedora>
 <20261112064459.81535-1-sunwenbo@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="1058388"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:rIFbCbkOh/bsm/a85l8XVhWu9zo= sha256:LejIPb5USPukpHoCde4N5CF+5aFmjLa3WaM41DoL03o=
	sha1:4/r9y0QCrEEFjZQ0uOJPFQ5SQ+o= sha256:syV3AS8xQgZWxZJIWcrhmTxDP1GNC263jmWYCo9TtNk=
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 06E341141AB; Thu, 12 Nov 2026 13:15:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 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.249,
	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 (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 c6N3YVoQsWJ5;
	Thu, 12 Nov 2026 13:15:50 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-361666-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 9FA4711415F; Thu, 12 Nov 2026 13:15:41 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 20CBCE8A78; Thu, 12 Nov 2026 09:42:42 +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=1794476479;
	b=gU7bis8t0GgsNlcHYN7jE89FnApml4JqCZ3wt2FkfLo/9QWlv6Il44qf+eBT8zvtPheq
	 HYConnZtZDeqLoIVKr59TIie6+5zYYpnlVgH+ra3HxAZ9NJa110Mfo2YKr8FwEfak9BOl
	 4KVJpV70D+xDrcOtjwmMr0XszGZoPFBu25oLrXuksLDPSSAdCfeusWZVUBVU5M0O2U8zT
	 cWxQkAhhVAEtbCk9buGpp1nnBkFGZH+6+1bAoPQqkM9QAsn6WhYDRKt8hlelJakZsKTMw
	 w42XP0a8JnT4lUboJ7tKG1v3ljpMxhFBRh+b+qp6Goux39AkzxfS+HHtIXF10idnWdw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794476479;
	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=LYSO9/G+nFBoVNURsqyo9sHLReLzezHi8+C++TTDM7Y=;
	b=ybv6lMsRTKTtuxk9TvilHWMOjJfI1nLW411gmVaL+h4kyn/e2f6shRDzAP6/QwtC37D9
	 LFrGeN+8VFZ/8l9w2UQ3zT/SEV535pImz2wjYj85g0n9+VCFvuAnirzv1ovHkA1dvWh2Y
	 CZlcgVydpXfi2w11ATfo5OwI5BuMg3HHyIhkx9NUwg+O/ps5ezc4ASHaaUYxnTGaI6RGi
	 EUQT0s8BjwUxkKOqYuDwC1aSuO2+ybkmUADOyXBIphvA7Yt2igsOrUY/Eq5vQh6cZLx5l
	 nWRKvESCuEC/HtyhkNHuHohJZaBGB63k46yEwKp+Ck9YOYsha0pGH5Y45zNA6B5301g==
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=MJaPo8bf;
	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 D19D860A2635;
	Thu, 12 Nov 2026 09:41:19 +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=MJaPo8bf
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.177
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794476479;
	b=B139UjldmWgEFf1Hvq5MH3uH+6DrXMy7ltc5nytqVQ25Sm/dyIae7mEwhoxG1/weASQb
	 S5Y8Sjk4BvC9OPyTYLM0BsKXNuiT9lvPccDgvFLM5/Mk1jgInND/rB6QCdvwlD7tOxssn
	 CQBYy5vUf0UA5ra4BpiTrLplAVV0XIG7eAoivBNm6PAxVqxkQbC19aZ4A30Fignhw38R8
	 laEIay+XNSQfH3BFAqwVFOBOmRr/9mmk1hKFHt5KhjVA6bqAMQUWfTtezzIjflvSE55Td
	 Hesa7VzxA5+Og5f/Dfa0EqV6CA+mDWMxmRpahqWJ4yMXJ592kfA+6YJxIxXrgADlQdQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794476479;
	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=LYSO9/G+nFBoVNURsqyo9sHLReLzezHi8+C++TTDM7Y=;
	b=i327nTTUBNK99eblUdZdP3oM8CLRakRUVvyG0peR784EDcLMTeEg/XX9SmVxU334oZlA
	 856r+18k9tH/sFKVmlUiRS9HQoEhBvpSrsR1dxhBrWT0lsfZynIyn+O7Mmpxg3A7dCIb4
	 GX2GD1d5tU6a58MpqPHsxSQGT1tCi/q5gHnWbXtOt/2dvxUhnkuogny58UovlDpPKfOzZ
	 0n3LUKXZdMVusa5T4v2HiQfpAvpDrU/o+nTweT8v2wobc9xF2dUPVG0iKFz2Jy8FwdgoI
	 vTcOrVOr3UNVqTINu5CzON11cD8OVm09F0sFMvLvhSeoB08KdKIjtlPMnQgmYEZNaRA==
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=MJaPo8bf;
	arc=none smtp.remote-ip=95.215.58.177
X-Received: from mta1.migadu.com (out-177.mta1.migadu.com [95.215.58.177])
	(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 6276860A261F
	for <netdev@vger.kernel.org>; Thu, 12 Nov 2026 09:41:18 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6276860A261F
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=MEFt2EAwBQt77VedDYefJ9IZ2Qype05DO122KbkmEHI=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1794476476; v=1; x=1795081276;
 b=MJaPo8bfsoa2dlVqkiOwG1Zpdv18+RF+Fdz9rYnNYTs8NS/Ndp8g0Z4zz0p3RoXekXkm/hbi
 qQMXHhE2ZjdfCV6yJns1DID7lYaMkWa2WQsOp0scDWYfQ1hxtillXg1YBYUxMSukZkHYPZ0aIZm
 W4MFAQOc2EaIzAvly8HWb2YY=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta10.migadu.com with ESMTPS id f85c0bce8482aa4e;
	Thu, 12 Nov 2026 09:41:16 +0000
X-Mizu-Trace-ID: f85c0bce8482aa4e
X-Migadu-Flow: FLOW_OUT
X-Cc: "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Fernando Fernandez Mancera <fmancera@suse.de>,
	MD Danish Anwar <danishanwar@ti.com>,
	Murali Karicheri <m-karicheri2@ti.com>,
	Wojciech Drewek <wojciech.drewek@intel.com>,
	Ravi Gunasekaran <r-gunasekaran@ti.com>, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, 1342116488@qq.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: <20261112064459.81535-1-sunwenbo@cmss.chinamobile.com>