Todd C. Miller wrote:
> On Thu, 23 Jun 2016 13:13:57 -0400, "Ted Unangst" wrote:
>
> > # route delete 1.1.1.1
> > route: writing to routing socket: No such process
> > delete host 1.1.1.1: not in table
> >
> > The first error is unnecessary and misleading. It comes from the rtmsg()
> > function, but another error will be printed by the caller, which will also
> > perform correct errno translation.
>
> With this change no warning will be written for "route get". Is that
> desirable? Perhaps the warning should just be moved, ala:
>
> if (*cmd == 'g') {
> if (qflag == 0)
> warn("writing to routing socket");
> exit(0);
yes, i think the caller should do the most checking.
(there is still a warning in rtmsg() for reading, but it will return 0 even
for failure in that case, so no double warning.)
Index: route.c
===================================================================
RCS file: /cvs/src/sbin/route/route.c,v
retrieving revision 1.183
diff -u -p -r1.183 route.c
--- route.c 7 Jun 2016 01:29:38 -0000 1.183
+++ route.c 23 Jun 2016 17:44:46 -0000
@@ -644,8 +644,11 @@ newroute(int argc, char **argv)
} else
break;
}
- if (*cmd == 'g')
+ 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);
@@ -1165,8 +1168,6 @@ rtmsg(int cmd, int flags, int fmask, uin
if (debugonly)
return (0);
if (write(s, &m_rtmsg, l) != l) {
- if (qflag == 0)
- warn("writing to routing socket");
return (-1);
}
if (cmd == RTM_GET) {