diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2017-03-21 06:23:49 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2017-03-21 06:23:49 +0000 |
commit | 0fc205df36973c744f5b92301e4394d9cfa4cd7b (patch) | |
tree | 155642d83502980b9a07967d37fdbae8a3f10d92 | |
parent | 4b62eeeaba83701e5873234dcbc89459dacef478 (diff) |
getnameinfo errors should go to stderr & should print what's going on.
Pointed out by & ok bluhm
While here print prefixlen with %u, pointed out by bluhm, too.
-rw-r--r-- | sbin/route/route.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c index cf1f183308d..74d62221faa 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.198 2017/03/20 19:01:38 florian Exp $ */ +/* $OpenBSD: route.c,v 1.199 2017/03/21 06:23:48 florian Exp $ */ /* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */ /* @@ -2074,7 +2074,7 @@ print_rtstatic(struct sockaddr_rtstatic *rtstatic) struct in6_addr prefix; struct in_addr dest, gateway; size_t srclen, offset; - int bits, bytes; + int bits, bytes, error; uint8_t prefixlen; unsigned char *src = rtstatic->sr_static; char ntoabuf[INET_ADDRSTRLEN]; @@ -2132,13 +2132,14 @@ print_rtstatic(struct sockaddr_rtstatic *rtstatic) srclen -= sizeof(gateway6); src += sizeof(gateway6); - if (getnameinfo((struct sockaddr *)&gateway6, + if ((error = getnameinfo((struct sockaddr *)&gateway6, gateway6.sin6_len, hbuf, sizeof(hbuf), NULL, 0, - NI_NUMERICHOST | NI_NUMERICSERV)) { - printf("cannot get gateway address"); + NI_NUMERICHOST | NI_NUMERICSERV))) { + warnx("cannot get gateway address: %s", + gai_strerror(error)); return; } - printf("%s/%hhu %s ", inet_ntop(AF_INET6, &prefix, + printf("%s/%u %s ", inet_ntop(AF_INET6, &prefix, ntopbuf, INET6_ADDRSTRLEN), prefixlen, hbuf); } break; |