mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01: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>.
PR: 274426
Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D41882
(cherry picked from commit 2a78083fc2)
This commit is contained in:
1 parent
00d474e242
commit
eb80809883
1 file changed
+15
-10
+15
-10
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user