On 12/10/17(Thu) 00:22, Julien Dhaille wrote:
> Hi,
>
> when a default gateway is not set :
>
> # route get 4.4.4.4
> route: writing to routing socket: No such process
>
> this small patch uses oerrno translation :
>
> # route get 4.4.4.4
> get host 4.4.4.4: not in table
Nice, but there's no need to set oerrno, the line just below will do it.
Removing the if () block should do it. It introduces a small change in
behavior, route(8) now exists with an error code if an entry doesn't
exist in the table. That's a good thing, because one can now test if a
route is reachable by doing:
route -nq get 4.4.4.4 && echo "present"
Index: route.c
===================================================================
RCS file: /cvs/src/sbin/route/route.c,v
retrieving revision 1.203
diff -u -p -r1.203 route.c
--- route.c 6 Sep 2017 20:21:22 -0000 1.203
+++ route.c 16 Oct 2017 11:14:49 -0000
@@ -674,11 +674,6 @@ newroute(int argc, char **argv)
} else
break;
}
- if (*cmd == 'g') {
- if (ret != 0 && qflag == 0)
- warn("writing to routing socket");
- exit(0);
- }
oerrno = errno;
if (!qflag) {
printf("%s %s %s", cmd, ishost ? "host" : "net", dest);