Commit 4a4ee616 authored by Cong Wang's avatar Cong Wang Committed by Stephen Hemminger

iproute2: add support to monitor mdb entries too

This patch implements `bridge monitor mdb`.

Cc: Stephen Hemminger <shemminger@vyatta.com>
Cc: Thomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarCong Wang <amwang@redhat.com>
parent 9dca6767
...@@ -3,6 +3,8 @@ extern int print_linkinfo(const struct sockaddr_nl *who, ...@@ -3,6 +3,8 @@ extern int print_linkinfo(const struct sockaddr_nl *who,
void *arg); void *arg);
extern int print_fdb(const struct sockaddr_nl *who, extern int print_fdb(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg); struct nlmsghdr *n, void *arg);
extern int print_mdb(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg);
extern int do_fdb(int argc, char **argv); extern int do_fdb(int argc, char **argv);
extern int do_mdb(int argc, char **argv); extern int do_mdb(int argc, char **argv);
......
...@@ -82,8 +82,8 @@ int print_mdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) ...@@ -82,8 +82,8 @@ int print_mdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
int len = n->nlmsg_len; int len = n->nlmsg_len;
struct rtattr * tb[MDBA_MAX+1]; struct rtattr * tb[MDBA_MAX+1];
if (n->nlmsg_type != RTM_GETMDB) { if (n->nlmsg_type != RTM_GETMDB && n->nlmsg_type != RTM_NEWMDB && n->nlmsg_type != RTM_DELMDB) {
fprintf(stderr, "Not RTM_GETMDB: %08x %08x %08x\n", fprintf(stderr, "Not RTM_GETMDB, RTM_NEWMDB or RTM_DELMDB: %08x %08x %08x\n",
n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags); n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags);
return 0; return 0;
......
...@@ -68,6 +68,12 @@ int accept_msg(const struct sockaddr_nl *who, ...@@ -68,6 +68,12 @@ int accept_msg(const struct sockaddr_nl *who,
fprintf(fp, "[NEIGH]"); fprintf(fp, "[NEIGH]");
return print_fdb(who, n, arg); return print_fdb(who, n, arg);
case RTM_NEWMDB:
case RTM_DELMDB:
if (prefix_banner)
fprintf(fp, "[MDB]");
return print_mdb(who, n, arg);
case 15: case 15:
return show_mark(fp, n); return show_mark(fp, n);
...@@ -84,6 +90,7 @@ int do_monitor(int argc, char **argv) ...@@ -84,6 +90,7 @@ int do_monitor(int argc, char **argv)
unsigned groups = ~RTMGRP_TC; unsigned groups = ~RTMGRP_TC;
int llink=0; int llink=0;
int lneigh=0; int lneigh=0;
int lmdb=0;
rtnl_close(&rth); rtnl_close(&rth);
...@@ -97,6 +104,9 @@ int do_monitor(int argc, char **argv) ...@@ -97,6 +104,9 @@ int do_monitor(int argc, char **argv)
} else if (matches(*argv, "fdb") == 0) { } else if (matches(*argv, "fdb") == 0) {
lneigh = 1; lneigh = 1;
groups = 0; groups = 0;
} else if (matches(*argv, "mdb") == 0) {
lmdb = 1;
groups = 0;
} else if (strcmp(*argv, "all") == 0) { } else if (strcmp(*argv, "all") == 0) {
groups = ~RTMGRP_TC; groups = ~RTMGRP_TC;
prefix_banner=1; prefix_banner=1;
...@@ -116,6 +126,10 @@ int do_monitor(int argc, char **argv) ...@@ -116,6 +126,10 @@ int do_monitor(int argc, char **argv)
groups |= nl_mgrp(RTNLGRP_NEIGH); groups |= nl_mgrp(RTNLGRP_NEIGH);
} }
if (lmdb) {
groups |= nl_mgrp(RTNLGRP_MDB);
}
if (file) { if (file) {
FILE *fp; FILE *fp;
fp = fopen(file, "r"); fp = fopen(file, "r");
......
...@@ -609,6 +609,8 @@ enum rtnetlink_groups { ...@@ -609,6 +609,8 @@ enum rtnetlink_groups {
#define RTNLGRP_IPV4_NETCONF RTNLGRP_IPV4_NETCONF #define RTNLGRP_IPV4_NETCONF RTNLGRP_IPV4_NETCONF
RTNLGRP_IPV6_NETCONF, RTNLGRP_IPV6_NETCONF,
#define RTNLGRP_IPV6_NETCONF RTNLGRP_IPV6_NETCONF #define RTNLGRP_IPV6_NETCONF RTNLGRP_IPV6_NETCONF
RTNLGRP_MDB,
#define RTNLGRP_MDB RTNLGRP_MDB
__RTNLGRP_MAX __RTNLGRP_MAX
}; };
#define RTNLGRP_MAX (__RTNLGRP_MAX - 1) #define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
......
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