struct netlink_ext_ack *extack)
{
struct net_device *dev = team->dev;
- struct team_port *port;
char *portname = port_dev->name;
+ struct team_port *port;
int err;
if (port_dev->flags & IFF_LOOPBACK) {
memcpy(port->orig.dev_addr, port_dev->dev_addr, port_dev->addr_len);
- err = team_port_enter(team, port);
+ err = dev_open(port_dev, extack);
if (err) {
- netdev_err(dev, "Device %s failed to enter team mode\n",
+ netdev_dbg(dev, "Device %s opening failed\n",
portname);
- goto err_port_enter;
+ goto err_dev_open;
}
- err = dev_open(port_dev, extack);
+ err = team_upper_dev_link(team, port, extack);
if (err) {
- netdev_dbg(dev, "Device %s opening failed\n",
+ netdev_err(dev, "Device %s failed to set upper link\n",
portname);
- goto err_dev_open;
+ goto err_set_upper_link;
+ }
+
+ /* lockdep subclass variable(dev->nested_level) was updated by
+ * team_upper_dev_link().
+ */
+ team_unlock(team);
+ team_lock(team);
+
+ err = team_port_enter(team, port);
+ if (err) {
+ netdev_err(dev, "Device %s failed to enter team mode\n",
+ portname);
+ goto err_port_enter;
}
err = vlan_vids_add_by_dev(port_dev, dev);
goto err_handler_register;
}
- err = team_upper_dev_link(team, port, extack);
- if (err) {
- netdev_err(dev, "Device %s failed to set upper link\n",
- portname);
- goto err_set_upper_link;
- }
-
err = __team_option_inst_add_port(team, port);
if (err) {
netdev_err(dev, "Device %s failed to add per-port options\n",
__team_option_inst_del_port(team, port);
err_option_port_add:
- team_upper_dev_unlink(team, port);
-
-err_set_upper_link:
netdev_rx_handler_unregister(port_dev);
err_handler_register:
vlan_vids_del_by_dev(port_dev, dev);
err_vids_add:
+ team_port_leave(team, port);
+
+err_port_enter:
+ team_upper_dev_unlink(team, port);
+
+err_set_upper_link:
dev_close(port_dev);
err_dev_open:
- team_port_leave(team, port);
team_port_set_orig_dev_addr(port);
-
-err_port_enter:
dev_set_mtu(port_dev, port->orig.mtu);
err_set_mtu:
int err;
team->dev = dev;
+ mutex_init(&team->lock);
team_set_no_mode(team);
team->notifier_ctx = false;
goto err_options_register;
netif_carrier_off(dev);
- lockdep_register_key(&team->team_lock_key);
- __mutex_init(&team->lock, "team->team_lock_key", &team->team_lock_key);
netdev_lockdep_set_classes(dev);
return 0;
struct team_port *port;
struct team_port *tmp;
- mutex_lock(&team->lock);
+ team_lock(team);
list_for_each_entry_safe(port, tmp, &team->port_list, list)
team_port_del(team, port->dev);
team_mcast_rejoin_fini(team);
team_notify_peers_fini(team);
team_queue_override_fini(team);
- mutex_unlock(&team->lock);
+ team_unlock(team);
netdev_change_features(dev);
- lockdep_unregister_key(&team->team_lock_key);
}
static void team_destructor(struct net_device *dev)
static int team_set_mac_address(struct net_device *dev, void *p)
{
- struct sockaddr *addr = p;
struct team *team = netdev_priv(dev);
+ struct sockaddr *addr = p;
struct team_port *port;
if (dev->type == ARPHRD_ETHER && !is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;
dev_addr_set(dev, addr->sa_data);
- mutex_lock(&team->lock);
+ team_lock(team);
list_for_each_entry(port, &team->port_list, list)
if (team->ops.port_change_dev_addr)
team->ops.port_change_dev_addr(team, port);
- mutex_unlock(&team->lock);
+ team_unlock(team);
return 0;
}
* Alhough this is reader, it's guarded by team lock. It's not possible
* to traverse list in reverse under rcu_read_lock
*/
- mutex_lock(&team->lock);
+ team_lock(team);
team->port_mtu_change_allowed = true;
list_for_each_entry(port, &team->port_list, list) {
err = dev_set_mtu(port->dev, new_mtu);
}
}
team->port_mtu_change_allowed = false;
- mutex_unlock(&team->lock);
+ team_unlock(team);
dev->mtu = new_mtu;
list_for_each_entry_continue_reverse(port, &team->port_list, list)
dev_set_mtu(port->dev, dev->mtu);
team->port_mtu_change_allowed = false;
- mutex_unlock(&team->lock);
+ team_unlock(team);
return err;
}
* Alhough this is reader, it's guarded by team lock. It's not possible
* to traverse list in reverse under rcu_read_lock
*/
- mutex_lock(&team->lock);
+ team_lock(team);
list_for_each_entry(port, &team->port_list, list) {
err = vlan_vid_add(port->dev, proto, vid);
if (err)
goto unwind;
}
- mutex_unlock(&team->lock);
+ team_unlock(team);
return 0;
unwind:
list_for_each_entry_continue_reverse(port, &team->port_list, list)
vlan_vid_del(port->dev, proto, vid);
- mutex_unlock(&team->lock);
+ team_unlock(team);
return err;
}
struct team *team = netdev_priv(dev);
struct team_port *port;
- mutex_lock(&team->lock);
+ team_lock(team);
list_for_each_entry(port, &team->port_list, list)
vlan_vid_del(port->dev, proto, vid);
- mutex_unlock(&team->lock);
+ team_unlock(team);
return 0;
}
{
struct team *team = netdev_priv(dev);
- mutex_lock(&team->lock);
+ team_lock(team);
__team_netpoll_cleanup(team);
- mutex_unlock(&team->lock);
+ team_unlock(team);
}
static int team_netpoll_setup(struct net_device *dev,
struct team_port *port;
int err = 0;
- mutex_lock(&team->lock);
+ team_lock(team);
list_for_each_entry(port, &team->port_list, list) {
err = __team_port_enable_netpoll(port);
if (err) {
break;
}
}
- mutex_unlock(&team->lock);
+ team_unlock(team);
return err;
}
#endif
struct team *team = netdev_priv(dev);
int err;
- mutex_lock(&team->lock);
+ team_lock(team);
err = team_port_add(team, port_dev, extack);
- mutex_unlock(&team->lock);
+ team_unlock(team);
if (!err)
netdev_change_features(dev);
struct team *team = netdev_priv(dev);
int err;
- mutex_lock(&team->lock);
+ team_lock(team);
err = team_port_del(team, port_dev);
- mutex_unlock(&team->lock);
-
- if (err)
- return err;
+ team_unlock(team);
- if (netif_is_team_master(port_dev)) {
- lockdep_unregister_key(&team->team_lock_key);
- lockdep_register_key(&team->team_lock_key);
- lockdep_set_class(&team->lock, &team->team_lock_key);
- }
- netdev_change_features(dev);
+ if (!err)
+ netdev_change_features(dev);
return err;
}
}
team = netdev_priv(dev);
- mutex_lock(&team->lock);
+ __team_lock(team);
return team;
}
static void team_nl_team_put(struct team *team)
{
- mutex_unlock(&team->lock);
+ team_unlock(team);
dev_put(team->dev);
}
{
struct team *team = port->team;
- mutex_lock(&team->lock);
+ team_lock(team);
__team_port_change_check(port, linkup);
- mutex_unlock(&team->lock);
+ team_unlock(team);
}