aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorHiroki Sato <hrs@FreeBSD.org>2013-07-20 15:58:43 +0000
committerHiroki Sato <hrs@FreeBSD.org>2013-07-20 15:58:43 +0000
commitb3e0158e5905bfc55b8777b7be90610949631ff0 (patch)
tree40788aa54cb59789ba39431c85998bc7479bc5ef /sbin
parent74ff9accb4f3757d3f2bf80c4a7f169149d203aa (diff)
downloadsrc-b3e0158e5905bfc55b8777b7be90610949631ff0.tar.gz
src-b3e0158e5905bfc55b8777b7be90610949631ff0.zip
Show "default" for the zero-filled address consistently when nflag == 0.
Notes
Notes: svn path=/head/; revision=253503
Diffstat (limited to 'sbin')
-rw-r--r--sbin/route/route.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c
index 4e218b4fba07..6da4deb8548b 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -511,10 +511,8 @@ routename(struct sockaddr *sa)
domain[0] = '\0';
}
- if (sa->sa_len == 0) {
- strcpy(line, "default");
- return (line);
- }
+ if (sa->sa_len == 0 && nflag == 0)
+ return ("default");
switch (sa->sa_family) {
#ifdef INET
case AF_INET:
@@ -523,9 +521,9 @@ routename(struct sockaddr *sa)
in = ((struct sockaddr_in *)(void *)sa)->sin_addr;
cp = NULL;
- if (in.s_addr == INADDR_ANY || sa->sa_len < 4)
- cp = "default";
- if (cp == NULL && !nflag) {
+ if (in.s_addr == INADDR_ANY && nflag == 0)
+ return ("default");
+ if (nflag != 0) {
hp = gethostbyaddr((char *)&in, sizeof (struct in_addr),
AF_INET);
if (hp != NULL) {
@@ -552,6 +550,10 @@ routename(struct sockaddr *sa)
struct sockaddr_in6 sin6; /* use static var for safety */
int niflags = 0;
+ /* Check if the address is ::. If true, use "default". */
+ if (nflag == 0 &&
+ IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *)(void *)sa)->sin6_addr))
+ return("default");
memset(&sin6, 0, sizeof(sin6));
memcpy(&sin6, sa, sa->sa_len);
sin6.sin6_len = sizeof(struct sockaddr_in6);
@@ -1712,13 +1714,8 @@ print_getmsg(struct rt_msghdr *rtm, int msglen, int fib)
mask->sa_family = dst->sa_family; /* XXX */
if (dst)
(void)printf("destination: %s\n", routename(dst));
- if (mask) {
- int savenflag = nflag;
-
- nflag = 1;
+ if (mask)
(void)printf(" mask: %s\n", routename(mask));
- nflag = savenflag;
- }
if (gate && rtm->rtm_flags & RTF_GATEWAY)
(void)printf(" gateway: %s\n", routename(gate));
if (fib >= 0)