bonding: fix parameter parsing
My last fix (commit ece95f7fef
)
didn't handle one case correctly. This resolves that, and it will now
correctly parse parameters with arbitrary white space, and either text
names or mode values.
Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
c800c5c9db
commit
a42e534f1b
@@ -4549,14 +4549,19 @@ static void bond_free_all(void)
|
|||||||
int bond_parse_parm(const char *buf, struct bond_parm_tbl *tbl)
|
int bond_parse_parm(const char *buf, struct bond_parm_tbl *tbl)
|
||||||
{
|
{
|
||||||
int mode = -1, i, rv;
|
int mode = -1, i, rv;
|
||||||
char modestr[BOND_MAX_MODENAME_LEN + 1] = { 0, };
|
char *p, modestr[BOND_MAX_MODENAME_LEN + 1] = { 0, };
|
||||||
|
|
||||||
rv = sscanf(buf, "%d", &mode);
|
for (p = (char *)buf; *p; p++)
|
||||||
if (!rv) {
|
if (!(isdigit(*p) || isspace(*p)))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (*p)
|
||||||
rv = sscanf(buf, "%20s", modestr);
|
rv = sscanf(buf, "%20s", modestr);
|
||||||
if (!rv)
|
else
|
||||||
return -1;
|
rv = sscanf(buf, "%d", &mode);
|
||||||
}
|
|
||||||
|
if (!rv)
|
||||||
|
return -1;
|
||||||
|
|
||||||
for (i = 0; tbl[i].modename; i++) {
|
for (i = 0; tbl[i].modename; i++) {
|
||||||
if (mode == tbl[i].mode)
|
if (mode == tbl[i].mode)
|
||||||
|
Reference in New Issue
Block a user