Message ID | 20140213163159.7F73CE668E@unicorn.suse.cz |
---|---|
State | Accepted, archived |
Delegated to: | stephen hemminger |
Headers | show |
On Thu, 13 Feb 2014 17:31:59 +0100 (CET) Michal Kubecek <mkubecek@suse.cz> wrote: > 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> Applied -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/ip/iplink_bond.c b/ip/iplink_bond.c index f22151e..7a950df 100644 --- a/ip/iplink_bond.c +++ b/ip/iplink_bond.c @@ -106,7 +106,7 @@ static int get_index(const char **tbl, char *name) return 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 -1;
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> --- ip/iplink_bond.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)