mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-04 04:44:37 +08:00
bonding: combine netlink and console error messages
There seems to be no reason to have different error messages between netlink and printk. It also cleans up the function slightly. Signed-off-by: Jonathan Toppins <jtoppins@redhat.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
891a88f4f5
commit
6569fa2d4e
@ -1725,6 +1725,20 @@ void bond_lower_state_changed(struct slave *slave)
|
|||||||
netdev_lower_state_changed(slave->dev, &info);
|
netdev_lower_state_changed(slave->dev, &info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define BOND_NL_ERR(bond_dev, extack, errmsg) do { \
|
||||||
|
if (extack) \
|
||||||
|
NL_SET_ERR_MSG(extack, errmsg); \
|
||||||
|
else \
|
||||||
|
netdev_err(bond_dev, "Error: %s\n", errmsg); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define SLAVE_NL_ERR(bond_dev, slave_dev, extack, errmsg) do { \
|
||||||
|
if (extack) \
|
||||||
|
NL_SET_ERR_MSG(extack, errmsg); \
|
||||||
|
else \
|
||||||
|
slave_err(bond_dev, slave_dev, "Error: %s\n", errmsg); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/* enslave device <slave> to bond device <master> */
|
/* enslave device <slave> to bond device <master> */
|
||||||
int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
|
int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
|
||||||
struct netlink_ext_ack *extack)
|
struct netlink_ext_ack *extack)
|
||||||
@ -1738,9 +1752,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
|
|||||||
|
|
||||||
if (slave_dev->flags & IFF_MASTER &&
|
if (slave_dev->flags & IFF_MASTER &&
|
||||||
!netif_is_bond_master(slave_dev)) {
|
!netif_is_bond_master(slave_dev)) {
|
||||||
NL_SET_ERR_MSG(extack, "Device with IFF_MASTER cannot be enslaved");
|
BOND_NL_ERR(bond_dev, extack,
|
||||||
netdev_err(bond_dev,
|
"Device with IFF_MASTER cannot be enslaved");
|
||||||
"Error: Device with IFF_MASTER cannot be enslaved\n");
|
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1752,15 +1765,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
|
|||||||
|
|
||||||
/* already in-use? */
|
/* already in-use? */
|
||||||
if (netdev_is_rx_handler_busy(slave_dev)) {
|
if (netdev_is_rx_handler_busy(slave_dev)) {
|
||||||
NL_SET_ERR_MSG(extack, "Device is in use and cannot be enslaved");
|
SLAVE_NL_ERR(bond_dev, slave_dev, extack,
|
||||||
slave_err(bond_dev, slave_dev,
|
"Device is in use and cannot be enslaved");
|
||||||
"Error: Device is in use and cannot be enslaved\n");
|
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bond_dev == slave_dev) {
|
if (bond_dev == slave_dev) {
|
||||||
NL_SET_ERR_MSG(extack, "Cannot enslave bond to itself.");
|
BOND_NL_ERR(bond_dev, extack, "Cannot enslave bond to itself.");
|
||||||
netdev_err(bond_dev, "cannot enslave bond to itself.\n");
|
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1769,8 +1780,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
|
|||||||
if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) {
|
if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) {
|
||||||
slave_dbg(bond_dev, slave_dev, "is NETIF_F_VLAN_CHALLENGED\n");
|
slave_dbg(bond_dev, slave_dev, "is NETIF_F_VLAN_CHALLENGED\n");
|
||||||
if (vlan_uses_dev(bond_dev)) {
|
if (vlan_uses_dev(bond_dev)) {
|
||||||
NL_SET_ERR_MSG(extack, "Can not enslave VLAN challenged device to VLAN enabled bond");
|
SLAVE_NL_ERR(bond_dev, slave_dev, extack,
|
||||||
slave_err(bond_dev, slave_dev, "Error: cannot enslave VLAN challenged slave on VLAN enabled bond\n");
|
"Can not enslave VLAN challenged device to VLAN enabled bond");
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
} else {
|
} else {
|
||||||
slave_warn(bond_dev, slave_dev, "enslaved VLAN challenged slave. Adding VLANs will be blocked as long as it is part of bond.\n");
|
slave_warn(bond_dev, slave_dev, "enslaved VLAN challenged slave. Adding VLANs will be blocked as long as it is part of bond.\n");
|
||||||
@ -1788,8 +1799,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
|
|||||||
* enslaving it; the old ifenslave will not.
|
* enslaving it; the old ifenslave will not.
|
||||||
*/
|
*/
|
||||||
if (slave_dev->flags & IFF_UP) {
|
if (slave_dev->flags & IFF_UP) {
|
||||||
NL_SET_ERR_MSG(extack, "Device can not be enslaved while up");
|
SLAVE_NL_ERR(bond_dev, slave_dev, extack,
|
||||||
slave_err(bond_dev, slave_dev, "slave is up - this may be due to an out of date ifenslave\n");
|
"Device can not be enslaved while up");
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1828,17 +1839,15 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
|
|||||||
bond_dev);
|
bond_dev);
|
||||||
}
|
}
|
||||||
} else if (bond_dev->type != slave_dev->type) {
|
} else if (bond_dev->type != slave_dev->type) {
|
||||||
NL_SET_ERR_MSG(extack, "Device type is different from other slaves");
|
SLAVE_NL_ERR(bond_dev, slave_dev, extack,
|
||||||
slave_err(bond_dev, slave_dev, "ether type (%d) is different from other slaves (%d), can not enslave it\n",
|
"Device type is different from other slaves");
|
||||||
slave_dev->type, bond_dev->type);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slave_dev->type == ARPHRD_INFINIBAND &&
|
if (slave_dev->type == ARPHRD_INFINIBAND &&
|
||||||
BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
|
BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
|
||||||
NL_SET_ERR_MSG(extack, "Only active-backup mode is supported for infiniband slaves");
|
SLAVE_NL_ERR(bond_dev, slave_dev, extack,
|
||||||
slave_warn(bond_dev, slave_dev, "Type (%d) supports only active-backup mode\n",
|
"Only active-backup mode is supported for infiniband slaves");
|
||||||
slave_dev->type);
|
|
||||||
res = -EOPNOTSUPP;
|
res = -EOPNOTSUPP;
|
||||||
goto err_undo_flags;
|
goto err_undo_flags;
|
||||||
}
|
}
|
||||||
@ -1852,8 +1861,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
|
|||||||
bond->params.fail_over_mac = BOND_FOM_ACTIVE;
|
bond->params.fail_over_mac = BOND_FOM_ACTIVE;
|
||||||
slave_warn(bond_dev, slave_dev, "Setting fail_over_mac to active for active-backup mode\n");
|
slave_warn(bond_dev, slave_dev, "Setting fail_over_mac to active for active-backup mode\n");
|
||||||
} else {
|
} else {
|
||||||
NL_SET_ERR_MSG(extack, "Slave device does not support setting the MAC address, but fail_over_mac is not set to active");
|
SLAVE_NL_ERR(bond_dev, slave_dev, extack,
|
||||||
slave_err(bond_dev, slave_dev, "The slave device specified does not support setting the MAC address, but fail_over_mac is not set to active\n");
|
"Slave device does not support setting the MAC address, but fail_over_mac is not set to active");
|
||||||
res = -EOPNOTSUPP;
|
res = -EOPNOTSUPP;
|
||||||
goto err_undo_flags;
|
goto err_undo_flags;
|
||||||
}
|
}
|
||||||
@ -2149,8 +2158,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
|
|||||||
if (!slave_dev->netdev_ops->ndo_bpf ||
|
if (!slave_dev->netdev_ops->ndo_bpf ||
|
||||||
!slave_dev->netdev_ops->ndo_xdp_xmit) {
|
!slave_dev->netdev_ops->ndo_xdp_xmit) {
|
||||||
if (bond->xdp_prog) {
|
if (bond->xdp_prog) {
|
||||||
NL_SET_ERR_MSG(extack, "Slave does not support XDP");
|
SLAVE_NL_ERR(bond_dev, slave_dev, extack,
|
||||||
slave_err(bond_dev, slave_dev, "Slave does not support XDP\n");
|
"Slave does not support XDP");
|
||||||
res = -EOPNOTSUPP;
|
res = -EOPNOTSUPP;
|
||||||
goto err_sysfs_del;
|
goto err_sysfs_del;
|
||||||
}
|
}
|
||||||
@ -2163,10 +2172,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (dev_xdp_prog_count(slave_dev) > 0) {
|
if (dev_xdp_prog_count(slave_dev) > 0) {
|
||||||
NL_SET_ERR_MSG(extack,
|
SLAVE_NL_ERR(bond_dev, slave_dev, extack,
|
||||||
"Slave has XDP program loaded, please unload before enslaving");
|
"Slave has XDP program loaded, please unload before enslaving");
|
||||||
slave_err(bond_dev, slave_dev,
|
|
||||||
"Slave has XDP program loaded, please unload before enslaving\n");
|
|
||||||
res = -EOPNOTSUPP;
|
res = -EOPNOTSUPP;
|
||||||
goto err_sysfs_del;
|
goto err_sysfs_del;
|
||||||
}
|
}
|
||||||
@ -5190,17 +5197,15 @@ static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog,
|
|||||||
|
|
||||||
if (!slave_dev->netdev_ops->ndo_bpf ||
|
if (!slave_dev->netdev_ops->ndo_bpf ||
|
||||||
!slave_dev->netdev_ops->ndo_xdp_xmit) {
|
!slave_dev->netdev_ops->ndo_xdp_xmit) {
|
||||||
NL_SET_ERR_MSG(extack, "Slave device does not support XDP");
|
SLAVE_NL_ERR(dev, slave_dev, extack,
|
||||||
slave_err(dev, slave_dev, "Slave does not support XDP\n");
|
"Slave device does not support XDP");
|
||||||
err = -EOPNOTSUPP;
|
err = -EOPNOTSUPP;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev_xdp_prog_count(slave_dev) > 0) {
|
if (dev_xdp_prog_count(slave_dev) > 0) {
|
||||||
NL_SET_ERR_MSG(extack,
|
SLAVE_NL_ERR(dev, slave_dev, extack,
|
||||||
"Slave has XDP program loaded, please unload before enslaving");
|
"Slave has XDP program loaded, please unload before enslaving");
|
||||||
slave_err(dev, slave_dev,
|
|
||||||
"Slave has XDP program loaded, please unload before enslaving\n");
|
|
||||||
err = -EOPNOTSUPP;
|
err = -EOPNOTSUPP;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user