@@ -14,6 +14,7 @@ void print_stp_state(__u8 state);
int parse_stp_state(const char *arg);
int print_vlan_rtm(struct nlmsghdr *n, void *arg, bool monitor,
bool global_only);
+void br_print_router_port_stats(struct rtattr *pattr);
int do_fdb(int argc, char **argv);
int do_mdb(int argc, char **argv);
@@ -59,7 +59,7 @@ static const char *format_timer(__u32 ticks, int align)
return tbuf;
}
-static void __print_router_port_stats(FILE *f, struct rtattr *pattr)
+void br_print_router_port_stats(struct rtattr *pattr)
{
struct rtattr *tb[MDBA_ROUTER_PATTR_MAX + 1];
@@ -101,13 +101,13 @@ static void br_print_router_ports(FILE *f, struct rtattr *attr,
print_string(PRINT_JSON, "port", NULL, port_ifname);
if (show_stats)
- __print_router_port_stats(f, i);
+ br_print_router_port_stats(i);
close_json_object();
} else if (show_stats) {
fprintf(f, "router ports on %s: %s",
brifname, port_ifname);
- __print_router_port_stats(f, i);
+ br_print_router_port_stats(i);
fprintf(f, "\n");
} else {
fprintf(f, "%s ", port_ifname);
@@ -802,6 +802,36 @@ static int print_vlan_stats(struct nlmsghdr *n, void *arg)
return 0;
}
+static void print_vlan_router_ports(struct rtattr *rattr)
+{
+ int rem = RTA_PAYLOAD(rattr);
+ struct rtattr *i;
+
+ print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s ", "");
+ open_json_array(PRINT_ANY, is_json_context() ? "router_ports" :
+ "router ports: ");
+ for (i = RTA_DATA(rattr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
+ uint32_t *port_ifindex = RTA_DATA(i);
+ const char *port_ifname = ll_index_to_name(*port_ifindex);
+
+ open_json_object(NULL);
+ if (show_stats && i != RTA_DATA(rattr)) {
+ print_nl();
+ /* start: IFNAMSIZ + 4 + strlen("router ports: ") */
+ print_string(PRINT_FP, NULL,
+ "%-" __stringify(IFNAMSIZ) "s "
+ " ",
+ "");
+ }
+ print_string(PRINT_ANY, "port", "%s ", port_ifname);
+ if (show_stats)
+ br_print_router_port_stats(i);
+ close_json_object();
+ }
+ close_json_array(PRINT_JSON, NULL);
+ print_nl();
+}
+
static void print_vlan_global_opts(struct rtattr *a, int ifindex)
{
struct rtattr *vtb[BRIDGE_VLANDB_GOPTS_MAX + 1], *vattr;
@@ -901,6 +931,10 @@ static void print_vlan_global_opts(struct rtattr *a, int ifindex)
rta_getattr_u64(vattr));
}
print_nl();
+ if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS]) {
+ vattr = RTA_DATA(vtb[BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS]);
+ print_vlan_router_ports(vattr);
+ }
close_json_object();
}