Commit 05d4f64d authored by Nikolay Aleksandrov's avatar Nikolay Aleksandrov Committed by Stephen Hemminger

bridge: mdb: add user-space support for extended attributes

Recently support was added to the kernel to be able to add more per-mdb
entry attributes via standard netlink attributes of type MDBA_MDB_EATTR_.
This patch adds support to iproute2 to parse and output these
attributes. The first exported attribute is the mdb "timer" value which
is shown only when the "-s" iproute2 arg is used.

Example:
$ bridge -s mdb show
dev br0 port eth1 grp 239.0.0.11 permanent   0.00
dev br0 port eth1 grp 239.0.0.10 temp 244.15
dev br0 port eth1 grp 239.0.0.1 temp 245.21
dev br0 port eth1 grp 239.0.0.5 temp 246.43
dev br0 port eth2 grp 239.0.0.5 temp 248.44
dev br0 port eth1 grp 239.0.0.2 temp 245.32
Signed-off-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
parent 2421ab75
#define MDB_RTA(r) \
((struct rtattr *)(((char *)(r)) + RTA_ALIGN(sizeof(struct br_mdb_entry))))
extern int print_linkinfo(const struct sockaddr_nl *who, extern int print_linkinfo(const struct sockaddr_nl *who,
struct nlmsghdr *n, struct nlmsghdr *n,
void *arg); void *arg);
......
...@@ -49,7 +49,7 @@ static void br_print_router_ports(FILE *f, struct rtattr *attr) ...@@ -49,7 +49,7 @@ static void br_print_router_ports(FILE *f, struct rtattr *attr)
} }
static void print_mdb_entry(FILE *f, int ifindex, struct br_mdb_entry *e, static void print_mdb_entry(FILE *f, int ifindex, struct br_mdb_entry *e,
struct nlmsghdr *n) struct nlmsghdr *n, struct rtattr **tb)
{ {
SPRINT_BUF(abuf); SPRINT_BUF(abuf);
const void *src; const void *src;
...@@ -66,20 +66,29 @@ static void print_mdb_entry(FILE *f, int ifindex, struct br_mdb_entry *e, ...@@ -66,20 +66,29 @@ static void print_mdb_entry(FILE *f, int ifindex, struct br_mdb_entry *e,
(e->state & MDB_PERMANENT) ? "permanent" : "temp"); (e->state & MDB_PERMANENT) ? "permanent" : "temp");
if (e->vid) if (e->vid)
fprintf(f, " vid %hu", e->vid); fprintf(f, " vid %hu", e->vid);
if (show_stats && tb && tb[MDBA_MDB_EATTR_TIMER]) {
struct timeval tv;
__jiffies_to_tv(&tv, rta_getattr_u32(tb[MDBA_MDB_EATTR_TIMER]));
fprintf(f, "%4i.%.2i", (int)tv.tv_sec, (int)tv.tv_usec/10000);
}
fprintf(f, "\n"); fprintf(f, "\n");
} }
static void br_print_mdb_entry(FILE *f, int ifindex, struct rtattr *attr, static void br_print_mdb_entry(FILE *f, int ifindex, struct rtattr *attr,
struct nlmsghdr *n) struct nlmsghdr *n)
{ {
struct rtattr *etb[MDBA_MDB_EATTR_MAX + 1];
struct br_mdb_entry *e;
struct rtattr *i; struct rtattr *i;
int rem; int rem;
struct br_mdb_entry *e;
rem = RTA_PAYLOAD(attr); rem = RTA_PAYLOAD(attr);
for (i = RTA_DATA(attr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) { for (i = RTA_DATA(attr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
e = RTA_DATA(i); e = RTA_DATA(i);
print_mdb_entry(f, ifindex, e, n); parse_rtattr(etb, MDBA_MDB_EATTR_MAX, MDB_RTA(RTA_DATA(i)),
RTA_PAYLOAD(i) - RTA_ALIGN(sizeof(*e)));
print_mdb_entry(f, ifindex, e, n, etb);
} }
} }
......
...@@ -503,6 +503,11 @@ With the ...@@ -503,6 +503,11 @@ With the
option, the command becomes verbose. It prints out the ports known to have option, the command becomes verbose. It prints out the ports known to have
a connected router. a connected router.
.PP
With the
.B -statistics
option, the command displays timer values for mdb entries.
.SH bridge vlan - VLAN filter list .SH bridge vlan - VLAN filter list
.B vlan .B vlan
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment