Blame SOURCES/0083-bridge-mdb-add-user-space-support-for-extended-attri.patch

4aca6e
From c55cf2cf1b127e5a08830c158fddc45fc8e5c8d8 Mon Sep 17 00:00:00 2001
4aca6e
From: Phil Sutter <psutter@redhat.com>
4aca6e
Date: Tue, 28 Feb 2017 16:12:38 +0100
4aca6e
Subject: [PATCH] bridge: mdb: add user-space support for extended attributes
4aca6e
4aca6e
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1417289
4aca6e
Upstream Status: iproute2.git commit 05d4f64d4abfe
4aca6e
4aca6e
commit 05d4f64d4abfe198144df807d7d496086c5a7ce9
4aca6e
Author: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
4aca6e
Date:   Mon Feb 22 15:16:13 2016 +0100
4aca6e
4aca6e
    bridge: mdb: add user-space support for extended attributes
4aca6e
4aca6e
    Recently support was added to the kernel to be able to add more per-mdb
4aca6e
    entry attributes via standard netlink attributes of type MDBA_MDB_EATTR_.
4aca6e
    This patch adds support to iproute2 to parse and output these
4aca6e
    attributes. The first exported attribute is the mdb "timer" value which
4aca6e
    is shown only when the "-s" iproute2 arg is used.
4aca6e
4aca6e
    Example:
4aca6e
    $ bridge -s mdb show
4aca6e
    dev br0 port eth1 grp 239.0.0.11 permanent   0.00
4aca6e
    dev br0 port eth1 grp 239.0.0.10 temp 244.15
4aca6e
    dev br0 port eth1 grp 239.0.0.1 temp 245.21
4aca6e
    dev br0 port eth1 grp 239.0.0.5 temp 246.43
4aca6e
    dev br0 port eth2 grp 239.0.0.5 temp 248.44
4aca6e
    dev br0 port eth1 grp 239.0.0.2 temp 245.32
4aca6e
4aca6e
    Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
4aca6e
---
4aca6e
 bridge/br_common.h |  3 +++
4aca6e
 bridge/mdb.c       | 15 ++++++++++++---
4aca6e
 man/man8/bridge.8  |  5 +++++
4aca6e
 3 files changed, 20 insertions(+), 3 deletions(-)
4aca6e
4aca6e
diff --git a/bridge/br_common.h b/bridge/br_common.h
4aca6e
index 169a162..41eb0dc 100644
4aca6e
--- a/bridge/br_common.h
4aca6e
+++ b/bridge/br_common.h
4aca6e
@@ -1,3 +1,6 @@
4aca6e
+#define MDB_RTA(r) \
4aca6e
+		((struct rtattr *)(((char *)(r)) + RTA_ALIGN(sizeof(struct br_mdb_entry))))
4aca6e
+
4aca6e
 extern int print_linkinfo(const struct sockaddr_nl *who,
4aca6e
 			  struct nlmsghdr *n,
4aca6e
 			  void *arg);
4aca6e
diff --git a/bridge/mdb.c b/bridge/mdb.c
4aca6e
index 24c4903..09d4b22 100644
4aca6e
--- a/bridge/mdb.c
4aca6e
+++ b/bridge/mdb.c
4aca6e
@@ -49,7 +49,7 @@ static void br_print_router_ports(FILE *f, struct rtattr *attr)
4aca6e
 }
4aca6e
 
4aca6e
 static void print_mdb_entry(FILE *f, int ifindex, struct br_mdb_entry *e,
4aca6e
-			    struct nlmsghdr *n)
4aca6e
+			    struct nlmsghdr *n, struct rtattr **tb)
4aca6e
 {
4aca6e
 	SPRINT_BUF(abuf);
4aca6e
 	const void *src;
4aca6e
@@ -66,20 +66,29 @@ static void print_mdb_entry(FILE *f, int ifindex, struct br_mdb_entry *e,
4aca6e
 		(e->state & MDB_PERMANENT) ? "permanent" : "temp");
4aca6e
 	if (e->vid)
4aca6e
 		fprintf(f, " vid %hu", e->vid);
4aca6e
+	if (show_stats && tb && tb[MDBA_MDB_EATTR_TIMER]) {
4aca6e
+		struct timeval tv;
4aca6e
+
4aca6e
+		__jiffies_to_tv(&tv, rta_getattr_u32(tb[MDBA_MDB_EATTR_TIMER]));
4aca6e
+		fprintf(f, "%4i.%.2i", (int)tv.tv_sec, (int)tv.tv_usec/10000);
4aca6e
+	}
4aca6e
 	fprintf(f, "\n");
4aca6e
 }
4aca6e
 
4aca6e
 static void br_print_mdb_entry(FILE *f, int ifindex, struct rtattr *attr,
4aca6e
 			       struct nlmsghdr *n)
4aca6e
 {
4aca6e
+	struct rtattr *etb[MDBA_MDB_EATTR_MAX + 1];
4aca6e
+	struct br_mdb_entry *e;
4aca6e
 	struct rtattr *i;
4aca6e
 	int rem;
4aca6e
-	struct br_mdb_entry *e;
4aca6e
 
4aca6e
 	rem = RTA_PAYLOAD(attr);
4aca6e
 	for (i = RTA_DATA(attr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
4aca6e
 		e = RTA_DATA(i);
4aca6e
-		print_mdb_entry(f, ifindex, e, n);
4aca6e
+		parse_rtattr(etb, MDBA_MDB_EATTR_MAX, MDB_RTA(RTA_DATA(i)),
4aca6e
+			     RTA_PAYLOAD(i) - RTA_ALIGN(sizeof(*e)));
4aca6e
+		print_mdb_entry(f, ifindex, e, n, etb);
4aca6e
 	}
4aca6e
 }
4aca6e
 
4aca6e
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
4aca6e
index 0a36e75..08f327b 100644
4aca6e
--- a/man/man8/bridge.8
4aca6e
+++ b/man/man8/bridge.8
4aca6e
@@ -503,6 +503,11 @@ With the
4aca6e
 option, the command becomes verbose. It prints out the ports known to have
4aca6e
 a connected router.
4aca6e
 
4aca6e
+.PP
4aca6e
+With the
4aca6e
+.B -statistics
4aca6e
+option, the command displays timer values for mdb entries.
4aca6e
+
4aca6e
 .SH bridge vlan - VLAN filter list
4aca6e
 
4aca6e
 .B vlan
4aca6e
-- 
4aca6e
1.8.3.1
4aca6e