diff options
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r-- | drivers/net/bonding/bond_main.c | 23 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 8 | ||||
-rw-r--r-- | drivers/net/bonding/bonding.h | 4 |
3 files changed, 23 insertions, 12 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 3ede0a2e6860..379c5d87c804 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -4540,18 +4540,27 @@ static void bond_free_all(void) | |||
4540 | 4540 | ||
4541 | /* | 4541 | /* |
4542 | * Convert string input module parms. Accept either the | 4542 | * Convert string input module parms. Accept either the |
4543 | * number of the mode or its string name. | 4543 | * number of the mode or its string name. A bit complicated because |
4544 | * some mode names are substrings of other names, and calls from sysfs | ||
4545 | * may have whitespace in the name (trailing newlines, for example). | ||
4544 | */ | 4546 | */ |
4545 | int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl) | 4547 | int bond_parse_parm(const char *buf, struct bond_parm_tbl *tbl) |
4546 | { | 4548 | { |
4547 | int i; | 4549 | int mode = -1, i, rv; |
4550 | char modestr[BOND_MAX_MODENAME_LEN + 1] = { 0, }; | ||
4551 | |||
4552 | rv = sscanf(buf, "%d", &mode); | ||
4553 | if (!rv) { | ||
4554 | rv = sscanf(buf, "%20s", modestr); | ||
4555 | if (!rv) | ||
4556 | return -1; | ||
4557 | } | ||
4548 | 4558 | ||
4549 | for (i = 0; tbl[i].modename; i++) { | 4559 | for (i = 0; tbl[i].modename; i++) { |
4550 | if ((isdigit(*mode_arg) && | 4560 | if (mode == tbl[i].mode) |
4551 | tbl[i].mode == simple_strtol(mode_arg, NULL, 0)) || | 4561 | return tbl[i].mode; |
4552 | (strcmp(mode_arg, tbl[i].modename) == 0)) { | 4562 | if (strcmp(modestr, tbl[i].modename) == 0) |
4553 | return tbl[i].mode; | 4563 | return tbl[i].mode; |
4554 | } | ||
4555 | } | 4564 | } |
4556 | 4565 | ||
4557 | return -1; | 4566 | return -1; |
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 28a2d803e7e5..bff4f2b84ce0 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -423,7 +423,7 @@ static ssize_t bonding_store_mode(struct device *d, | |||
423 | goto out; | 423 | goto out; |
424 | } | 424 | } |
425 | 425 | ||
426 | new_value = bond_parse_parm((char *)buf, bond_mode_tbl); | 426 | new_value = bond_parse_parm(buf, bond_mode_tbl); |
427 | if (new_value < 0) { | 427 | if (new_value < 0) { |
428 | printk(KERN_ERR DRV_NAME | 428 | printk(KERN_ERR DRV_NAME |
429 | ": %s: Ignoring invalid mode value %.*s.\n", | 429 | ": %s: Ignoring invalid mode value %.*s.\n", |
@@ -478,7 +478,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d, | |||
478 | goto out; | 478 | goto out; |
479 | } | 479 | } |
480 | 480 | ||
481 | new_value = bond_parse_parm((char *)buf, xmit_hashtype_tbl); | 481 | new_value = bond_parse_parm(buf, xmit_hashtype_tbl); |
482 | if (new_value < 0) { | 482 | if (new_value < 0) { |
483 | printk(KERN_ERR DRV_NAME | 483 | printk(KERN_ERR DRV_NAME |
484 | ": %s: Ignoring invalid xmit hash policy value %.*s.\n", | 484 | ": %s: Ignoring invalid xmit hash policy value %.*s.\n", |
@@ -518,7 +518,7 @@ static ssize_t bonding_store_arp_validate(struct device *d, | |||
518 | int new_value; | 518 | int new_value; |
519 | struct bonding *bond = to_bond(d); | 519 | struct bonding *bond = to_bond(d); |
520 | 520 | ||
521 | new_value = bond_parse_parm((char *)buf, arp_validate_tbl); | 521 | new_value = bond_parse_parm(buf, arp_validate_tbl); |
522 | if (new_value < 0) { | 522 | if (new_value < 0) { |
523 | printk(KERN_ERR DRV_NAME | 523 | printk(KERN_ERR DRV_NAME |
524 | ": %s: Ignoring invalid arp_validate value %s\n", | 524 | ": %s: Ignoring invalid arp_validate value %s\n", |
@@ -941,7 +941,7 @@ static ssize_t bonding_store_lacp(struct device *d, | |||
941 | goto out; | 941 | goto out; |
942 | } | 942 | } |
943 | 943 | ||
944 | new_value = bond_parse_parm((char *)buf, bond_lacp_tbl); | 944 | new_value = bond_parse_parm(buf, bond_lacp_tbl); |
945 | 945 | ||
946 | if ((new_value == 1) || (new_value == 0)) { | 946 | if ((new_value == 1) || (new_value == 0)) { |
947 | bond->params.lacp_fast = new_value; | 947 | bond->params.lacp_fast = new_value; |
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index e1e4734e23ce..6d83be49899a 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -141,6 +141,8 @@ struct bond_parm_tbl { | |||
141 | int mode; | 141 | int mode; |
142 | }; | 142 | }; |
143 | 143 | ||
144 | #define BOND_MAX_MODENAME_LEN 20 | ||
145 | |||
144 | struct vlan_entry { | 146 | struct vlan_entry { |
145 | struct list_head vlan_list; | 147 | struct list_head vlan_list; |
146 | __be32 vlan_ip; | 148 | __be32 vlan_ip; |
@@ -314,7 +316,7 @@ void bond_mii_monitor(struct work_struct *); | |||
314 | void bond_loadbalance_arp_mon(struct work_struct *); | 316 | void bond_loadbalance_arp_mon(struct work_struct *); |
315 | void bond_activebackup_arp_mon(struct work_struct *); | 317 | void bond_activebackup_arp_mon(struct work_struct *); |
316 | void bond_set_mode_ops(struct bonding *bond, int mode); | 318 | void bond_set_mode_ops(struct bonding *bond, int mode); |
317 | int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl); | 319 | int bond_parse_parm(const char *mode_arg, struct bond_parm_tbl *tbl); |
318 | void bond_select_active_slave(struct bonding *bond); | 320 | void bond_select_active_slave(struct bonding *bond); |
319 | void bond_change_active_slave(struct bonding *bond, struct slave *new_active); | 321 | void bond_change_active_slave(struct bonding *bond, struct slave *new_active); |
320 | void bond_register_arp(struct bonding *); | 322 | void bond_register_arp(struct bonding *); |