Article View: linux.kernel.netdev
Article #14805Re: [PATCH net] net: hsr: clean up synced addresses and allmulti in hsr_del_port()
From: Hangbin Liu
Date: Thu, 12 Nov 2026 01:05
Date: Thu, 12 Nov 2026 01:05
69 lines
11402 bytes
11402 bytes
On Wed, Nov 11, 2026 at 02:01:43PM +0800, Wenbo Sun wrote:
> hsr_set_rx_mode() syncs unicast and multicast addresses to slave A and
> slave B devices via dev_uc_sync_multiple() and dev_mc_sync_multiple(),
> and hsr_change_rx_flags() propagates IFF_ALLMULTI via
> dev_set_allmulti().
>
> However, when an HSR device is deleted via hsr_dellink(),
> hsr_del_ports() removes all ports from hsr->ports before
> unregister_netdevice_queue() invokes hsr_dev_close(). Similarly, when a
> slave device is unregistered while the HSR master is UP,
> hsr_netdev_notify() calls hsr_del_port() directly. Because
> hsr_del_port() does not unsync unicast/multicast addresses or restore
> the allmulti count, the slave devices permanently retain synced hardware
> addresses and a leaked allmulti reference count after port deletion.
>
> Fix this by calling dev_uc_unsync() and dev_mc_unsync(), and
> decrementing allmulti via dev_set_allmulti(port->dev, -1) if
> IFF_ALLMULTI is set on the master device, when detaching slave A or
> slave B in hsr_del_port().
>
> This issue was identified with the assistance of an LLM-based code
> review tool, confirmed by reproducing the leaked allmulti reference
> count and synced multicast address in a User-Mode Linux (UML)
> environment, and verified in UML that both states are properly cleaned
> up upon HSR port deletion.
>
> Fixes: 36b20fcdd966 ("net: hsr: Add support for MC filtering at the slave device")
> Signed-off-by: Wenbo Sun <sunwenbo@cmss.chinamobile.com>
> ---
> net/hsr/hsr_slave.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/net/hsr/hsr_slave.c b/net/hsr/hsr_slave.c
> index a546f70f9cc8..bab0c27dd06a 100644
> --- a/net/hsr/hsr_slave.c
> +++ b/net/hsr/hsr_slave.c
> @@ -245,8 +245,14 @@ void hsr_del_port(struct hsr_port *port)
> netdev_rx_handler_unregister(port->dev);
> if (!port->hsr->fwd_offloaded || port->type == HSR_PT_INTERLINK)
> dev_set_promiscuity(port->dev, -1);
> - if (port->type == HSR_PT_SLAVE_A || port->type == HSR_PT_SLAVE_B)
> + if (port->type == HSR_PT_SLAVE_A ||
> + port->type == HSR_PT_SLAVE_B) {
> vlan_vids_del_by_dev(port->dev, master->dev);
> + dev_uc_unsync(port->dev, master->dev);
> + dev_mc_unsync(port->dev, master->dev);
> + if (master->dev->flags & IFF_ALLMULTI)
> + dev_set_allmulti(port->dev, -1);
> + }
> netdev_upper_dev_unlink(port->dev, master->dev);
> if (hsr->prot_version == PRP_V1 &&
> port->type == HSR_PT_SLAVE_B) {
> --
> 2.33.0
>
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?
Thanks
Hangbin
Technical Details
Message-ID:
<avUQ5dAMMRlUTNzq@fedora>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-361412-linux-kernel-netdev=dewy.ruReferences:
<20261111060143.183670-1-sunwenbo@cmss.chinamobile.com>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-361412-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 09:05:41 +0800 Organization: Usenet Network Message-ID: <avUQ5dAMMRlUTNzq@fedora> References: <20261111060143.183670-1-sunwenbo@cmss.chinamobile.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="979265"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:1EEtciZ/LsAVsFeANsC+7OZVyYo= sha256:1A8UVFAeu1W2GTzHC6Udr3+u9Uas/9WpKFXMADuORdc= sha1:wZra5q92Ihnf7BpW9M5ywHHI9wg= sha256:Nwwy01NlAu4K9suCOJFk3Kji/1uWsSVLRW+v9IfQgfA= 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 B995A1140A2; Thu, 12 Nov 2026 04:13:36 +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 UhVKCt4R0Tuw; Thu, 12 Nov 2026 04:13:33 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-361412-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id CD650113FAE; Thu, 12 Nov 2026 04:13:23 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 6A8D9C638D; Thu, 12 Nov 2026 01:06:20 +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=1794445564; b=pxuRZY5UVZsVKD7cPj0cpv+Qv3y6F3YVwwN/O49hBogGBKana4ZSbAs/E/lIdVh7I/dl AaL5vc16ePYDuM8XZycacAhwdAi8Rhc+6QpqYb1kDEwPcD81To1BSOEaNR20rPNYMbCHs Hq2xUo6R9MrL4iq0kYTJ8r9dWvGdpqUdjzhaViO3A5bqSAgSv6ZSzMng730Ya990jxEz8 Bc2aaOyRwHsQgAbIXZKXAxAcgoAgrbyGYHLoPiicqrhABn0VspomY6NzQHVEvr+JbNrlT dxY3CrWDcWf4vw3BSnpAFmB1/c4tv4ckZJEtlPBcHAcjX36KNEGA9izDF6R13W+hj0A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794445564; 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=eYwsRxOsEMHA3DkX0f0CV+Z+v0W7uUrlEZM5+4lXwUU=; b=j5/eZAf13VcKWJJAKD8Vzf0xWUb18C2HSbB6HgZ+9dNQc1HPi3XbrHCaTLyqahZxB7S0 a7UhIbej14A0dgzoN8LKXKzEqvDJOsqpVB9aBQiBcabglBsE72Y9IFSpMjMmGu3zEQVeU l9i/x1nMP1MfBPWDg6ESHpShFIoJW3PDUhcqRdRtZLi5hKobhtYfI89qA37bNmS/5aU29 LqTl4A0NHPppE/u3TQ2KrLBBtG0bcqThBYNd0gBVy50MQDJlUO/HKxklBKQuBxiosmd1e 21hx9NyDO9dE/QO3y//jCuCHVPvnDKu3lIMgCnV54VQFUxJa/kcwJisxuavNWUCv0Gw== 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=RmRbPnJA; 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 E4B16606A336; Thu, 12 Nov 2026 01:06:03 +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=RmRbPnJA X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.40 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794445558; b=0KhzQT5TT9vA6FXw6wWYqaKKN/rCSVEa3CCntpgastgsxvEOeGDamlSC9MVu6Hdz96Br lXwgXXnPDhLy7mDErVbpW12x5VFRXoGUsRPeDb7mVAnzaHjBvfY1tE1GZ0qKc8Ykfg0xx NyQojBbm0gCxsKenWZsHGtnUKvUHzMmaM6NDflc9R2CTZOB++GmLsxjsSWID3vCtBaNte WWIbfQXrtDjxY8/o4aA19UqUGRN2bIeB4gPmPm/Y3XFK0NkMJ+DZZCVXm2JKSX0SjgSY5 CoFJSbfI24LI7IqHbnZZSg8aAsH/KOb7Wlco0wGzUIRhlanK8Q3hUmA7oyjHxCs1wTQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794445558; 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=eYwsRxOsEMHA3DkX0f0CV+Z+v0W7uUrlEZM5+4lXwUU=; b=0mFUFtfduPFQDwcFlesLSuVWiPxqgaykFJLUKaCgh2LjoiqneZOVSAvWLpDXj9tkMM/R c4vciUfiUU/HqwhGooKdLrJzLnnkWxwHcLNClZhOzvlPNnn4zVA6w3XgCpgmohGWghU4m AUOTmJJaRD4DPZXQuBGaoxnJA32owqdT29dWhUVpWCgcIP1n9lASmiJ9yOQ62wRQMU0B+ q972bdu5wOVCaaylAy8Fmro6D8uE2RmhyEGsjhmAGxJJ7Jt6Va+U0Ewis2mCf2JPUBjXl 5/hRsL7YWEo0QEm4MfriTxnyUWoxuU229sPpnvk3Sdlj589q3h1e/TdddCtcxBWcTVQ== 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=RmRbPnJA; arc=none smtp.remote-ip=91.218.175.40 X-Received: from mta0.migadu.com (out-40.mta0.migadu.com [91.218.175.40]) (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 B7172606A33D for <netdev@vger.kernel.org>; Thu, 12 Nov 2026 01:05:56 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B7172606A33D 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=sW31Mhk6Zdi3FsOK//N9bHRAgzlVLc7voc1yH7U/NNw=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1794445554; v=1; x=1795050354; b=RmRbPnJAhPUwyMgzbUXtctYoxObMDMxIBvVAgdIKgsXvIqE4kMqtXpRAoSHHd0KJ/mwEPZaC bcsEBY1RSCCYMf72KjgfLGFjfvTWjMTKuvfv4KhNVMaCfGiyJWJMuHb5OGAP70gbqPM3dhPxFeh mKl4waXK6BS3ltWdWX3G8ACc= X-Envelope-To: netdev@vger.kernel.org X-Received: by mta12.migadu.com with ESMTPS id 27b18086ca939e00; Thu, 12 Nov 2026 01:05:54 +0000 X-Mizu-Trace-ID: 27b18086ca939e00 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: <20261111060143.183670-1-sunwenbo@cmss.chinamobile.com>