Article View: linux.kernel.netdev
Article #14917Re: [PATCH net] net: hsr: clean up synced addresses and allmulti in hsr_del_port()
From: Wenbo Sun
Date: Thu, 12 Nov 2026 06:44
Date: Thu, 12 Nov 2026 06:44
67 lines
11898 bytes
11898 bytes
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. 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. 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 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. Thanks again, Wenbo
Technical Details
Message-ID:
<20261112064459.81535-1-sunwenbo@cmss.chinamobile.com>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-361535-linux-kernel-netdev=dewy.ruReferences:
<20261111060143.183670-1-sunwenbo@cmss.chinamobile.com> <avULIJLRzOEoefJI@fedora> <avUQ5dAMMRlUTNzq@fedora>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-361535-linux-kernel-netdev=dewy.ru From: sunwenbo@cmss.chinamobile.com (Wenbo Sun) 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 14:44:59 +0800 Organization: Usenet Network Message-ID: <20261112064459.81535-1-sunwenbo@cmss.chinamobile.com> References: <20261111060143.183670-1-sunwenbo@cmss.chinamobile.com> <avULIJLRzOEoefJI@fedora> <avUQ5dAMMRlUTNzq@fedora> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1028397"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:/LBR7UFpegUG+VN9xUIoCUByT/w= sha256:enqF3qnIMv1ZlQtYPrYCaMsdridYURve4pwd32nI9YQ= sha1:HpAnuv++9/W9ErjWt8TGcWVS3tk= sha256:Gcui+k9XPiRuJKi2nJ4y/N8Hk/tXVE7T9Stf6NboL94= 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 50EDC1140FC; Thu, 12 Nov 2026 09:47:02 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.751 X-Spam-Status: No, score=-2.751 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_INVALID=0.1, DKIM_SIGNED=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=fail (1024-bit key) reason="fail (body has been altered)" header.d=cmss.chinamobile.com 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 pUNmksqavKFT; Thu, 12 Nov 2026 09:46:56 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-361535-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=cmss.chinamobile.com X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 6395311411D; Thu, 12 Nov 2026 09:46:46 +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 A23084645A; Thu, 12 Nov 2026 06:45:27 +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=1794465924; b=5ge3uwIDps2+/FDB9sgxIIgkFtL/+6DSBVu+VWf9Ie+9Zyk6DqzvV5GvKNDJeeE4sIRZ irPJ7B/XkzrjzOUIPDFGhPTj4FrcCmg4uvr/dpZEVKaMt3PSl4k/DeY/bBVX7PA8Z7svz 9zGT5AwIXeX5MyBlujdeGkioiwEyW7pnFunEaut9omvEqtP5mY+CxD8dSY7LKvFCoQcUd Ei4cjgn748Y3a2CAZ90Z/n2on/SlNFZtSABw9jBm+7PbXtfaZXeChnzMHcxGwFN1Te9fS d+bjySJdAIaPlF9fNmXJFMSWPKCAnLzpb+s848MeR24GIjaoT+JZ3qdn4/K94eN3jYA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794465924; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-RM-TagInfo: X-RM-SPAM-FLAG:Received:X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG: Received:X-RM-TRANSID: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-Type:Content-Transfer-Encoding; bh=PH7FPXKmXWwh86LBiWXSpBFcw8LkkIhddh/M7mADpoA=; b=Z4tGmvZRqMUz3/ALbz54Z4rzR3R6uKggjADDtyQVoV/dbVxVaGquQiwcnJ2q7m9Wam7K uA8/ayx5H6JlIyykAlbwYS18d+04H4zCfWTG2JT0yG5OgVvJMls8y8seMqzQ6GCq2EDhJ ijQUnPGKzEA4pr30MvWR+E7UR2XtcB2gnxmyLZtY/2ku4tnTbkMLseqpPnymDU05I0ysR gCZC5ocYWKYdKsY2bsu1eoWq8KRnJ2qTsowQ52pif+jPpn23gDqTWD4FHeH5F1RJb97/e geDB0mHT3DhmXofBqCEi6EC6IFx+cbB6x/9lC+ijgEpz98X8MK0Z9Gku4wOSgc737+A== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=ymSbpqUV; dmarc=pass header.from=cmss.chinamobile.com; spf=pass smtp.mailfrom=cmss.chinamobile.com; 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 C281C606A33B; Thu, 12 Nov 2026 06:45:24 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=ymSbpqUV X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.137 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794465923; b=qtvpXHkHaael+QYt4uctZM1KLR6ziRg8o6gcAgd/bfRRoSKKRpguuzj6XOIrXtNmWWF1 XsWbz7Wms5WcMG534FmOP6CnDGFb5vDAvvZy3KWX/M+9s4UM4uEbSIzpn/OdgtMcwwNCn muU+ncYa6tVKEZUqLHRia/4T+QNWygQEmAI01VPX4BZAyjge/l1WVQ6ut1yY0Rm/G+BDc 9hYlgc5Cz575+TtF99QJr8ubmN0SLNAMrJe/KJOF9KgpPruIcQGWl/4lIy+SaCO3ICXGH ovG4xvsI3rA7P6bIfISYpLnwbSMo3lsJ9DbQfnQUe2xfJL2hbmvLqe8CLdVDW1vjB9Q== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794465923; h=DMARC-Filter:DKIM-Signature:X-RM-TagInfo:X-RM-SPAM-FLAG:Received: X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:X-RM-TRANSID:From: To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=PH7FPXKmXWwh86LBiWXSpBFcw8LkkIhddh/M7mADpoA=; b=ZKBNAIheHnlGqLg20KbOs6f/GSNPcNXlHzokI7+ZNPXmmCrTXn+Co/7kKhCO34XPOc+7 uVqITwHOEJZVn1hhY+6p//zEIcTjpDuOemK7LooeH0WIuGMwQplZt1gqo3fZwE64p1u+8 8/DUIiQz4eAuJGwYpgZMDm8U8N907JAUawHWjPgULffJ+dHolqtmMdflTCey7hbtVJH+f 2X+BRZ+EHmAy5YiLRccS0GUXARpYrW4j/56ow4Gnd9+rwHP9SejMwJbt6phGGaPPu1Hdy h3KVy/nG0Qd1n63Fhe46wCKmzVj50Gaqq5ezZy017qwM3c8ybVV5j37SxN5tQe8Irlg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=cmss.chinamobile.com; spf=pass smtp.mailfrom=cmss.chinamobile.com; dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=ymSbpqUV; arc=none smtp.remote-ip=111.22.67.137 X-Received: from cmccmta4.chinamobile.com (cmccmta4.chinamobile.com [111.22.67.137]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B10C9606A31C; Thu, 12 Nov 2026 06:45:21 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B10C9606A31C X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmss.chinamobile.com; s=default; l=0; h=from:subject:message-id:to:cc:mime-version; bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=; b=ymSbpqUVBIpRATdz2wahkZ5KpQq4S30Dx1UdKRR9ULig5alk8DxYjdz+IYafo7AXDZNX+5MfTne8F YVMxXQc6SVk4vFkh16+bhcGX5QJKaIOjCFVn1qt0GfDyQIOCiYXkUiYIToFnKQjhqjY8eLxp+xaHCm /GekKm6UupsYvRTE= X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-Received: from spf.mail.chinamobile.com (unknown[10.188.0.87]) by rmmx-syy-dmz-app08-12008 (RichMail) with SMTP id 2ee86af5607e80a-7ea8d; Thu, 12 Nov 2026 14:45:19 +0800 (CST) X-RM-TRANSID: 2ee86af5607e80a-7ea8d X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-Received: from localhost.net (unknown[223.64.115.200]) by rmsmtp-syy-appsvr10-12010 (RichMail) with SMTP id 2eea6af5607d33a-f5871; Thu, 12 Nov 2026 14:45:18 +0800 (CST) X-RM-TRANSID: 2eea6af5607d33a-f5871 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, sunwenbo@cmss.chinamobile.com, 1342116488@qq.com X-Mailer: git-send-email 2.33.0 X-In-Reply-To: <avUQ5dAMMRlUTNzq@fedora> 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