|
|
99be8f |
From 765baea7751f7140571dfb0285b1fca974b3450b Mon Sep 17 00:00:00 2001
|
|
|
99be8f |
From: Andrea Claudi <aclaudi@redhat.com>
|
|
|
99be8f |
Date: Mon, 29 Apr 2019 18:03:01 +0200
|
|
|
99be8f |
Subject: [PATCH] ss: enclose IPv6 address in brackets
|
|
|
99be8f |
|
|
|
99be8f |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1588122
|
|
|
99be8f |
Upstream Status: iproute2.git commit aba9c23a6e1cb
|
|
|
99be8f |
|
|
|
99be8f |
commit aba9c23a6e1cb134840c998df14888dca469a485
|
|
|
99be8f |
Author: Stephen Hemminger <stephen@networkplumber.org>
|
|
|
99be8f |
Date: Fri Aug 4 12:02:41 2017 -0700
|
|
|
99be8f |
|
|
|
99be8f |
ss: enclose IPv6 address in brackets
|
|
|
99be8f |
|
|
|
99be8f |
Based on patch by Lehner Florian <dev@der-flo.net>
|
|
|
99be8f |
|
|
|
99be8f |
Adds support for RFC2732 IPv6 address format with brackets.
|
|
|
99be8f |
|
|
|
99be8f |
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
|
|
|
99be8f |
---
|
|
|
99be8f |
misc/ss.c | 25 +++++++++++++++++++------
|
|
|
99be8f |
1 file changed, 19 insertions(+), 6 deletions(-)
|
|
|
99be8f |
|
|
|
99be8f |
diff --git a/misc/ss.c b/misc/ss.c
|
|
|
99be8f |
index c0cb33e96d9ec..86defc71fabc4 100644
|
|
|
99be8f |
--- a/misc/ss.c
|
|
|
99be8f |
+++ b/misc/ss.c
|
|
|
99be8f |
@@ -1093,12 +1093,25 @@ static void inet_addr_print(const inet_prefix *a, int port, unsigned int ifindex
|
|
|
99be8f |
ap = format_host(AF_INET, 4, a->data);
|
|
|
99be8f |
}
|
|
|
99be8f |
} else {
|
|
|
99be8f |
- ap = format_host(a->family, 16, a->data);
|
|
|
99be8f |
- est_len = strlen(ap);
|
|
|
99be8f |
- if (est_len <= addr_width)
|
|
|
99be8f |
- est_len = addr_width;
|
|
|
99be8f |
- else
|
|
|
99be8f |
- est_len = addr_width + ((est_len-addr_width+3)/4)*4;
|
|
|
99be8f |
+ if (!memcmp(a->data, &in6addr_any, sizeof(in6addr_any))) {
|
|
|
99be8f |
+ buf[0] = '*';
|
|
|
99be8f |
+ buf[1] = 0;
|
|
|
99be8f |
+ } else {
|
|
|
99be8f |
+ ap = format_host(a->family, 16, a->data);
|
|
|
99be8f |
+
|
|
|
99be8f |
+ /* Numeric IPv6 addresses should be bracketed */
|
|
|
99be8f |
+ if (strchr(ap, ':')) {
|
|
|
99be8f |
+ snprintf(buf, sizeof(buf),
|
|
|
99be8f |
+ "[%s]", ap);
|
|
|
99be8f |
+ ap = buf;
|
|
|
99be8f |
+ }
|
|
|
99be8f |
+
|
|
|
99be8f |
+ est_len = strlen(ap);
|
|
|
99be8f |
+ if (est_len <= addr_width)
|
|
|
99be8f |
+ est_len = addr_width;
|
|
|
99be8f |
+ else
|
|
|
99be8f |
+ est_len = addr_width + ((est_len-addr_width+3)/4)*4;
|
|
|
99be8f |
+ }
|
|
|
99be8f |
}
|
|
|
99be8f |
|
|
|
99be8f |
if (ifindex) {
|
|
|
99be8f |
--
|
|
|
d30c09 |
2.21.0
|
|
|
99be8f |
|