diff options
Diffstat (limited to 'drivers/net/bonding/bond_sysfs.c')
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 81 |
1 files changed, 58 insertions, 23 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 08f3d396bcd6..dd265c69b0df 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -50,6 +50,7 @@ extern struct bond_parm_tbl bond_mode_tbl[]; | |||
50 | extern struct bond_parm_tbl bond_lacp_tbl[]; | 50 | extern struct bond_parm_tbl bond_lacp_tbl[]; |
51 | extern struct bond_parm_tbl xmit_hashtype_tbl[]; | 51 | extern struct bond_parm_tbl xmit_hashtype_tbl[]; |
52 | extern struct bond_parm_tbl arp_validate_tbl[]; | 52 | extern struct bond_parm_tbl arp_validate_tbl[]; |
53 | extern struct bond_parm_tbl fail_over_mac_tbl[]; | ||
53 | 54 | ||
54 | static int expected_refcount = -1; | 55 | static int expected_refcount = -1; |
55 | static struct class *netdev_class; | 56 | static struct class *netdev_class; |
@@ -111,7 +112,6 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t | |||
111 | char *ifname; | 112 | char *ifname; |
112 | int rv, res = count; | 113 | int rv, res = count; |
113 | struct bonding *bond; | 114 | struct bonding *bond; |
114 | struct bonding *nxt; | ||
115 | 115 | ||
116 | sscanf(buffer, "%16s", command); /* IFNAMSIZ*/ | 116 | sscanf(buffer, "%16s", command); /* IFNAMSIZ*/ |
117 | ifname = command + 1; | 117 | ifname = command + 1; |
@@ -122,7 +122,7 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t | |||
122 | if (command[0] == '+') { | 122 | if (command[0] == '+') { |
123 | printk(KERN_INFO DRV_NAME | 123 | printk(KERN_INFO DRV_NAME |
124 | ": %s is being created...\n", ifname); | 124 | ": %s is being created...\n", ifname); |
125 | rv = bond_create(ifname, &bonding_defaults, &bond); | 125 | rv = bond_create(ifname, &bonding_defaults); |
126 | if (rv) { | 126 | if (rv) { |
127 | printk(KERN_INFO DRV_NAME ": Bond creation failed.\n"); | 127 | printk(KERN_INFO DRV_NAME ": Bond creation failed.\n"); |
128 | res = rv; | 128 | res = rv; |
@@ -134,7 +134,7 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t | |||
134 | rtnl_lock(); | 134 | rtnl_lock(); |
135 | down_write(&bonding_rwsem); | 135 | down_write(&bonding_rwsem); |
136 | 136 | ||
137 | list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) | 137 | list_for_each_entry(bond, &bond_dev_list, bond_list) |
138 | if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) { | 138 | if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) { |
139 | /* check the ref count on the bond's kobject. | 139 | /* check the ref count on the bond's kobject. |
140 | * If it's > expected, then there's a file open, | 140 | * If it's > expected, then there's a file open, |
@@ -548,42 +548,37 @@ static ssize_t bonding_show_fail_over_mac(struct device *d, struct device_attrib | |||
548 | { | 548 | { |
549 | struct bonding *bond = to_bond(d); | 549 | struct bonding *bond = to_bond(d); |
550 | 550 | ||
551 | return sprintf(buf, "%d\n", bond->params.fail_over_mac) + 1; | 551 | return sprintf(buf, "%s %d\n", |
552 | fail_over_mac_tbl[bond->params.fail_over_mac].modename, | ||
553 | bond->params.fail_over_mac); | ||
552 | } | 554 | } |
553 | 555 | ||
554 | static ssize_t bonding_store_fail_over_mac(struct device *d, struct device_attribute *attr, const char *buf, size_t count) | 556 | static ssize_t bonding_store_fail_over_mac(struct device *d, struct device_attribute *attr, const char *buf, size_t count) |
555 | { | 557 | { |
556 | int new_value; | 558 | int new_value; |
557 | int ret = count; | ||
558 | struct bonding *bond = to_bond(d); | 559 | struct bonding *bond = to_bond(d); |
559 | 560 | ||
560 | if (bond->slave_cnt != 0) { | 561 | if (bond->slave_cnt != 0) { |
561 | printk(KERN_ERR DRV_NAME | 562 | printk(KERN_ERR DRV_NAME |
562 | ": %s: Can't alter fail_over_mac with slaves in bond.\n", | 563 | ": %s: Can't alter fail_over_mac with slaves in bond.\n", |
563 | bond->dev->name); | 564 | bond->dev->name); |
564 | ret = -EPERM; | 565 | return -EPERM; |
565 | goto out; | ||
566 | } | 566 | } |
567 | 567 | ||
568 | if (sscanf(buf, "%d", &new_value) != 1) { | 568 | new_value = bond_parse_parm(buf, fail_over_mac_tbl); |
569 | if (new_value < 0) { | ||
569 | printk(KERN_ERR DRV_NAME | 570 | printk(KERN_ERR DRV_NAME |
570 | ": %s: no fail_over_mac value specified.\n", | 571 | ": %s: Ignoring invalid fail_over_mac value %s.\n", |
571 | bond->dev->name); | 572 | bond->dev->name, buf); |
572 | ret = -EINVAL; | 573 | return -EINVAL; |
573 | goto out; | ||
574 | } | 574 | } |
575 | 575 | ||
576 | if ((new_value == 0) || (new_value == 1)) { | 576 | bond->params.fail_over_mac = new_value; |
577 | bond->params.fail_over_mac = new_value; | 577 | printk(KERN_INFO DRV_NAME ": %s: Setting fail_over_mac to %s (%d).\n", |
578 | printk(KERN_INFO DRV_NAME ": %s: Setting fail_over_mac to %d.\n", | 578 | bond->dev->name, fail_over_mac_tbl[new_value].modename, |
579 | bond->dev->name, new_value); | 579 | new_value); |
580 | } else { | 580 | |
581 | printk(KERN_INFO DRV_NAME | 581 | return count; |
582 | ": %s: Ignoring invalid fail_over_mac value %d.\n", | ||
583 | bond->dev->name, new_value); | ||
584 | } | ||
585 | out: | ||
586 | return ret; | ||
587 | } | 582 | } |
588 | 583 | ||
589 | static DEVICE_ATTR(fail_over_mac, S_IRUGO | S_IWUSR, bonding_show_fail_over_mac, bonding_store_fail_over_mac); | 584 | static DEVICE_ATTR(fail_over_mac, S_IRUGO | S_IWUSR, bonding_show_fail_over_mac, bonding_store_fail_over_mac); |
@@ -952,6 +947,45 @@ out: | |||
952 | static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp); | 947 | static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp); |
953 | 948 | ||
954 | /* | 949 | /* |
950 | * Show and set the number of grat ARP to send after a failover event. | ||
951 | */ | ||
952 | static ssize_t bonding_show_n_grat_arp(struct device *d, | ||
953 | struct device_attribute *attr, | ||
954 | char *buf) | ||
955 | { | ||
956 | struct bonding *bond = to_bond(d); | ||
957 | |||
958 | return sprintf(buf, "%d\n", bond->params.num_grat_arp); | ||
959 | } | ||
960 | |||
961 | static ssize_t bonding_store_n_grat_arp(struct device *d, | ||
962 | struct device_attribute *attr, | ||
963 | const char *buf, size_t count) | ||
964 | { | ||
965 | int new_value, ret = count; | ||
966 | struct bonding *bond = to_bond(d); | ||
967 | |||
968 | if (sscanf(buf, "%d", &new_value) != 1) { | ||
969 | printk(KERN_ERR DRV_NAME | ||
970 | ": %s: no num_grat_arp value specified.\n", | ||
971 | bond->dev->name); | ||
972 | ret = -EINVAL; | ||
973 | goto out; | ||
974 | } | ||
975 | if (new_value < 0 || new_value > 255) { | ||
976 | printk(KERN_ERR DRV_NAME | ||
977 | ": %s: Invalid num_grat_arp value %d not in range 0-255; rejected.\n", | ||
978 | bond->dev->name, new_value); | ||
979 | ret = -EINVAL; | ||
980 | goto out; | ||
981 | } else { | ||
982 | bond->params.num_grat_arp = new_value; | ||
983 | } | ||
984 | out: | ||
985 | return ret; | ||
986 | } | ||
987 | static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR, bonding_show_n_grat_arp, bonding_store_n_grat_arp); | ||
988 | /* | ||
955 | * Show and set the MII monitor interval. There are two tricky bits | 989 | * Show and set the MII monitor interval. There are two tricky bits |
956 | * here. First, if MII monitoring is activated, then we must disable | 990 | * here. First, if MII monitoring is activated, then we must disable |
957 | * ARP monitoring. Second, if the timer isn't running, we must | 991 | * ARP monitoring. Second, if the timer isn't running, we must |
@@ -1388,6 +1422,7 @@ static struct attribute *per_bond_attrs[] = { | |||
1388 | &dev_attr_updelay.attr, | 1422 | &dev_attr_updelay.attr, |
1389 | &dev_attr_lacp_rate.attr, | 1423 | &dev_attr_lacp_rate.attr, |
1390 | &dev_attr_xmit_hash_policy.attr, | 1424 | &dev_attr_xmit_hash_policy.attr, |
1425 | &dev_attr_num_grat_arp.attr, | ||
1391 | &dev_attr_miimon.attr, | 1426 | &dev_attr_miimon.attr, |
1392 | &dev_attr_primary.attr, | 1427 | &dev_attr_primary.attr, |
1393 | &dev_attr_use_carrier.attr, | 1428 | &dev_attr_use_carrier.attr, |