Skip to contentSkip to conversation

support batching of ip route get commands

PATCH In review Roopa Prabhu 2 participants 2 messages Jul 16, 2015 – Jul 20, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 support batching of ip route get commands

From: Roopa Prabhu <[email protected]>

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

---
 ip/iproute.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
ip/iproute.c +3 -3
index 41dea8f..8f49e62 100644
@@ -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,
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 19 lines · On Wed, 15 Jul 2015 17:06:36 -0700 Roopa Prabhu <[email protected]>…

From: Roopa Prabhu <[email protected]>

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

Quoted 1 line

Looks good and simple, applied.