ip link: fix display of interface groups
This change adds the interface group to the output of "ip link show".
It also makes "ip link" print _all_ devices if no group filter is specified;
previously, only interfaces of the default group (0) were shown.
Signed-off-by: Stefan Tomanek <stefan.tomanek@wertarbyte.de>
diff --git a/lib/rt_names.c b/lib/rt_names.c
index 02f1417..67e4c49 100644
--- a/lib/rt_names.c
+++ b/lib/rt_names.c
@@ -500,3 +500,22 @@
*id = i;
return 0;
}
+
+const char *rtnl_group_n2a(int id, char *buf, int len)
+{
+ struct rtnl_hash_entry *entry;
+ int i;
+
+ if (!rtnl_group_init)
+ rtnl_group_initialize();
+
+ for (i=0; i<256; i++) {
+ entry = rtnl_group_hash[i];
+ if (entry && entry->id == id) {
+ return entry->name;
+ }
+ }
+
+ snprintf(buf, len, "%d", id);
+ return buf;
+}