netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2] ip link: Do not show help if 'dev he' was specified
@ 2015-03-15  8:01 Vadim Kochan
  2015-03-15 10:24 ` Christoph Schulz
  0 siblings, 1 reply; 5+ messages in thread
From: Vadim Kochan @ 2015-03-15  8:01 UTC (permalink / raw)
  To: netdev; +Cc: leonhard, Vadim Kochan

From: Vadim Kochan <vadim4j@gmail.com>

Date: Sun, 15 Mar 2015 09:11:41 +0200
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Reported-by: Leonhard Preis <leonhard@pre.is>
---
 ip/ipaddress.c | 3 +--
 ip/iplink.c    | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 99a6ab5..4879826 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -1380,8 +1380,7 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
 		} else {
 			if (strcmp(*argv, "dev") == 0) {
 				NEXT_ARG();
-			}
-			if (matches(*argv, "help") == 0)
+			} else if (matches(*argv, "help") == 0)
 				usage();
 			if (filter_dev)
 				duparg2("dev", *argv);
diff --git a/ip/iplink.c b/ip/iplink.c
index 5893ee4..664774f 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -601,8 +601,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
 		} else {
 			if (strcmp(*argv, "dev") == 0) {
 				NEXT_ARG();
-			}
-			if (matches(*argv, "help") == 0)
+			} else if (matches(*argv, "help") == 0)
 				usage();
 			if (*dev)
 				duparg2("dev", *argv);
@@ -1088,8 +1087,7 @@ static int do_set(int argc, char **argv)
 		} else {
 			if (strcmp(*argv, "dev") == 0) {
 				NEXT_ARG();
-			}
-			if (matches(*argv, "help") == 0)
+			} else if (matches(*argv, "help") == 0)
 				usage();
 			if (dev)
 				duparg2("dev", *argv);
-- 
2.3.1

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

* Re: [PATCH iproute2] ip link: Do not show help if 'dev he' was specified
  2015-03-15  8:01 [PATCH iproute2] ip link: Do not show help if 'dev he' was specified Vadim Kochan
@ 2015-03-15 10:24 ` Christoph Schulz
  2015-03-15 10:38   ` Vadim Kochan
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Schulz @ 2015-03-15 10:24 UTC (permalink / raw)
  To: Vadim Kochan, netdev; +Cc: leonhard

Hello!

On 15.03.2015 09:01, Vadim Kochan wrote:
> From: Vadim Kochan <vadim4j@gmail.com>
> 
> Date: Sun, 15 Mar 2015 09:11:41 +0200
> Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
> Reported-by: Leonhard Preis <leonhard@pre.is>
> ---
>  ip/ipaddress.c | 3 +--
>  ip/iplink.c    | 6 ++----
>  2 files changed, 3 insertions(+), 6 deletions(-)

We use a similar patch at the fli4l router project, but we also modified other files (ip6tunnel.c, ipmaddr.c, ipmroute.c, ipneigh.c, iproute.c, iprule.c). I'm afraid the patch is based on iproute2 3.11.0, but it applies to 3.17.0 (the version we currently use).

I attach the patch in the hope it will prove useful, perhaps as a base for a follow-up patch of yours.


Best regards,

Christoph Schulz

-------- %< --------

Signed-off-by: Christoph Schulz <develop@kristov.de>
---
diff -urN iproute2-3.11.0.orig/ip/ip6tunnel.c iproute2-3.11.0/ip/ip6tunnel.c
--- iproute2-3.11.0.orig/ip/ip6tunnel.c	2013-09-03 17:23:03.000000000 +0200
+++ iproute2-3.11.0/ip/ip6tunnel.c	2013-12-03 20:34:45.000000000 +0100
@@ -206,7 +206,7 @@
 			if (strcmp(*argv, "name") == 0) {
 				NEXT_ARG();
 			}
-			if (matches(*argv, "help") == 0)
+			else if (matches(*argv, "help") == 0)
 				usage();
 			if (p->name[0])
 				duparg2("name", *argv);
diff -urN iproute2-3.11.0.orig/ip/ipaddress.c iproute2-3.11.0/ip/ipaddress.c
--- iproute2-3.11.0.orig/ip/ipaddress.c	2013-09-03 17:23:03.000000000 +0200
+++ iproute2-3.11.0/ip/ipaddress.c	2013-12-03 20:34:45.000000000 +0100
@@ -1128,7 +1128,7 @@
 			if (strcmp(*argv, "dev") == 0) {
 				NEXT_ARG();
 			}
-			if (matches(*argv, "help") == 0)
+			else if (matches(*argv, "help") == 0)
 				usage();
 			if (filter_dev)
 				duparg2("dev", *argv);
@@ -1336,7 +1336,7 @@
 			if (strcmp(*argv, "local") == 0) {
 				NEXT_ARG();
 			}
-			if (matches(*argv, "help") == 0)
+			else if (matches(*argv, "help") == 0)
 				usage();
 			if (local_len)
 				duparg2("local", *argv);
diff -urN iproute2-3.11.0.orig/ip/iplink.c iproute2-3.11.0/ip/iplink.c
--- iproute2-3.11.0.orig/ip/iplink.c	2013-09-03 17:23:03.000000000 +0200
+++ iproute2-3.11.0/ip/iplink.c	2013-12-03 20:34:45.000000000 +0100
@@ -484,7 +484,7 @@
 			if (strcmp(*argv, "dev") == 0) {
 				NEXT_ARG();
 			}
-			if (matches(*argv, "help") == 0)
+			else if (matches(*argv, "help") == 0)
 				usage();
 			if (*dev)
 				duparg2("dev", *argv);
@@ -914,7 +914,7 @@
                         if (strcmp(*argv, "dev") == 0) {
 				NEXT_ARG();
 			}
-			if (matches(*argv, "help") == 0)
+			else if (matches(*argv, "help") == 0)
 				usage();
 			if (dev)
 				duparg2("dev", *argv);
diff -urN iproute2-3.11.0.orig/ip/ipmaddr.c iproute2-3.11.0/ip/ipmaddr.c
--- iproute2-3.11.0.orig/ip/ipmaddr.c	2013-09-03 17:23:03.000000000 +0200
+++ iproute2-3.11.0/ip/ipmaddr.c	2013-12-03 20:34:45.000000000 +0100
@@ -257,7 +257,7 @@
 			if (strcmp(*argv, "dev") == 0) {
 				NEXT_ARG();
 			}
-			if (matches(*argv, "help") == 0)
+			else if (matches(*argv, "help") == 0)
 				usage();
 			if (filter.dev)
 				duparg2("dev", *argv);
@@ -298,7 +298,7 @@
 			if (matches(*argv, "address") == 0) {
 				NEXT_ARG();
 			}
-			if (matches(*argv, "help") == 0)
+			else if (matches(*argv, "help") == 0)
 				usage();
 			if (ifr.ifr_hwaddr.sa_data[0])
 				duparg("address", *argv);
diff -urN iproute2-3.11.0.orig/ip/ipmroute.c iproute2-3.11.0/ip/ipmroute.c
--- iproute2-3.11.0.orig/ip/ipmroute.c	2013-09-03 17:23:03.000000000 +0200
+++ iproute2-3.11.0/ip/ipmroute.c	2013-12-03 20:34:45.000000000 +0100
@@ -222,7 +222,7 @@
 			if (strcmp(*argv, "to") == 0) {
 				NEXT_ARG();
 			}
-			if (matches(*argv, "help") == 0)
+			else if (matches(*argv, "help") == 0)
 				usage();
 			get_prefix(&filter.mdst, *argv, family);
 		}
diff -urN iproute2-3.11.0.orig/ip/ipneigh.c iproute2-3.11.0/ip/ipneigh.c
--- iproute2-3.11.0.orig/ip/ipneigh.c	2013-09-03 17:23:03.000000000 +0200
+++ iproute2-3.11.0/ip/ipneigh.c	2013-12-03 20:34:45.000000000 +0100
@@ -142,7 +142,7 @@
 			if (strcmp(*argv, "to") == 0) {
 				NEXT_ARG();
 			}
-			if (matches(*argv, "help") == 0) {
+			else if (matches(*argv, "help") == 0) {
 				NEXT_ARG();
 			}
 			if (dst_ok)
@@ -370,7 +370,7 @@
 			if (strcmp(*argv, "to") == 0) {
 				NEXT_ARG();
 			}
-			if (matches(*argv, "help") == 0)
+			else if (matches(*argv, "help") == 0)
 				usage();
 			get_prefix(&filter.pfx, *argv, filter.family);
 			if (filter.family == AF_UNSPEC)
diff -urN iproute2-3.11.0.orig/ip/iproute.c iproute2-3.11.0/ip/iproute.c
--- iproute2-3.11.0.orig/ip/iproute.c	2013-09-03 17:23:03.000000000 +0200
+++ iproute2-3.11.0/ip/iproute.c	2013-12-03 20:34:45.000000000 +0100
@@ -951,10 +951,12 @@
 			NEXT_ARG();
 			d = *argv;
 		} else {
+			int has_to = 0;
 			int type;
 			inet_prefix dst;
 
 			if (strcmp(*argv, "to") == 0) {
+				has_to = 1;
 				NEXT_ARG();
 			}
 			if ((**argv < '0' || **argv > '9') &&
@@ -963,7 +965,7 @@
 				req.r.rtm_type = type;
 			}
 
-			if (matches(*argv, "help") == 0)
+			if (!has_to && matches(*argv, "help") == 0)
 				usage();
 			if (dst_ok)
 				duparg2("to", *argv);
@@ -1414,8 +1416,6 @@
 		} else if (matches(*argv, "from") == 0) {
 			inet_prefix addr;
 			NEXT_ARG();
-			if (matches(*argv, "help") == 0)
-				usage();
 			from_ok = 1;
 			get_prefix(&addr, *argv, req.r.rtm_family);
 			if (req.r.rtm_family == AF_UNSPEC)
@@ -1442,7 +1442,7 @@
 			if (strcmp(*argv, "to") == 0) {
 				NEXT_ARG();
 			}
-			if (matches(*argv, "help") == 0)
+			else if (matches(*argv, "help") == 0)
 				usage();
 			get_prefix(&addr, *argv, req.r.rtm_family);
 			if (req.r.rtm_family == AF_UNSPEC)
diff -urN iproute2-3.11.0.orig/ip/iprule.c iproute2-3.11.0/ip/iprule.c
--- iproute2-3.11.0.orig/ip/iprule.c	2013-09-03 17:23:03.000000000 +0200
+++ iproute2-3.11.0/ip/iprule.c	2013-12-03 20:34:45.000000000 +0100
@@ -331,7 +331,7 @@
 			}
 			if (matches(*argv, "help") == 0)
 				usage();
-			else if (matches(*argv, "goto") == 0) {
+			if (matches(*argv, "goto") == 0) {
 				__u32 target;
 				type = FR_ACT_GOTO;
 				NEXT_ARG();

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

* Re: [PATCH iproute2] ip link: Do not show help if 'dev he' was specified
  2015-03-15 10:24 ` Christoph Schulz
