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

From: Wenbo Sun

Date: Fri Nov 13 2026 - 09:04:43 EST


Hi Hangbin,

I sincerely apologize for sending out v2 too quickly yesterday before
giving you enough time to review the previous discussion. I really appreciate
your patience and thoughtful guidance.

Regarding your question on whether dev_uc_unsync()/dev_mc_unsync() could be
called from hsr_dev_close(), and whether they should be removed:

I traced the function calls and verified the behavior in a User-Mode Linux
(UML) environment across different lifecycle events:

1. Can they be called from hsr_dev_close()?
Yes. When an administrator administratively brings down the HSR interface
without deleting it (e.g. running "ip link set hsr0 down"):
- hsr_dellink() is NOT called, and ports remain in hsr->ports.
- dev_close() triggers ndo_stop (hsr_dev_close()), where hsr_for_each_port_rtnl()
successfully iterates over SLAVE_A and SLAVE_B.
- Both dev_uc_unsync() and dev_mc_unsync() ARE actively called here to unsync
addresses, ensuring physical slaves stop filtering for HSR multicast while
hsr0 is DOWN (and re-synced by hsr_set_rx_mode() once brought back UP).
Therefore, they are NOT dead code in hsr_dev_close() and should NOT be removed.

2. Why do we still need the cleanup in hsr_del_port()?
Because in port removal/deletion paths, hsr_dev_close() cannot perform this cleanup:
- Master deletion ("ip link del hsr0"): In hsr_dellink(), hsr_del_ports()
detaches all ports from hsr->ports BEFORE calling unregister_netdevice_queue().
When unregister_netdevice_many_notify() subsequently invokes hsr_dev_close(),
hsr->ports is already empty, so the unsync loop runs 0 times.
- Slave unregistration ("ip link del veth0" while hsr0 is UP): hsr_netdev_notify()
calls hsr_del_port() directly without calling hsr_dev_close().
- In addition, hsr_change_rx_flags() propagates IFF_ALLMULTI via
dev_set_allmulti(slave, 1), but neither hsr_dev_close() nor the original
hsr_del_port() ever restored it.

Adding dev_uc_unsync(), dev_mc_unsync(), and dev_set_allmulti(port->dev, -1)
in hsr_del_port() ensures that whenever a slave port is detached, its synced
state and allmulti count are cleanly restored (mirroring the cleanup in
macvlan_uninit() and team_port_del()).

Per your comment on v1, I have dropped your Reviewed-by tag and will incorporate
the detailed reproducer and lifecycle trace steps into the commit message notes
(under the --- section).

Because v2 was sent yesterday at 14:47:16 (+0800), I will wait until the 24-hour
cooldown period has elapsed (after 14:47:16 today) before submitting [PATCH net v3],
giving us full time to discuss.

Please let me know if this clarifies the call flow and whether you are comfortable
with this plan.

Thanks again for your time!

Best regards,
Wenbo Sun