[PATCH 3/4] If 'route' fails, log its exit status.
Richard Kettlewell
rjk at terraraq.org.uk
Wed Jul 6 21:19:26 BST 2011
From: Richard Kettlewell <rjk at greenend.org.uk>
Signed-off-by: Richard Kettlewell <rjk at greenend.org.uk>
---
tun.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/tun.c b/tun.c
index 7d1053a..8728676 100644
--- a/tun.c
+++ b/tun.c
@@ -148,7 +148,7 @@ static bool_t tun_set_route(void *sst, struct netlink_client *routes)
string_t network, mask, secnetaddr;
struct subnet_list *nets;
int32_t i;
- int fd=-1;
+ int fd=-1, rv;
if (routes->up == routes->kup) return False;
if (st->route_type==TUN_CONFIG_IOCTL) {
@@ -174,17 +174,17 @@ static bool_t tun_set_route(void *sst, struct netlink_client *routes)
nets->list[i].len,routes->up?"to":"from");
switch (st->route_type) {
case TUN_CONFIG_LINUX:
- sys_cmd(st->route_path,"route",routes->up?"add":"del",
- "-net",network,"netmask",mask,
- "gw",secnetaddr,(char *)0);
+ rv = sys_cmd(st->route_path,"route",routes->up?"add":"del",
+ "-net",network,"netmask",mask,
+ "gw",secnetaddr,(char *)0);
break;
case TUN_CONFIG_BSD:
- sys_cmd(st->route_path,"route",routes->up?"add":"del",
- "-net",network,secnetaddr,mask,(char *)0);
+ rv = sys_cmd(st->route_path,"route",routes->up?"add":"del",
+ "-net",network,secnetaddr,mask,(char *)0);
break;
case TUN_CONFIG_SOLARIS25:
- sys_cmd(st->route_path,"route",routes->up?"add":"del",
- network,secnetaddr,(char *)0);
+ rv = sys_cmd(st->route_path,"route",routes->up?"add":"del",
+ network,secnetaddr,(char *)0);
break;
case TUN_CONFIG_IOCTL:
{
@@ -209,6 +209,7 @@ static bool_t tun_set_route(void *sst, struct netlink_client *routes)
if (ioctl(fd,action,&rt)<0) {
fatal_perror("tun_set_route: ioctl()");
}
+ rv = 0;
#else
fatal("tun_set_route: ioctl method not supported");
#endif
@@ -218,6 +219,8 @@ static bool_t tun_set_route(void *sst, struct netlink_client *routes)
fatal("tun_set_route: unsupported route command type");
break;
}
+ if(rv != 0)
+ Message(M_ERR, "tun_set_route: route exited with status %#x\n", rv);
free(network); free(mask);
}
free(secnetaddr);
--
1.6.4.2
More information about the sgo-software-discuss
mailing list