diff options
Diffstat (limited to 'drivers/net/bonding/bond_main.c')
-rw-r--r-- | drivers/net/bonding/bond_main.c | 23 |
1 files changed, 16 insertions, 7 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; |