Project

General

Profile

Bug #7302 » 6e9761a3afe1e9f6332bb0254890eeaf00a7806e.patch.txt

Andy Fiddaman, 2018-05-11 08:50 AM

 
1
From 6e9761a3afe1e9f6332bb0254890eeaf00a7806e Mon Sep 17 00:00:00 2001
2
From: Andy Fiddaman <omnios@citrus-it.co.uk>
3
Date: Fri, 11 May 2018 08:43:47 +0000
4
Subject: [PATCH] 7302 netstat -rn does not print default routes as numeric
5

    
6
---
7
 usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c | 24 +++++++++++++++++++++---
8
 1 file changed, 21 insertions(+), 3 deletions(-)
9

    
10
diff --git a/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c b/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c
11
index 475e915b2e7..83aa20f7553 100644
12
--- a/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c
13
+++ b/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c
14
@@ -5915,7 +5915,10 @@ pr_prefix6(const struct in6_addr *addr, uint_t prefixlen, char *dst,
15
 	char *cp;
16
 
17
 	if (IN6_IS_ADDR_UNSPECIFIED(addr) && prefixlen == 0) {
18
-		(void) strncpy(dst, "default", dstlen);
19
+		if (Nflag)
20
+			(void) strlcpy(dst, "::/0", dstlen);
21
+		else
22
+			(void) strlcpy(dst, "default", dstlen);
23
 		dst[dstlen - 1] = 0;
24
 		return (dst);
25
 	}
26
@@ -6048,7 +6051,14 @@ pr_net(uint_t addr, uint_t mask, char *dst, uint_t dstlen)
27
 					/* -2 == Noncontiguous mask... */
28
 
29
 	if (addr == INADDR_ANY && mask == INADDR_ANY) {
30
-		(void) strlcpy(dst, "default", dstlen);
31
+		if (Nflag) {
32
+			(void) strlcpy(dst, "0.0.0.0", dstlen);
33
+			if (CIDRflag)
34
+				(void) strlcat(dst, "/0", dstlen);
35
+		}
36
+		else {
37
+			(void) strlcpy(dst, "default", dstlen);
38
+		}
39
 		return (dst);
40
 	}
41
 
42
@@ -6133,8 +6143,16 @@ pr_netaddr(uint_t addr, uint_t mask, char *dst, uint_t dstlen)
43
 
44
 	addr = ntohl(addr);
45
 	mask = ntohl(mask);
46
+
47
 	if (addr == INADDR_ANY && mask == INADDR_ANY) {
48
-		(void) strlcpy(dst, "default", dstlen);
49
+		if (Nflag) {
50
+			(void) strlcpy(dst, "0.0.0.0", dstlen);
51
+			if (CIDRflag)
52
+				(void) strlcat(dst, "/0", dstlen);
53
+		}
54
+		else {
55
+			(void) strlcpy(dst, "default", dstlen);
56
+		}
57
 		return (dst);
58
 	}
59
 
(2-2/2)