@ 2015-03-15 10:38   ` Vadim Kochan
  2015-03-15 11:42     ` Christoph Schulz
  0 siblings, 1 reply; 5+ messages in thread
From: Vadim Kochan @ 2015-03-15 10:38 UTC (permalink / raw)
  To: Christoph Schulz; +Cc: Vadim Kochan, netdev, leonhard

On Sun, Mar 15, 2015 at 11:24:10AM +0100, Christoph Schulz wrote:
> Hello!
> 
> On 15.03.2015 09:01, Vadim Kochan wrote:
> > From: Vadim Kochan <vadim4j@gmail.com>
> > 
> > Date: Sun, 15 Mar 2015 09:11:41 +0200
> > Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
> > Reported-by: Leonhard Preis <leonhard@pre.is>
> > ---
> >  ip/ipaddress.c | 3 +--
> >  ip/iplink.c    | 6 ++----
> >  2 files changed, 3 insertions(+), 6 deletions(-)
> 
> We use a similar patch at the fli4l router project, but we also modified other files (ip6tunnel.c, ipmaddr.c, ipmroute.c, ipneigh.c, iproute.c, iprule.c). I'm afraid the patch is based on iproute2 3.11.0, but it applies to 3.17.0 (the version we currently use).
> 
> I attach the patch in the hope it will prove useful, perhaps as a base for a follow-up patch of yours.
> 
> 
> Best regards,
> 
> Christoph Schulz
> 

