All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next iproute2] support batching of ip route get commands
@ 2015-07-16  0:06 Roopa Prabhu
  2015-07-20 21:56 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Roopa Prabhu @ 2015-07-16  0:06 UTC (permalink / raw)
  To: stephen; +Cc: netdev

From: Roopa Prabhu <roopa@cumulusnetworks.com>

This patch replaces exits with returns in
ip route get command handling. This allows batching
of ip route get commands.

$cat route_get_batch.txt
route get 10.0.14.2
route get 12.0.14.2
route get 10.0.14.4

$ip -batch route_get_batch.txt
local 10.0.14.2 dev lo  src 10.0.14.2
    cache <local>
12.0.14.2 via 192.168.0.2 dev eth0  src 192.168.0.15
    cache
10.0.14.4 dev dummy0  src 10.0.14.2
    cache

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
---
 ip/iproute.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ip/iproute.c b/ip/iproute.c
index 41dea8f..8f49e62 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -1682,15 +1682,15 @@ static int iproute_get(int argc, char **argv)
 		req.n.nlmsg_type = RTM_GETROUTE;
 
 		if (rtnl_talk(&rth, &req.n, &req.n, sizeof(req)) < 0)
-			exit(2);
+			return -2;
 	}
 
 	if (print_route(NULL, &req.n, (void*)stdout) < 0) {
 		fprintf(stderr, "An error :-)\n");
-		exit(1);
+		return -1;
 	}
 
-	exit(0);
+	return 0;
 }
 
 static int restore_handler(const struct sockaddr_nl *nl,
-- 
1.7.10.4

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

* Re: [PATCH net-next iproute2] support batching of ip route get commands
  2015-07-16  0:06 [PATCH net-next iproute2] support batching of ip route get commands Roopa Prabhu
@ 2015-07-20 21:56 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2015-07-20 21:56 UTC (permalink / raw)
  To: Roopa Prabhu; +Cc: netdev

On Wed, 15 Jul 2015 17:06:36 -0700
Roopa Prabhu <roopa@cumulusnetworks.com> wrote:

> From: Roopa Prabhu <roopa@cumulusnetworks.com>
> 
> This patch replaces exits with returns in
> ip route get command handling. This allows batching
> of ip route get commands.
> 
> $cat route_get_batch.txt
> route get 10.0.14.2
> route get 12.0.14.2
> route get 10.0.14.4
> 
> $ip -batch route_get_batch.txt
> local 10.0.14.2 dev lo  src 10.0.14.2
>     cache <local>
> 12.0.14.2 via 192.168.0.2 dev eth0  src 192.168.0.15
>     cache
> 10.0.14.4 dev dummy0  src 10.0.14.2
>     cache
> 
> Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>

Looks good and simple, applied.

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

end of thread, other threads:[~2015-07-20 21:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-16  0:06 [PATCH net-next iproute2] support batching of ip route get commands Roopa Prabhu
2015-07-20 21:56 ` Stephen Hemminger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.