Commit 44d15d93 authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

team: Use extack to report enslavement failures

Use extack inside team's enslavement function and also propagate it to
the netdevice notifier to allow enslaved ports to report the failure
reason. Example:

$ teamd -t team0 -d -c '{"runner": {"name": "lacp"}}'
$ ip link set dev lo master team0
Error: Loopback device can't be added as a team port.
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Acked-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fb66cb07
...@@ -1105,14 +1105,15 @@ static void team_port_disable_netpoll(struct team_port *port) ...@@ -1105,14 +1105,15 @@ static void team_port_disable_netpoll(struct team_port *port)
} }
#endif #endif
static int team_upper_dev_link(struct team *team, struct team_port *port) static int team_upper_dev_link(struct team *team, struct team_port *port,
struct netlink_ext_ack *extack)
{ {
struct netdev_lag_upper_info lag_upper_info; struct netdev_lag_upper_info lag_upper_info;
int err; int err;
lag_upper_info.tx_type = team->mode->lag_tx_type; lag_upper_info.tx_type = team->mode->lag_tx_type;
err = netdev_master_upper_dev_link(port->dev, team->dev, NULL, err = netdev_master_upper_dev_link(port->dev, team->dev, NULL,
&lag_upper_info, NULL); &lag_upper_info, extack);
if (err) if (err)
return err; return err;
port->dev->priv_flags |= IFF_TEAM_PORT; port->dev->priv_flags |= IFF_TEAM_PORT;
...@@ -1129,7 +1130,8 @@ static void __team_port_change_port_added(struct team_port *port, bool linkup); ...@@ -1129,7 +1130,8 @@ static void __team_port_change_port_added(struct team_port *port, bool linkup);
static int team_dev_type_check_change(struct net_device *dev, static int team_dev_type_check_change(struct net_device *dev,
struct net_device *port_dev); struct net_device *port_dev);
static int team_port_add(struct team *team, struct net_device *port_dev) static int team_port_add(struct team *team, struct net_device *port_dev,
struct netlink_ext_ack *extack)
{ {
struct net_device *dev = team->dev; struct net_device *dev = team->dev;
struct team_port *port; struct team_port *port;
...@@ -1137,12 +1139,14 @@ static int team_port_add(struct team *team, struct net_device *port_dev) ...@@ -1137,12 +1139,14 @@ static int team_port_add(struct team *team, struct net_device *port_dev)
int err; int err;
if (port_dev->flags & IFF_LOOPBACK) { if (port_dev->flags & IFF_LOOPBACK) {
NL_SET_ERR_MSG(extack, "Loopback device can't be added as a team port");
netdev_err(dev, "Device %s is loopback device. Loopback devices can't be added as a team port\n", netdev_err(dev, "Device %s is loopback device. Loopback devices can't be added as a team port\n",
portname); portname);
return -EINVAL; return -EINVAL;
} }
if (team_port_exists(port_dev)) { if (team_port_exists(port_dev)) {
NL_SET_ERR_MSG(extack, "Device is already a port of a team device");
netdev_err(dev, "Device %s is already a port " netdev_err(dev, "Device %s is already a port "
"of a team device\n", portname); "of a team device\n", portname);
return -EBUSY; return -EBUSY;
...@@ -1150,6 +1154,7 @@ static int team_port_add(struct team *team, struct net_device *port_dev) ...@@ -1150,6 +1154,7 @@ static int team_port_add(struct team *team, struct net_device *port_dev)
if (port_dev->features & NETIF_F_VLAN_CHALLENGED && if (port_dev->features & NETIF_F_VLAN_CHALLENGED &&
vlan_uses_dev(dev)) { vlan_uses_dev(dev)) {
NL_SET_ERR_MSG(extack, "Device is VLAN challenged and team device has VLAN set up");
netdev_err(dev, "Device %s is VLAN challenged and team device has VLAN set up\n", netdev_err(dev, "Device %s is VLAN challenged and team device has VLAN set up\n",
portname); portname);
return -EPERM; return -EPERM;
...@@ -1160,6 +1165,7 @@ static int team_port_add(struct team *team, struct net_device *port_dev) ...@@ -1160,6 +1165,7 @@ static int team_port_add(struct team *team, struct net_device *port_dev)
return err; return err;
if (port_dev->flags & IFF_UP) { if (port_dev->flags & IFF_UP) {
NL_SET_ERR_MSG(extack, "Device is up. Set it down before adding it as a team port");
netdev_err(dev, "Device %s is up. Set it down before adding it as a team port\n", netdev_err(dev, "Device %s is up. Set it down before adding it as a team port\n",
portname); portname);
return -EBUSY; return -EBUSY;
...@@ -1227,7 +1233,7 @@ static int team_port_add(struct team *team, struct net_device *port_dev) ...@@ -1227,7 +1233,7 @@ static int team_port_add(struct team *team, struct net_device *port_dev)
goto err_handler_register; goto err_handler_register;
} }
err = team_upper_dev_link(team, port); err = team_upper_dev_link(team, port, extack);
if (err) { if (err) {
netdev_err(dev, "Device %s failed to set upper link\n", netdev_err(dev, "Device %s failed to set upper link\n",
portname); portname);
...@@ -1921,7 +1927,7 @@ static int team_add_slave(struct net_device *dev, struct net_device *port_dev, ...@@ -1921,7 +1927,7 @@ static int team_add_slave(struct net_device *dev, struct net_device *port_dev,
int err; int err;
mutex_lock(&team->lock); mutex_lock(&team->lock);
err = team_port_add(team, port_dev); err = team_port_add(team, port_dev, extack);
mutex_unlock(&team->lock); mutex_unlock(&team->lock);
if (!err) if (!err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment