From ade2d09ef2a32d65a7a389b4b76b470c782addf2 Mon Sep 17 00:00:00 2001
From: Phil Sutter <psutter@redhat.com>
Date: Tue, 28 Feb 2017 16:11:51 +0100
Subject: [PATCH] bridge: mdb: add deleted when monitoring delmdb event
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1417289
Upstream Status: iproute2.git commit 90d73159d9a32
commit 90d73159d9a326fa59c5e340ae3489f63ec49b3e
Author: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Date: Thu Jul 30 11:30:32 2015 +0200
bridge: mdb: add deleted when monitoring delmdb event
Before this patch both addmdb and delmdb events were printed the same,
now we'll get a "Deleted" string in front when delmdb is received.
Before:
$ bridge mdb add dev br0 port eth3 grp 239.0.0.1
(monitor) dev br0 port eth3 grp 239.0.0.1 temp
$ bridge mdb del dev br0 port eth3 grp 239.0.0.1
(monitor) dev br0 port eth3 grp 239.0.0.1 temp
^^ No way to differentiate between both events.
After:
$ bridge mdb add dev br0 port eth3 grp 239.0.0.1
(monitor) dev br0 port eth3 grp 239.0.0.1 temp
$ bridge mdb del dev br0 port eth3 grp 239.0.0.1
(monitor) Deleted dev br0 port eth3 grp 239.0.0.1 temp
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
bridge/mdb.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/bridge/mdb.c b/bridge/mdb.c
index 1b34f69..b14bd01 100644
--- a/bridge/mdb.c
+++ b/bridge/mdb.c
@@ -48,7 +48,8 @@ static void br_print_router_ports(FILE *f, struct rtattr *attr)
fprintf(f, "\n");
}
-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)
{
SPRINT_BUF(abuf);
const void *src;
@@ -57,6 +58,8 @@ static void print_mdb_entry(FILE *f, int ifindex, struct br_mdb_entry *e)
af = e->addr.proto == htons(ETH_P_IP) ? AF_INET : AF_INET6;
src = af == AF_INET ? (const void *)&e->addr.u.ip4 :
(const void *)&e->addr.u.ip6;
+ if (n->nlmsg_type == RTM_DELMDB)
+ fprintf(f, "Deleted ");
fprintf(f, "dev %s port %s grp %s %s", ll_index_to_name(ifindex),
ll_index_to_name(e->ifindex),
inet_ntop(af, src, abuf, sizeof(abuf)),
@@ -66,7 +69,8 @@ static void print_mdb_entry(FILE *f, int ifindex, struct br_mdb_entry *e)
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 rtattr *i;
int rem;
@@ -75,7 +79,7 @@ static void br_print_mdb_entry(FILE *f, int ifindex, struct rtattr *attr)
rem = RTA_PAYLOAD(attr);
for (i = RTA_DATA(attr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
e = RTA_DATA(i);
- print_mdb_entry(f, ifindex, e);
+ print_mdb_entry(f, ifindex, e, n);
}
}
@@ -108,7 +112,7 @@ int print_mdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
int rem = RTA_PAYLOAD(tb[MDBA_MDB]);
for (i = RTA_DATA(tb[MDBA_MDB]); RTA_OK(i, rem); i = RTA_NEXT(i, rem))
- br_print_mdb_entry(fp, r->ifindex, i);
+ br_print_mdb_entry(fp, r->ifindex, i, n);
}
if (tb[MDBA_ROUTER]) {
--
1.8.3.1