mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-06 16:40:47 +00:00
route(8): fix route not found
exit code and warn with netlink
Fix route(8) incorrectly returning a zero exit code even when unable to find the specified route with route -n get <route>. Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D41882
This commit is contained in:
parent
2ccfa855b2
commit
2a78083fc2
|
@ -271,22 +271,27 @@ rtmsg_nl_int(struct nl_helper *h, int cmd, int rtm_flags, int fib, int rtm_addrs
|
|||
|
||||
hdr = snl_read_reply(ss, hdr->nlmsg_seq);
|
||||
if (nl_type == NL_RTM_GETROUTE) {
|
||||
if (hdr->nlmsg_type == NL_RTM_NEWROUTE)
|
||||
if (hdr->nlmsg_type == NL_RTM_NEWROUTE) {
|
||||
print_getmsg(h, hdr, dst);
|
||||
else {
|
||||
snl_parse_errmsg(ss, hdr, &e);
|
||||
if (e.error == ESRCH)
|
||||
warn("route has not been found");
|
||||
else
|
||||
warn("message indicates error %d", e.error);
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (snl_parse_errmsg(ss, hdr, &e))
|
||||
if (snl_parse_errmsg(ss, hdr, &e)) {
|
||||
switch (e.error) {
|
||||
case (ESRCH):
|
||||
warnx("route has not been found");
|
||||
break;
|
||||
default:
|
||||
if (e.error == 0)
|
||||
break;
|
||||
warnc(e.error, "message indicates error");
|
||||
}
|
||||
|
||||
return (e.error);
|
||||
}
|
||||
}
|
||||
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue