Skip to contentSkip to conversation

iproute2: fix addrlabel interface names handling

PATCH New Florian Westphal 1 participant 1 message May 7, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 ip/ipaddrlabel.c |    2 ++
 lib/ll_map.c     |    6 +++++-
 2 files changed, 7 insertions(+), 1 deletions(-)
ip/ipaddrlabel.c +2 -0
index cf438d6..95e813d 100644
@@ -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 ||
lib/ll_map.c +5 -1
index 5addf4a..b8b49aa 100644
@@ -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)
Signature · 1 line
1.6.4.4