aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_main.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-11-15 14:56:19 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-15 14:56:19 -0500
commit5bbcc0f595fadb4cac0eddc4401035ec0bd95b09 (patch)
tree3b65e490cc36a6c6fecac1fa24d9e0ac9ced4455 /drivers/net/bonding/bond_main.c
parent892204e06cb9e89fbc4b299a678f9ca358e97cac (diff)
parent50895b9de1d3e0258e015e8e55128d835d9a9f19 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking updates from David Miller: "Highlights: 1) Maintain the TCP retransmit queue using an rbtree, with 1GB windows at 100Gb this really has become necessary. From Eric Dumazet. 2) Multi-program support for cgroup+bpf, from Alexei Starovoitov. 3) Perform broadcast flooding in hardware in mv88e6xxx, from Andrew Lunn. 4) Add meter action support to openvswitch, from Andy Zhou. 5) Add a data meta pointer for BPF accessible packets, from Daniel Borkmann. 6) Namespace-ify almost all TCP sysctl knobs, from Eric Dumazet. 7) Turn on Broadcom Tags in b53 driver, from Florian Fainelli. 8) More work to move the RTNL mutex down, from Florian Westphal. 9) Add 'bpftool' utility, to help with bpf program introspection. From Jakub Kicinski. 10) Add new 'cpumap' type for XDP_REDIRECT action, from Jesper Dangaard Brouer. 11) Support 'blocks' of transformations in the packet scheduler which can span multiple network devices, from Jiri Pirko. 12) TC flower offload support in cxgb4, from Kumar Sanghvi. 13) Priority based stream scheduler for SCTP, from Marcelo Ricardo Leitner. 14) Thunderbolt networking driver, from Amir Levy and Mika Westerberg. 15) Add RED qdisc offloadability, and use it in mlxsw driver. From Nogah Frankel. 16) eBPF based device controller for cgroup v2, from Roman Gushchin. 17) Add some fundamental tracepoints for TCP, from Song Liu. 18) Remove garbage collection from ipv6 route layer, this is a significant accomplishment. From Wei Wang. 19) Add multicast route offload support to mlxsw, from Yotam Gigi" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (2177 commits) tcp: highest_sack fix geneve: fix fill_info when link down bpf: fix lockdep splat net: cdc_ncm: GetNtbFormat endian fix openvswitch: meter: fix NULL pointer dereference in ovs_meter_cmd_reply_start netem: remove unnecessary 64 bit modulus netem: use 64 bit divide by rate tcp: Namespace-ify sysctl_tcp_default_congestion_control net: Protect iterations over net::fib_notifier_ops in fib_seq_sum() ipv6: set all.accept_dad to 0 by default uapi: fix linux/tls.h userspace compilation error usbnet: ipheth: prevent TX queue timeouts when device not ready vhost_net: conditionally enable tx polling uapi: fix linux/rxrpc.h userspace compilation errors net: stmmac: fix LPI transitioning for dwmac4 atm: horizon: Fix irq release error net-sysfs: trigger netlink notification on ifalias change via sysfs openvswitch: Using kfree_rcu() to simplify the code openvswitch: Make local function ovs_nsh_key_attr_size() static openvswitch: Fix return value check in ovs_meter_cmd_features() ...
Diffstat (limited to 'drivers/net/bonding/bond_main.c')
-rw-r--r--drivers/net/bonding/bond_main.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 08a4f57cf409..c669554d70bb 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1217,25 +1217,21 @@ static enum netdev_lag_tx_type bond_lag_tx_type(struct bonding *bond)
1217 } 1217 }
1218} 1218}
1219 1219
1220static int bond_master_upper_dev_link(struct bonding *bond, struct slave *slave) 1220static int bond_master_upper_dev_link(struct bonding *bond, struct slave *slave,
1221 struct netlink_ext_ack *extack)
1221{ 1222{
1222 struct netdev_lag_upper_info lag_upper_info; 1223 struct netdev_lag_upper_info lag_upper_info;
1223 int err;
1224 1224
1225 lag_upper_info.tx_type = bond_lag_tx_type(bond); 1225 lag_upper_info.tx_type = bond_lag_tx_type(bond);
1226 err = netdev_master_upper_dev_link(slave->dev, bond->dev, slave, 1226
1227 &lag_upper_info); 1227 return netdev_master_upper_dev_link(slave->dev, bond->dev, slave,
1228 if (err) 1228 &lag_upper_info, extack);
1229 return err;
1230 rtmsg_ifinfo(RTM_NEWLINK, slave->dev, IFF_SLAVE, GFP_KERNEL);
1231 return 0;
1232} 1229}
1233 1230
1234static void bond_upper_dev_unlink(struct bonding *bond, struct slave *slave) 1231static void bond_upper_dev_unlink(struct bonding *bond, struct slave *slave)
1235{ 1232{
1236 netdev_upper_dev_unlink(slave->dev, bond->dev); 1233 netdev_upper_dev_unlink(slave->dev, bond->dev);
1237 slave->dev->flags &= ~IFF_SLAVE; 1234 slave->dev->flags &= ~IFF_SLAVE;
1238 rtmsg_ifinfo(RTM_NEWLINK, slave->dev, IFF_SLAVE, GFP_KERNEL);
1239} 1235}
1240 1236
1241static struct slave *bond_alloc_slave(struct bonding *bond) 1237static struct slave *bond_alloc_slave(struct bonding *bond)
@@ -1328,7 +1324,8 @@ void bond_lower_state_changed(struct slave *slave)
1328} 1324}
1329 1325
1330/* enslave device <slave> to bond device <master> */ 1326/* enslave device <slave> to bond device <master> */
1331int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) 1327int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
1328 struct netlink_ext_ack *extack)
1332{ 1329{
1333 struct bonding *bond = netdev_priv(bond_dev); 1330 struct bonding *bond = netdev_priv(bond_dev);
1334 const struct net_device_ops *slave_ops = slave_dev->netdev_ops; 1331 const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
@@ -1346,12 +1343,14 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1346 1343
1347 /* already in-use? */ 1344 /* already in-use? */
1348 if (netdev_is_rx_handler_busy(slave_dev)) { 1345 if (netdev_is_rx_handler_busy(slave_dev)) {
1346 NL_SET_ERR_MSG(extack, "Device is in use and cannot be enslaved");
1349 netdev_err(bond_dev, 1347 netdev_err(bond_dev,
1350 "Error: Device is in use and cannot be enslaved\n"); 1348 "Error: Device is in use and cannot be enslaved\n");
1351 return -EBUSY; 1349 return -EBUSY;
1352 } 1350 }
1353 1351
1354 if (bond_dev == slave_dev) { 1352 if (bond_dev == slave_dev) {
1353 NL_SET_ERR_MSG(extack, "Cannot enslave bond to itself.");
1355 netdev_err(bond_dev, "cannot enslave bond to itself.\n"); 1354 netdev_err(bond_dev, "cannot enslave bond to itself.\n");
1356 return -EPERM; 1355 return -EPERM;
1357 } 1356 }
@@ -1362,6 +1361,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1362 netdev_dbg(bond_dev, "%s is NETIF_F_VLAN_CHALLENGED\n", 1361 netdev_dbg(bond_dev, "%s is NETIF_F_VLAN_CHALLENGED\n",
1363 slave_dev->name); 1362 slave_dev->name);
1364 if (vlan_uses_dev(bond_dev)) { 1363 if (vlan_uses_dev(bond_dev)) {
1364 NL_SET_ERR_MSG(extack, "Can not enslave VLAN challenged device to VLAN enabled bond");
1365 netdev_err(bond_dev, "Error: cannot enslave VLAN challenged slave %s on VLAN enabled bond %s\n", 1365 netdev_err(bond_dev, "Error: cannot enslave VLAN challenged slave %s on VLAN enabled bond %s\n",
1366 slave_dev->name, bond_dev->name); 1366 slave_dev->name, bond_dev->name);
1367 return -EPERM; 1367 return -EPERM;
@@ -1381,6 +1381,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1381 * enslaving it; the old ifenslave will not. 1381 * enslaving it; the old ifenslave will not.
1382 */ 1382 */
1383 if (slave_dev->flags & IFF_UP) { 1383 if (slave_dev->flags & IFF_UP) {
1384 NL_SET_ERR_MSG(extack, "Device can not be enslaved while up");
1384 netdev_err(bond_dev, "%s is up - this may be due to an out of date ifenslave\n", 1385 netdev_err(bond_dev, "%s is up - this may be due to an out of date ifenslave\n",
1385 slave_dev->name); 1386 slave_dev->name);
1386 return -EPERM; 1387 return -EPERM;
@@ -1421,6 +1422,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1421 bond_dev); 1422 bond_dev);
1422 } 1423 }
1423 } else if (bond_dev->type != slave_dev->type) { 1424 } else if (bond_dev->type != slave_dev->type) {
1425 NL_SET_ERR_MSG(extack, "Device type is different from other slaves");
1424 netdev_err(bond_dev, "%s ether type (%d) is different from other slaves (%d), can not enslave it\n", 1426 netdev_err(bond_dev, "%s ether type (%d) is different from other slaves (%d), can not enslave it\n",
1425 slave_dev->name, slave_dev->type, bond_dev->type); 1427 slave_dev->name, slave_dev->type, bond_dev->type);
1426 return -EINVAL; 1428 return -EINVAL;
@@ -1428,6 +1430,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1428 1430
1429 if (slave_dev->type == ARPHRD_INFINIBAND && 1431 if (slave_dev->type == ARPHRD_INFINIBAND &&
1430 BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { 1432 BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
1433 NL_SET_ERR_MSG(extack, "Only active-backup mode is supported for infiniband slaves");
1431 netdev_warn(bond_dev, "Type (%d) supports only active-backup mode\n", 1434 netdev_warn(bond_dev, "Type (%d) supports only active-backup mode\n",
1432 slave_dev->type); 1435 slave_dev->type);
1433 res = -EOPNOTSUPP; 1436 res = -EOPNOTSUPP;
@@ -1443,6 +1446,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1443 bond->params.fail_over_mac = BOND_FOM_ACTIVE; 1446 bond->params.fail_over_mac = BOND_FOM_ACTIVE;
1444 netdev_warn(bond_dev, "Setting fail_over_mac to active for active-backup mode\n"); 1447 netdev_warn(bond_dev, "Setting fail_over_mac to active for active-backup mode\n");
1445 } else { 1448 } else {
1449 NL_SET_ERR_MSG(extack, "Slave device does not support setting the MAC address, but fail_over_mac is not set to active");
1446 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"); 1450 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");
1447 res = -EOPNOTSUPP; 1451 res = -EOPNOTSUPP;
1448 goto err_undo_flags; 1452 goto err_undo_flags;
@@ -1709,7 +1713,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1709 goto err_detach; 1713 goto err_detach;
1710 } 1714 }
1711 1715
1712 res = bond_master_upper_dev_link(bond, new_slave); 1716 res = bond_master_upper_dev_link(bond, new_slave, extack);
1713 if (res) { 1717 if (res) {
1714 netdev_dbg(bond_dev, "Error %d calling bond_master_upper_dev_link\n", res); 1718 netdev_dbg(bond_dev, "Error %d calling bond_master_upper_dev_link\n", res);
1715 goto err_unregister; 1719 goto err_unregister;
@@ -2492,7 +2496,8 @@ int bond_arp_rcv(const struct sk_buff *skb, struct bonding *bond,
2492 struct slave *curr_active_slave, *curr_arp_slave; 2496 struct slave *curr_active_slave, *curr_arp_slave;
2493 unsigned char *arp_ptr; 2497 unsigned char *arp_ptr;
2494 __be32 sip, tip; 2498 __be32 sip, tip;
2495 int alen, is_arp = skb->protocol == __cpu_to_be16(ETH_P_ARP); 2499 int is_arp = skb->protocol == __cpu_to_be16(ETH_P_ARP);
2500 unsigned int alen;
2496 2501
2497 if (!slave_do_arp_validate(bond, slave)) { 2502 if (!slave_do_arp_validate(bond, slave)) {
2498 if ((slave_do_arp_validate_only(bond) && is_arp) || 2503 if ((slave_do_arp_validate_only(bond) && is_arp) ||
@@ -3073,7 +3078,16 @@ static int bond_slave_netdev_event(unsigned long event,
3073 break; 3078 break;
3074 case NETDEV_UP: 3079 case NETDEV_UP:
3075 case NETDEV_CHANGE: 3080 case NETDEV_CHANGE:
3076 bond_update_speed_duplex(slave); 3081 /* For 802.3ad mode only:
3082 * Getting invalid Speed/Duplex values here will put slave
3083 * in weird state. So mark it as link-down for the time
3084 * being and let link-monitoring (miimon) set it right when
3085 * correct speeds/duplex are available.
3086 */
3087 if (bond_update_speed_duplex(slave) &&
3088 BOND_MODE(bond) == BOND_MODE_8023AD)
3089 slave->link = BOND_LINK_DOWN;
3090
3077 if (BOND_MODE(bond) == BOND_MODE_8023AD) 3091 if (BOND_MODE(bond) == BOND_MODE_8023AD)
3078 bond_3ad_adapter_speed_duplex_changed(slave); 3092 bond_3ad_adapter_speed_duplex_changed(slave);
3079 /* Fallthrough */ 3093 /* Fallthrough */
@@ -3483,7 +3497,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
3483 switch (cmd) { 3497 switch (cmd) {
3484 case BOND_ENSLAVE_OLD: 3498 case BOND_ENSLAVE_OLD:
3485 case SIOCBONDENSLAVE: 3499 case SIOCBONDENSLAVE:
3486 res = bond_enslave(bond_dev, slave_dev); 3500 res = bond_enslave(bond_dev, slave_dev, NULL);
3487 break; 3501 break;
3488 case BOND_RELEASE_OLD: 3502 case BOND_RELEASE_OLD:
3489 case SIOCBONDRELEASE: 3503 case SIOCBONDRELEASE: