iplink_bond: fix parameter value matching

Lookup function get_index() compares argument with table entries
only up to the length of the table entry so that if an entry
with lower index is a substring of a later one, earlier entry is
used even if the argument is equal to the other. For example,

  ip link set bond0 type bond xmit_hash_policy layer2+3

sets xmit_hash_policy to 0 (layer2) as this is found before
"layer2+3" can be checked.

Use strcmp() to compare whole strings instead.

v2: look for an exact match only

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
This commit is contained in:
Michal Kubeček 2014-02-13 17:31:59 +01:00 committed by Stephen Hemminger
parent 4806867a6c
commit f7a45e0955
1 changed files with 1 additions and 1 deletions

View File

@ -106,7 +106,7 @@ static int get_index(const char **tbl, char *name)
return i; return i;
for (i = 0; tbl[i]; i++) for (i = 0; tbl[i]; i++)
if (strncmp(tbl[i], name, strlen(tbl[i])) == 0) if (strcmp(tbl[i], name) == 0)
return i; return i;
return -1; return -1;