]> git.itanic.dy.fi Git - linux-stable/commitdiff
net: team: Unsync device addresses on ndo_stop
authorBenjamin Poirier <bpoirier@nvidia.com>
Wed, 7 Sep 2022 07:56:41 +0000 (16:56 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Sep 2022 09:02:56 +0000 (11:02 +0200)
[ Upstream commit bd60234222b2fd5573526da7bcd422801f271f5f ]

Netdev drivers are expected to call dev_{uc,mc}_sync() in their
ndo_set_rx_mode method and dev_{uc,mc}_unsync() in their ndo_stop method.
This is mentioned in the kerneldoc for those dev_* functions.

The team driver calls dev_{uc,mc}_unsync() during ndo_uninit instead of
ndo_stop. This is ineffective because address lists (dev->{uc,mc}) have
already been emptied in unregister_netdevice_many() before ndo_uninit is
called. This mistake can result in addresses being leftover on former team
ports after a team device has been deleted; see test_LAG_cleanup() in the
last patch in this series.

Add unsync calls at their expected location, team_close().

v3:
* When adding or deleting a port, only sync/unsync addresses if the team
  device is up. In other cases, it is taken care of at the right time by
  ndo_open/ndo_set_rx_mode/ndo_stop.

Fixes: 3d249d4ca7d0 ("net: introduce ethernet teaming device")
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/team/team.c

index 8a1e9dba1249e5f28def449fc4c0caf89ad48829..2410f08e2bb5cdb42ed73cfa3c6ad18adf83a5fc 100644 (file)
@@ -1280,10 +1280,12 @@ static int team_port_add(struct team *team, struct net_device *port_dev,
                }
        }
 
-       netif_addr_lock_bh(dev);
-       dev_uc_sync_multiple(port_dev, dev);
-       dev_mc_sync_multiple(port_dev, dev);
-       netif_addr_unlock_bh(dev);
+       if (dev->flags & IFF_UP) {
+               netif_addr_lock_bh(dev);
+               dev_uc_sync_multiple(port_dev, dev);
+               dev_mc_sync_multiple(port_dev, dev);
+               netif_addr_unlock_bh(dev);
+       }
 
        port->index = -1;
        list_add_tail_rcu(&port->list, &team->port_list);
@@ -1354,8 +1356,10 @@ static int team_port_del(struct team *team, struct net_device *port_dev)
        netdev_rx_handler_unregister(port_dev);
        team_port_disable_netpoll(port);
        vlan_vids_del_by_dev(port_dev, dev);
-       dev_uc_unsync(port_dev, dev);
-       dev_mc_unsync(port_dev, dev);
+       if (dev->flags & IFF_UP) {
+               dev_uc_unsync(port_dev, dev);
+               dev_mc_unsync(port_dev, dev);
+       }
        dev_close(port_dev);
        team_port_leave(team, port);
 
@@ -1703,6 +1707,14 @@ static int team_open(struct net_device *dev)
 
 static int team_close(struct net_device *dev)
 {
+       struct team *team = netdev_priv(dev);
+       struct team_port *port;
+
+       list_for_each_entry(port, &team->port_list, list) {
+               dev_uc_unsync(port->dev, dev);
+               dev_mc_unsync(port->dev, dev);
+       }
+
        return 0;
 }