]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
iproute2: fix addrlabel interface names handling
authorFlorian Westphal <fw@strlen.de>
Fri, 7 May 2010 11:31:02 +0000 (11:31 +0000)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Thu, 13 May 2010 16:23:46 +0000 (09:23 -0700)
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>
ip/ipaddrlabel.c
lib/ll_map.c

index cf438d639df2b617e3afda830eed35cbc58a9a75..95e813df7e07c7bb3a0cceb36301ef462776dde9 100644 (file)
@@ -252,6 +252,8 @@ static int ipaddrlabel_flush(int argc, char **argv)
 
 int do_ipaddrlabel(int argc, char **argv)
 {
+       ll_init_map(&rth);
+
        if (argc < 1) {
                return ipaddrlabel_list(0, NULL);
        } else if (matches(argv[0], "list") == 0 ||
index 5addf4a4cf4ba18bcdf574554d89c04b5a009c45..b8b49aa147be4fc7a3b6825ebd9bf5a8bc8b3f9b 100644 (file)
@@ -161,6 +161,7 @@ unsigned ll_name_to_index(const char *name)
        static int icache;
        struct idxmap *im;
        int i;
+       unsigned idx;
 
        if (name == NULL)
                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)