@@ -1217,14 +1217,15 @@ static enum netdev_lag_tx_type bond_lag_tx_type(struct bonding *bond)
12171217 }
12181218}
12191219
1220- static int bond_master_upper_dev_link (struct bonding * bond , struct slave * slave )
1220+ static int bond_master_upper_dev_link (struct bonding * bond , struct slave * slave ,
1221+ struct netlink_ext_ack * extack )
12211222{
12221223 struct netdev_lag_upper_info lag_upper_info ;
12231224 int err ;
12241225
12251226 lag_upper_info .tx_type = bond_lag_tx_type (bond );
12261227 err = netdev_master_upper_dev_link (slave -> dev , bond -> dev , slave ,
1227- & lag_upper_info );
1228+ & lag_upper_info , extack );
12281229 if (err )
12291230 return err ;
12301231 rtmsg_ifinfo (RTM_NEWLINK , slave -> dev , IFF_SLAVE , GFP_KERNEL );
@@ -1328,7 +1329,8 @@ void bond_lower_state_changed(struct slave *slave)
13281329}
13291330
13301331/* enslave device <slave> to bond device <master> */
1331- int bond_enslave (struct net_device * bond_dev , struct net_device * slave_dev )
1332+ int bond_enslave (struct net_device * bond_dev , struct net_device * slave_dev ,
1333+ struct netlink_ext_ack * extack )
13321334{
13331335 struct bonding * bond = netdev_priv (bond_dev );
13341336 const struct net_device_ops * slave_ops = slave_dev -> netdev_ops ;
@@ -1346,12 +1348,14 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
13461348
13471349 /* already in-use? */
13481350 if (netdev_is_rx_handler_busy (slave_dev )) {
1351+ NL_SET_ERR_MSG (extack , "Device is in use and cannot be enslaved" );
13491352 netdev_err (bond_dev ,
13501353 "Error: Device is in use and cannot be enslaved\n" );
13511354 return - EBUSY ;
13521355 }
13531356
13541357 if (bond_dev == slave_dev ) {
1358+ NL_SET_ERR_MSG (extack , "Cannot enslave bond to itself." );
13551359 netdev_err (bond_dev , "cannot enslave bond to itself.\n" );
13561360 return - EPERM ;
13571361 }
@@ -1362,6 +1366,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
13621366 netdev_dbg (bond_dev , "%s is NETIF_F_VLAN_CHALLENGED\n" ,
13631367 slave_dev -> name );
13641368 if (vlan_uses_dev (bond_dev )) {
1369+ NL_SET_ERR_MSG (extack , "Can not enslave VLAN challenged device to VLAN enabled bond" );
13651370 netdev_err (bond_dev , "Error: cannot enslave VLAN challenged slave %s on VLAN enabled bond %s\n" ,
13661371 slave_dev -> name , bond_dev -> name );
13671372 return - EPERM ;
@@ -1381,6 +1386,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
13811386 * enslaving it; the old ifenslave will not.
13821387 */
13831388 if (slave_dev -> flags & IFF_UP ) {
1389+ NL_SET_ERR_MSG (extack , "Device can not be enslaved while up" );
13841390 netdev_err (bond_dev , "%s is up - this may be due to an out of date ifenslave\n" ,
13851391 slave_dev -> name );
13861392 return - EPERM ;
@@ -1421,13 +1427,15 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
14211427 bond_dev );
14221428 }
14231429 } else if (bond_dev -> type != slave_dev -> type ) {
1430+ NL_SET_ERR_MSG (extack , "Device type is different from other slaves" );
14241431 netdev_err (bond_dev , "%s ether type (%d) is different from other slaves (%d), can not enslave it\n" ,
14251432 slave_dev -> name , slave_dev -> type , bond_dev -> type );
14261433 return - EINVAL ;
14271434 }
14281435
14291436 if (slave_dev -> type == ARPHRD_INFINIBAND &&
14301437 BOND_MODE (bond ) != BOND_MODE_ACTIVEBACKUP ) {
1438+ NL_SET_ERR_MSG (extack , "Only active-backup mode is supported for infiniband slaves" );
14311439 netdev_warn (bond_dev , "Type (%d) supports only active-backup mode\n" ,
14321440 slave_dev -> type );
14331441 res = - EOPNOTSUPP ;
@@ -1443,6 +1451,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
14431451 bond -> params .fail_over_mac = BOND_FOM_ACTIVE ;
14441452 netdev_warn (bond_dev , "Setting fail_over_mac to active for active-backup mode\n" );
14451453 } else {
1454+ NL_SET_ERR_MSG (extack , "Slave device does not support setting the MAC address, but fail_over_mac is not set to active" );
14461455 netdev_err (bond_dev , "The slave device specified does not support setting the MAC address, but fail_over_mac is not set to active\n" );
14471456 res = - EOPNOTSUPP ;
14481457 goto err_undo_flags ;
@@ -1709,7 +1718,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
17091718 goto err_detach ;
17101719 }
17111720
1712- res = bond_master_upper_dev_link (bond , new_slave );
1721+ res = bond_master_upper_dev_link (bond , new_slave , extack );
17131722 if (res ) {
17141723 netdev_dbg (bond_dev , "Error %d calling bond_master_upper_dev_link\n" , res );
17151724 goto err_unregister ;
@@ -3492,7 +3501,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
34923501 switch (cmd ) {
34933502 case BOND_ENSLAVE_OLD :
34943503 case SIOCBONDENSLAVE :
3495- res = bond_enslave (bond_dev , slave_dev );
3504+ res = bond_enslave (bond_dev , slave_dev , NULL );
34963505 break ;
34973506 case BOND_RELEASE_OLD :
34983507 case SIOCBONDRELEASE :
0 commit comments