netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ip monitor: Enable prefix labels when monitoring more than 1 object
@ 2013-08-14 21:05 Martin Schwenke
  2013-08-16  6:40 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Schwenke @ 2013-08-14 21:05 UTC (permalink / raw)
  To: netdev

Prefix labelling is currently only activated when monitoring "all"
objects.  However, the output can still be confusing when monitoring
more than 1 object, so enable prefix labels in this case.

Signed-off-by: Martin Schwenke <martin@meltin.net>
---
 ip/ipmonitor.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/ip/ipmonitor.c b/ip/ipmonitor.c
index 86c473e..62401ea 100644
--- a/ip/ipmonitor.c
+++ b/ip/ipmonitor.c
@@ -146,6 +146,7 @@ int do_ipmonitor(int argc, char **argv)
 	int lprefix=0;
 	int lneigh=0;
 	int lnetconf=0;
+	int num_objects = 0;
 
 	rtnl_close(&rth);
 	ipaddr_reset_filter(1);
@@ -159,24 +160,31 @@ int do_ipmonitor(int argc, char **argv)
 			file = *argv;
 		} else if (matches(*argv, "link") == 0) {
 			llink=1;
+			num_objects++;
 			groups = 0;
 		} else if (matches(*argv, "address") == 0) {
 			laddr=1;
+			num_objects++;
 			groups = 0;
 		} else if (matches(*argv, "route") == 0) {
 			lroute=1;
+			num_objects++;
 			groups = 0;
 		} else if (matches(*argv, "mroute") == 0) {
 			lmroute=1;
+			num_objects++;
 			groups = 0;
 		} else if (matches(*argv, "prefix") == 0) {
 			lprefix=1;
+			num_objects++;
 			groups = 0;
 		} else if (matches(*argv, "neigh") == 0) {
 			lneigh = 1;
+			num_objects++;
 			groups = 0;
 		} else if (matches(*argv, "netconf") == 0) {
 			lnetconf = 1;
+			num_objects++;
 			groups = 0;
 		} else if (strcmp(*argv, "all") == 0) {
 			groups = ~RTMGRP_TC;
@@ -223,6 +231,9 @@ int do_ipmonitor(int argc, char **argv)
 		if (!preferred_family || preferred_family == AF_INET6)
 			groups |= nl_mgrp(RTNLGRP_IPV6_NETCONF);
 	}
+	if (num_objects > 1) {
+		prefix_banner = 1;
+	}
 	if (file) {
 		FILE *fp;
 		fp = fopen(file, "r");
-- 
1.7.10.4


Can be pulled from git://git.ozlabs.org/~martins/iproute2.git/ctdb.git

I'm not on the list so please CC: me on responses...

peace & happiness,
martin

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-08-16  6:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-14 21:05 [PATCH] ip monitor: Enable prefix labels when monitoring more than 1 object Martin Schwenke
2013-08-16  6:40 ` Stephen Hemminger
2013-08-16  6:52   ` Martin Schwenke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).