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

* Re: [PATCH] ip monitor: Enable prefix labels when monitoring more than 1 object
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2013-08-16  6:40 UTC (permalink / raw)
  To: Martin Schwenke; +Cc: netdev

On Thu, 15 Aug 2013 07:05:27 +1000
Martin Schwenke <martin@meltin.net> wrote:

> 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>

I understand where you are coming from, but changing the output format
might break people with scripts doing parsing the current format.

Since there is already a flag to ip monitor to put on prefix labels,
why not just use that if you need to?

This seems like a change likely to upset more people than it pleases.

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

* Re: [PATCH] ip monitor: Enable prefix labels when monitoring more than 1 object
  2013-08-16  6:40 ` Stephen Hemminger
@ 2013-08-16  6:52   ` Martin Schwenke
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Schwenke @ 2013-08-16  6:52 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

On Thu, 15 Aug 2013 23:40:47 -0700, Stephen Hemminger
<stephen@networkplumber.org> wrote:

> On Thu, 15 Aug 2013 07:05:27 +1000
> Martin Schwenke <martin@meltin.net> wrote:
> 
> > 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>
> 
> I understand where you are coming from, but changing the output format
> might break people with scripts doing parsing the current format.
> 
> Since there is already a flag to ip monitor to put on prefix labels,
> why not just use that if you need to?

Sorry, I can't see that option in either the usage message or in the
code.  In the current code the only place I can see prefix_banner
being set is in the "all" case.  I think "prefix" is about monitoring
IPv6 prefixes or similar.

Perhaps I could add a "label" option instead?

> This seems like a change likely to upset more people than it pleases.

Yeah, perhaps...  :-(

peace & happiness,
martin

^ permalink raw reply	[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).