@@ -145,6 +145,7 @@ static int print_vlan(const struct sockaddr_nl *who,
struct ifinfomsg *ifm = NLMSG_DATA(n);
int len = n->nlmsg_len;
struct rtattr * tb[IFLA_MAX+1];
+ bool vlan_table_found = false;
if (n->nlmsg_type != RTM_NEWLINK) {
fprintf(stderr, "Not RTM_NEWLINK: %08x %08x %08x\n",
@@ -174,13 +175,22 @@ static int print_vlan(const struct sockaddr_nl *who,
struct rtattr *i, *list = tb[IFLA_AF_SPEC];
int rem = RTA_PAYLOAD(list);
- fprintf(fp, "%s", ll_index_to_name(ifm->ifi_index));
for (i = RTA_DATA(list); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) { struct bridge_vlan_info *vinfo;
if (i->rta_type != IFLA_BRIDGE_VLAN_INFO)
continue;
:
+ /* Printing interface name is deferred until first
+ * IFLA_BRIDGE_VLAN_INFO is seen since there could be
+ * IFLA_AF_SPEC with only IFLA_BRIDGE_MODE or/and
+ * IFLA_BRIDGE_FLAGS
+ */
+ if (!vlan_table_found) {
+ vlan_table_found = true;
+ fprintf(fp, "%s", ll_index_to_name(ifm->ifi_inde+ }
+
vinfo = RTA_DATA(i);
if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_END)
fprintf(fp, "-%hu", vinfo->vid);
@@ -195,7 +205,8 @@ static int print_vlan(const struct sockaddr_nl *who,