iproute2: fix addrlabel interface names handling

ip addrlabel outputs if%d names due to missing init call:
$ ip addrlabel s
prefix a::42/128 dev if4 label 1000

Also, ip did not accept "if%d" interfaces on input.

Signed-off-by: Florian Westphal <fw@strlen.de>
This commit is contained in:
Florian Westphal 2010-05-07 11:31:02 +00:00 committed by Stephen Hemminger
parent 608a96c727
commit 24abb62ee7
2 changed files with 7 additions and 1 deletions

View File

@ -252,6 +252,8 @@ static int ipaddrlabel_flush(int argc, char **argv)
int do_ipaddrlabel(int argc, char **argv) int do_ipaddrlabel(int argc, char **argv)
{ {
ll_init_map(&rth);
if (argc < 1) { if (argc < 1) {
return ipaddrlabel_list(0, NULL); return ipaddrlabel_list(0, NULL);
} else if (matches(argv[0], "list") == 0 || } else if (matches(argv[0], "list") == 0 ||

View File

@ -161,6 +161,7 @@ unsigned ll_name_to_index(const char *name)
static int icache; static int icache;
struct idxmap *im; struct idxmap *im;
int i; int i;
unsigned idx;
if (name == NULL) if (name == NULL)
return 0; return 0;
@ -176,7 +177,10 @@ unsigned ll_name_to_index(const char *name)
} }
} }
return if_nametoindex(name); idx = if_nametoindex(name);
if (idx == 0)
sscanf(name, "if%u", &idx);
return idx;
} }
int ll_init_map(struct rtnl_handle *rth) int ll_init_map(struct rtnl_handle *rth)