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/ip/ipaddress.c b/ip/ipaddress.c
index 013b4cb..1c3e4da 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -418,7 +418,7 @@
if (tb[IFLA_GROUP]) {
int group = *(int*)RTA_DATA(tb[IFLA_GROUP]);
- if (group != filter.group)
+ if (filter.group != -1 && group != filter.group)
return -1;
}
@@ -458,6 +458,12 @@
if (do_link && tb[IFLA_LINKMODE])
print_linkmode(fp, tb[IFLA_LINKMODE]);
+ if (tb[IFLA_GROUP]) {
+ SPRINT_BUF(b1);
+ int group = *(int*)RTA_DATA(tb[IFLA_GROUP]);
+ fprintf(fp, "group %s ", rtnl_group_n2a(group, b1, sizeof(b1)));
+ }
+
if (filter.showqueue)
print_queuelen(fp, tb);
@@ -1050,7 +1056,7 @@
if (filter.family == AF_UNSPEC)
filter.family = preferred_family;
- filter.group = INIT_NETDEV_GROUP;
+ filter.group = -1;
if (action == IPADD_FLUSH) {
if (argc <= 0) {