From caf1f1dfd523c10dd8c9d3694ba485b6edb5dd5d Mon Sep 17 00:00:00 2001
From: Phil Sutter <psutter@redhat.com>
Date: Tue, 28 Feb 2017 16:11:06 +0100
Subject: [PATCH] bridge: mdb: add support for router add/del notifications
monitoring
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1417289
Upstream Status: iproute2.git commit 6b4867e62175c
commit 6b4867e62175ca0635f8cf6b22f882272d5a2219
Author: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Date: Mon Jul 27 13:44:05 2015 +0200
bridge: mdb: add support for router add/del notifications monitoring
This patch adds support for ADDMDB/DELMDB notifications about router ports
which have been added or deleted/expired respectively.
Example output:
$ bridge -s monitor mdb
Deleted router port dev eth3 master br0
router port dev eth3 master br0
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
bridge/mdb.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/bridge/mdb.c b/bridge/mdb.c
index 9a8ed54..680ec30 100644
--- a/bridge/mdb.c
+++ b/bridge/mdb.c
@@ -82,7 +82,7 @@ int print_mdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
FILE *fp = arg;
struct br_port_msg *r = NLMSG_DATA(n);
int len = n->nlmsg_len;
- struct rtattr * tb[MDBA_MAX+1];
+ struct rtattr *tb[MDBA_MAX+1], *i;
if (n->nlmsg_type != RTM_GETMDB && n->nlmsg_type != RTM_NEWMDB && n->nlmsg_type != RTM_DELMDB) {
fprintf(stderr, "Not RTM_GETMDB, RTM_NEWMDB or RTM_DELMDB: %08x %08x %08x\n",
@@ -103,7 +103,6 @@ int print_mdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
parse_rtattr(tb, MDBA_MAX, MDBA_RTA(r), n->nlmsg_len - NLMSG_LENGTH(sizeof(*r)));
if (tb[MDBA_MDB]) {
- struct rtattr *i;
int rem = RTA_PAYLOAD(tb[MDBA_MDB]);
for (i = RTA_DATA(tb[MDBA_MDB]); RTA_OK(i, rem); i = RTA_NEXT(i, rem))
@@ -111,9 +110,22 @@ int print_mdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
}
if (tb[MDBA_ROUTER]) {
- if (show_details) {
- fprintf(fp, "router ports on %s: ", ll_index_to_name(r->ifindex));
- br_print_router_ports(fp, tb[MDBA_ROUTER]);
+ if (n->nlmsg_type == RTM_GETMDB) {
+ if (show_details) {
+ fprintf(fp, "router ports on %s: ",
+ ll_index_to_name(r->ifindex));
+ br_print_router_ports(fp, tb[MDBA_ROUTER]);
+ }
+ } else {
+ uint32_t *port_ifindex;
+
+ i = RTA_DATA(tb[MDBA_ROUTER]);
+ port_ifindex = RTA_DATA(i);
+ if (n->nlmsg_type == RTM_DELMDB)
+ fprintf(fp, "Deleted ");
+ fprintf(fp, "router port dev %s master %s\n",
+ ll_index_to_name(*port_ifindex),
+ ll_index_to_name(r->ifindex));
}
}
--
1.8.3.1