aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/bonding/bond_sysfs.c')
-rw-r--r--drivers/net/bonding/bond_sysfs.c165
1 files changed, 73 insertions, 92 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index c311aed9bd02..88fcb25e554a 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -118,7 +118,10 @@ static ssize_t bonding_store_bonds(struct class *cls,
118 pr_info("%s is being created...\n", ifname); 118 pr_info("%s is being created...\n", ifname);
119 rv = bond_create(net, ifname); 119 rv = bond_create(net, ifname);
120 if (rv) { 120 if (rv) {
121 pr_info("Bond creation failed.\n"); 121 if (rv == -EEXIST)
122 pr_info("%s already exists.\n", ifname);
123 else
124 pr_info("%s creation failed.\n", ifname);
122 res = rv; 125 res = rv;
123 } 126 }
124 } else if (command[0] == '-') { 127 } else if (command[0] == '-') {
@@ -224,12 +227,6 @@ static ssize_t bonding_store_slaves(struct device *d,
224 struct net_device *dev; 227 struct net_device *dev;
225 struct bonding *bond = to_bond(d); 228 struct bonding *bond = to_bond(d);
226 229
227 /* Quick sanity check -- is the bond interface up? */
228 if (!(bond->dev->flags & IFF_UP)) {
229 pr_warning("%s: doing slave updates when interface is down.\n",
230 bond->dev->name);
231 }
232
233 if (!rtnl_trylock()) 230 if (!rtnl_trylock())
234 return restart_syscall(); 231 return restart_syscall();
235 232
@@ -322,11 +319,6 @@ static ssize_t bonding_store_mode(struct device *d,
322 ret = -EINVAL; 319 ret = -EINVAL;
323 goto out; 320 goto out;
324 } 321 }
325 if (bond->params.mode == BOND_MODE_8023AD)
326 bond_unset_master_3ad_flags(bond);
327
328 if (bond->params.mode == BOND_MODE_ALB)
329 bond_unset_master_alb_flags(bond);
330 322
331 bond->params.mode = new_value; 323 bond->params.mode = new_value;
332 bond_set_mode_ops(bond, bond->params.mode); 324 bond_set_mode_ops(bond, bond->params.mode);
@@ -424,11 +416,6 @@ static ssize_t bonding_store_arp_validate(struct device *d,
424 bond->dev->name, arp_validate_tbl[new_value].modename, 416 bond->dev->name, arp_validate_tbl[new_value].modename,
425 new_value); 417 new_value);
426 418
427 if (!bond->params.arp_validate && new_value)
428 bond_register_arp(bond);
429 else if (bond->params.arp_validate && !new_value)
430 bond_unregister_arp(bond);
431
432 bond->params.arp_validate = new_value; 419 bond->params.arp_validate = new_value;
433 420
434 return count; 421 return count;
@@ -527,8 +514,6 @@ static ssize_t bonding_store_arp_interval(struct device *d,
527 pr_info("%s: Setting ARP monitoring interval to %d.\n", 514 pr_info("%s: Setting ARP monitoring interval to %d.\n",
528 bond->dev->name, new_value); 515 bond->dev->name, new_value);
529 bond->params.arp_interval = new_value; 516 bond->params.arp_interval = new_value;
530 if (bond->params.arp_interval)
531 bond->dev->priv_flags |= IFF_MASTER_ARPMON;
532 if (bond->params.miimon) { 517 if (bond->params.miimon) {
533 pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n", 518 pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n",
534 bond->dev->name, bond->dev->name); 519 bond->dev->name, bond->dev->name);
@@ -878,82 +863,28 @@ static DEVICE_ATTR(ad_select, S_IRUGO | S_IWUSR,
878 bonding_show_ad_select, bonding_store_ad_select); 863 bonding_show_ad_select, bonding_store_ad_select);
879 864
880/* 865/*
881 * Show and set the number of grat ARP to send after a failover event. 866 * Show and set the number of peer notifications to send after a failover event.
882 */ 867 */
883static ssize_t bonding_show_n_grat_arp(struct device *d, 868static ssize_t bonding_show_num_peer_notif(struct device *d,
884 struct device_attribute *attr, 869 struct device_attribute *attr,
885 char *buf) 870 char *buf)
886{ 871{
887 struct bonding *bond = to_bond(d); 872 struct bonding *bond = to_bond(d);
888 873 return sprintf(buf, "%d\n", bond->params.num_peer_notif);
889 return sprintf(buf, "%d\n", bond->params.num_grat_arp);
890} 874}
891 875
892static ssize_t bonding_store_n_grat_arp(struct device *d, 876static ssize_t bonding_store_num_peer_notif(struct device *d,
893 struct device_attribute *attr, 877 struct device_attribute *attr,
894 const char *buf, size_t count) 878 const char *buf, size_t count)
895{ 879{
896 int new_value, ret = count;
897 struct bonding *bond = to_bond(d); 880 struct bonding *bond = to_bond(d);
898 881 int err = kstrtou8(buf, 10, &bond->params.num_peer_notif);
899 if (sscanf(buf, "%d", &new_value) != 1) { 882 return err ? err : count;
900 pr_err("%s: no num_grat_arp value specified.\n",
901 bond->dev->name);
902 ret = -EINVAL;
903 goto out;
904 }
905 if (new_value < 0 || new_value > 255) {
906 pr_err("%s: Invalid num_grat_arp value %d not in range 0-255; rejected.\n",
907 bond->dev->name, new_value);
908 ret = -EINVAL;
909 goto out;
910 } else {
911 bond->params.num_grat_arp = new_value;
912 }
913out:
914 return ret;
915} 883}
916static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR, 884static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR,
917 bonding_show_n_grat_arp, bonding_store_n_grat_arp); 885 bonding_show_num_peer_notif, bonding_store_num_peer_notif);
918
919/*
920 * Show and set the number of unsolicited NA's to send after a failover event.
921 */
922static ssize_t bonding_show_n_unsol_na(struct device *d,
923 struct device_attribute *attr,
924 char *buf)
925{
926 struct bonding *bond = to_bond(d);
927
928 return sprintf(buf, "%d\n", bond->params.num_unsol_na);
929}
930
931static ssize_t bonding_store_n_unsol_na(struct device *d,
932 struct device_attribute *attr,
933 const char *buf, size_t count)
934{
935 int new_value, ret = count;
936 struct bonding *bond = to_bond(d);
937
938 if (sscanf(buf, "%d", &new_value) != 1) {
939 pr_err("%s: no num_unsol_na value specified.\n",
940 bond->dev->name);
941 ret = -EINVAL;
942 goto out;
943 }
944
945 if (new_value < 0 || new_value > 255) {
946 pr_err("%s: Invalid num_unsol_na value %d not in range 0-255; rejected.\n",
947 bond->dev->name, new_value);
948 ret = -EINVAL;
949 goto out;
950 } else
951 bond->params.num_unsol_na = new_value;
952out:
953 return ret;
954}
955static DEVICE_ATTR(num_unsol_na, S_IRUGO | S_IWUSR, 886static DEVICE_ATTR(num_unsol_na, S_IRUGO | S_IWUSR,
956 bonding_show_n_unsol_na, bonding_store_n_unsol_na); 887 bonding_show_num_peer_notif, bonding_store_num_peer_notif);
957 888
958/* 889/*
959 * Show and set the MII monitor interval. There are two tricky bits 890 * Show and set the MII monitor interval. There are two tricky bits
@@ -1004,9 +935,7 @@ static ssize_t bonding_store_miimon(struct device *d,
1004 pr_info("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n", 935 pr_info("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n",
1005 bond->dev->name); 936 bond->dev->name);
1006 bond->params.arp_interval = 0; 937 bond->params.arp_interval = 0;
1007 bond->dev->priv_flags &= ~IFF_MASTER_ARPMON;
1008 if (bond->params.arp_validate) { 938 if (bond->params.arp_validate) {
1009 bond_unregister_arp(bond);
1010 bond->params.arp_validate = 939 bond->params.arp_validate =
1011 BOND_ARP_VALIDATE_NONE; 940 BOND_ARP_VALIDATE_NONE;
1012 } 941 }
@@ -1066,6 +995,7 @@ static ssize_t bonding_store_primary(struct device *d,
1066 995
1067 if (!rtnl_trylock()) 996 if (!rtnl_trylock())
1068 return restart_syscall(); 997 return restart_syscall();
998 block_netpoll_tx();
1069 read_lock(&bond->lock); 999 read_lock(&bond->lock);
1070 write_lock_bh(&bond->curr_slave_lock); 1000 write_lock_bh(&bond->curr_slave_lock);
1071 1001
@@ -1101,6 +1031,7 @@ static ssize_t bonding_store_primary(struct device *d,
1101out: 1031out:
1102 write_unlock_bh(&bond->curr_slave_lock); 1032 write_unlock_bh(&bond->curr_slave_lock);
1103 read_unlock(&bond->lock); 1033 read_unlock(&bond->lock);
1034 unblock_netpoll_tx();
1104 rtnl_unlock(); 1035 rtnl_unlock();
1105 1036
1106 return count; 1037 return count;
@@ -1146,11 +1077,13 @@ static ssize_t bonding_store_primary_reselect(struct device *d,
1146 bond->dev->name, pri_reselect_tbl[new_value].modename, 1077 bond->dev->name, pri_reselect_tbl[new_value].modename,
1147 new_value); 1078 new_value);
1148 1079
1080 block_netpoll_tx();
1149 read_lock(&bond->lock); 1081 read_lock(&bond->lock);
1150 write_lock_bh(&bond->curr_slave_lock); 1082 write_lock_bh(&bond->curr_slave_lock);
1151 bond_select_active_slave(bond); 1083 bond_select_active_slave(bond);
1152 write_unlock_bh(&bond->curr_slave_lock); 1084 write_unlock_bh(&bond->curr_slave_lock);
1153 read_unlock(&bond->lock); 1085 read_unlock(&bond->lock);
1086 unblock_netpoll_tx();
1154out: 1087out:
1155 rtnl_unlock(); 1088 rtnl_unlock();
1156 return ret; 1089 return ret;
@@ -1194,7 +1127,7 @@ static ssize_t bonding_store_carrier(struct device *d,
1194 bond->dev->name, new_value); 1127 bond->dev->name, new_value);
1195 } 1128 }
1196out: 1129out:
1197 return count; 1130 return ret;
1198} 1131}
1199static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, 1132static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR,
1200 bonding_show_carrier, bonding_store_carrier); 1133 bonding_show_carrier, bonding_store_carrier);
@@ -1232,6 +1165,8 @@ static ssize_t bonding_store_active_slave(struct device *d,
1232 1165
1233 if (!rtnl_trylock()) 1166 if (!rtnl_trylock())
1234 return restart_syscall(); 1167 return restart_syscall();
1168
1169 block_netpoll_tx();
1235 read_lock(&bond->lock); 1170 read_lock(&bond->lock);
1236 write_lock_bh(&bond->curr_slave_lock); 1171 write_lock_bh(&bond->curr_slave_lock);
1237 1172
@@ -1288,6 +1223,8 @@ static ssize_t bonding_store_active_slave(struct device *d,
1288 out: 1223 out:
1289 write_unlock_bh(&bond->curr_slave_lock); 1224 write_unlock_bh(&bond->curr_slave_lock);
1290 read_unlock(&bond->lock); 1225 read_unlock(&bond->lock);
1226 unblock_netpoll_tx();
1227
1291 rtnl_unlock(); 1228 rtnl_unlock();
1292 1229
1293 return count; 1230 return count;
@@ -1579,19 +1516,62 @@ static ssize_t bonding_store_slaves_active(struct device *d,
1579 } 1516 }
1580 1517
1581 bond_for_each_slave(bond, slave, i) { 1518 bond_for_each_slave(bond, slave, i) {
1582 if (slave->state == BOND_STATE_BACKUP) { 1519 if (!bond_is_active_slave(slave)) {
1583 if (new_value) 1520 if (new_value)
1584 slave->dev->priv_flags &= ~IFF_SLAVE_INACTIVE; 1521 slave->inactive = 0;
1585 else 1522 else
1586 slave->dev->priv_flags |= IFF_SLAVE_INACTIVE; 1523 slave->inactive = 1;
1587 } 1524 }
1588 } 1525 }
1589out: 1526out:
1590 return count; 1527 return ret;
1591} 1528}
1592static DEVICE_ATTR(all_slaves_active, S_IRUGO | S_IWUSR, 1529static DEVICE_ATTR(all_slaves_active, S_IRUGO | S_IWUSR,
1593 bonding_show_slaves_active, bonding_store_slaves_active); 1530 bonding_show_slaves_active, bonding_store_slaves_active);
1594 1531
1532/*
1533 * Show and set the number of IGMP membership reports to send on link failure
1534 */
1535static ssize_t bonding_show_resend_igmp(struct device *d,
1536 struct device_attribute *attr,
1537 char *buf)
1538{
1539 struct bonding *bond = to_bond(d);
1540
1541 return sprintf(buf, "%d\n", bond->params.resend_igmp);
1542}
1543
1544static ssize_t bonding_store_resend_igmp(struct device *d,
1545 struct device_attribute *attr,
1546 const char *buf, size_t count)
1547{
1548 int new_value, ret = count;
1549 struct bonding *bond = to_bond(d);
1550
1551 if (sscanf(buf, "%d", &new_value) != 1) {
1552 pr_err("%s: no resend_igmp value specified.\n",
1553 bond->dev->name);
1554 ret = -EINVAL;
1555 goto out;
1556 }
1557
1558 if (new_value < 0 || new_value > 255) {
1559 pr_err("%s: Invalid resend_igmp value %d not in range 0-255; rejected.\n",
1560 bond->dev->name, new_value);
1561 ret = -EINVAL;
1562 goto out;
1563 }
1564
1565 pr_info("%s: Setting resend_igmp to %d.\n",
1566 bond->dev->name, new_value);
1567 bond->params.resend_igmp = new_value;
1568out:
1569 return ret;
1570}
1571
1572static DEVICE_ATTR(resend_igmp, S_IRUGO | S_IWUSR,
1573 bonding_show_resend_igmp, bonding_store_resend_igmp);
1574
1595static struct attribute *per_bond_attrs[] = { 1575static struct attribute *per_bond_attrs[] = {
1596 &dev_attr_slaves.attr, 1576 &dev_attr_slaves.attr,
1597 &dev_attr_mode.attr, 1577 &dev_attr_mode.attr,
@@ -1619,6 +1599,7 @@ static struct attribute *per_bond_attrs[] = {
1619 &dev_attr_ad_partner_mac.attr, 1599 &dev_attr_ad_partner_mac.attr,
1620 &dev_attr_queue_id.attr, 1600 &dev_attr_queue_id.attr,
1621 &dev_attr_all_slaves_active.attr, 1601 &dev_attr_all_slaves_active.attr,
1602 &dev_attr_resend_igmp.attr,
1622 NULL, 1603 NULL,
1623}; 1604};
1624 1605