Hi,

It applies on my local master but I did not test it,
so you can re-send it as a complete fix instead of my ?

Thanks,

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

* Re: [PATCH iproute2] ip link: Do not show help if 'dev he' was specified
  2015-03-15 11:42     ` Christoph Schulz
@ 2015-03-15 11:35       ` Vadim Kochan
  0 siblings, 0 replies; 5+ messages in thread
From: Vadim Kochan @ 2015-03-15 11:35 UTC (permalink / raw)
  To: Christoph Schulz; +Cc: Vadim Kochan, netdev, leonhard

On Sun, Mar 15, 2015 at 12:42:54PM +0100, Christoph Schulz wrote:
> Hello!
> 
> Vadim Kochan schrieb am Sun, 15 Mar 2015 12:38:31 +0200:
> 
> >It applies on my local master but I did not test it,
> >so you can re-send it as a complete fix instead of my ?
> 
> Will do.
> 
> 
> Regards,
> 
> Christoph Schulz
> 

OK, then I will reject my patch from patchwork.

Thanks,

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

* Re: [PATCH iproute2] ip link: Do not show help if 'dev he' was specified
  2015-03-15 10:38   ` Vadim Kochan
@ 2015-03-15 11:42     ` Christoph Schulz
  2015-03-15 11:35       ` Vadim Kochan
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Schulz @ 2015-03-15 11:42 UTC (permalink / raw)
  To: Vadim Kochan; +Cc: netdev, leonhard

Hello!

Vadim Kochan schrieb am Sun, 15 Mar 2015 12:38:31 +0200:

> It applies on my local master but I did not test it,
> so you can re-send it as a complete fix instead of my ?

Will do.


Regards,

Christoph Schulz

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

end of thread, other threads:[~2015-03-15 11:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-15  8:01 [PATCH iproute2] ip link: Do not show help if 'dev he' was specified Vadim Kochan
2015-03-15 10:24 ` Christoph Schulz
2015-03-15 10:38   ` Vadim Kochan
2015-03-15 11:42     ` Christoph Schulz
2015-03-15 11:35       ` Vadim Kochan

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