Commit 2dd5909d authored by Nicolas Dichtel's avatar Nicolas Dichtel Committed by Stephen Hemminger

ip-monitor: allow to monitor ip rules

Now done by default or with 'ip monitor rule'.
Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
parent 5f24ec0e
...@@ -32,7 +32,7 @@ static void usage(void) ...@@ -32,7 +32,7 @@ static void usage(void)
fprintf(stderr, "Usage: ip monitor [ all | LISTofOBJECTS ] [ FILE ]" fprintf(stderr, "Usage: ip monitor [ all | LISTofOBJECTS ] [ FILE ]"
"[ label ] [dev DEVICE]\n"); "[ label ] [dev DEVICE]\n");
fprintf(stderr, "LISTofOBJECTS := link | address | route | mroute | prefix |\n"); fprintf(stderr, "LISTofOBJECTS := link | address | route | mroute | prefix |\n");
fprintf(stderr, " neigh | netconf\n"); fprintf(stderr, " neigh | netconf | rule\n");
fprintf(stderr, "FILE := file FILENAME\n"); fprintf(stderr, "FILE := file FILENAME\n");
exit(-1); exit(-1);
} }
...@@ -150,6 +150,7 @@ int do_ipmonitor(int argc, char **argv) ...@@ -150,6 +150,7 @@ int do_ipmonitor(int argc, char **argv)
int lprefix=0; int lprefix=0;
int lneigh=0; int lneigh=0;
int lnetconf=0; int lnetconf=0;
int lrule=0;
int ifindex=0; int ifindex=0;
groups |= nl_mgrp(RTNLGRP_LINK); groups |= nl_mgrp(RTNLGRP_LINK);
...@@ -163,6 +164,8 @@ int do_ipmonitor(int argc, char **argv) ...@@ -163,6 +164,8 @@ int do_ipmonitor(int argc, char **argv)
groups |= nl_mgrp(RTNLGRP_NEIGH); groups |= nl_mgrp(RTNLGRP_NEIGH);
groups |= nl_mgrp(RTNLGRP_IPV4_NETCONF); groups |= nl_mgrp(RTNLGRP_IPV4_NETCONF);
groups |= nl_mgrp(RTNLGRP_IPV6_NETCONF); groups |= nl_mgrp(RTNLGRP_IPV6_NETCONF);
groups |= nl_mgrp(RTNLGRP_IPV4_RULE);
groups |= nl_mgrp(RTNLGRP_IPV6_RULE);
rtnl_close(&rth); rtnl_close(&rth);
...@@ -193,6 +196,9 @@ int do_ipmonitor(int argc, char **argv) ...@@ -193,6 +196,9 @@ int do_ipmonitor(int argc, char **argv)
} else if (matches(*argv, "netconf") == 0) { } else if (matches(*argv, "netconf") == 0) {
lnetconf = 1; lnetconf = 1;
groups = 0; groups = 0;
} else if (matches(*argv, "rule") == 0) {
lrule = 1;
groups = 0;
} else if (strcmp(*argv, "all") == 0) { } else if (strcmp(*argv, "all") == 0) {
prefix_banner=1; prefix_banner=1;
} else if (matches(*argv, "help") == 0) { } else if (matches(*argv, "help") == 0) {
...@@ -249,6 +255,12 @@ int do_ipmonitor(int argc, char **argv) ...@@ -249,6 +255,12 @@ int do_ipmonitor(int argc, char **argv)
if (!preferred_family || preferred_family == AF_INET6) if (!preferred_family || preferred_family == AF_INET6)
groups |= nl_mgrp(RTNLGRP_IPV6_NETCONF); groups |= nl_mgrp(RTNLGRP_IPV6_NETCONF);
} }
if (lrule) {
if (!preferred_family || preferred_family == AF_INET)
groups |= nl_mgrp(RTNLGRP_IPV4_RULE);
if (!preferred_family || preferred_family == AF_INET6)
groups |= nl_mgrp(RTNLGRP_IPV6_RULE);
}
if (file) { if (file) {
FILE *fp; FILE *fp;
fp = fopen(file, "r"); fp = fopen(file, "r");
......
...@@ -49,7 +49,7 @@ command is the first in the command line and then the object list follows: ...@@ -49,7 +49,7 @@ command is the first in the command line and then the object list follows:
is the list of object types that we want to monitor. is the list of object types that we want to monitor.
It may contain It may contain
.BR link ", " address ", " route ", " mroute ", " prefix ", " .BR link ", " address ", " route ", " mroute ", " prefix ", "
.BR neigh " and " netconf "." .BR neigh ", " netconf " and " rule "."
If no If no
.B file .B file
argument is given, argument is given,
......
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