mirror of
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git
synced 2024-11-16 22:45:17 +08:00
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>
This commit is contained in:
parent
cb89c7c70a
commit
6b4867e621
22
bridge/mdb.c
22
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user