Blame SOURCES/0142-ss-use-for-any-address-any-family-sockets.patch

36cfb7
From 04453080a3a92071227fd79a039137f72fa82e15 Mon Sep 17 00:00:00 2001
36cfb7
From: Andrea Claudi <aclaudi@redhat.com>
36cfb7
Date: Wed, 12 Jun 2019 15:00:33 +0200
36cfb7
Subject: [PATCH] ss: use [::] for any address/any family sockets
36cfb7
36cfb7
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1588122
36cfb7
Upstream Status: RHEL-only
36cfb7
36cfb7
commit d981824803999a339f4b8fb9ad36d9d5990d9eab
36cfb7
Author: Andrea Claudi <aclaudi@redhat.com>
36cfb7
Date:   Wed Jun 12 14:49:07 2019 +0200
36cfb7
36cfb7
    ss: use [::] for any address/any family sockets
36cfb7
36cfb7
    commit aba9c23a6e1cb ("ss: enclose IPv6 address in brackets")
36cfb7
    brings in the unintended side effect of showing as "*" sockets
36cfb7
    listening to any address in any family. This is consistent with
36cfb7
    upstream iproute and RHEL 8 iproute version, but not with
36cfb7
    previous versions of RHEL 7 iproute.
36cfb7
36cfb7
    This commit partially reverts aba9c23a6e1cb using "[::]" for
36cfb7
    any family sockets when -f inet6 is used.
36cfb7
36cfb7
    Tested with
36cfb7
    # ss -ln -f inet6
36cfb7
36cfb7
    ("ss: enclose IPv6 address in brackets")
36cfb7
---
36cfb7
 misc/ss.c | 29 ++++++++++++-----------------
36cfb7
 1 file changed, 12 insertions(+), 17 deletions(-)
36cfb7
36cfb7
diff --git a/misc/ss.c b/misc/ss.c
36cfb7
index 6aaae1b5390e4..8f184fb929d31 100644
36cfb7
--- a/misc/ss.c
36cfb7
+++ b/misc/ss.c
36cfb7
@@ -1090,25 +1090,20 @@ static void inet_addr_print(const inet_prefix *a, int port, unsigned int ifindex
36cfb7
 			ap = format_host(AF_INET, 4, a->data);
36cfb7
 		}
36cfb7
 	} else {
36cfb7
-		if (!memcmp(a->data, &in6addr_any, sizeof(in6addr_any))) {
36cfb7
-			buf[0] = '*';
36cfb7
-			buf[1] = 0;
36cfb7
-		} else {
36cfb7
-			ap = format_host(a->family, 16, a->data);
36cfb7
-
36cfb7
-			/* Numeric IPv6 addresses should be bracketed */
36cfb7
-			if (strchr(ap, ':')) {
36cfb7
-				snprintf(buf, sizeof(buf),
36cfb7
-					 "[%s]", ap);
36cfb7
-				ap = buf;
36cfb7
-			}
36cfb7
+		ap = format_host(a->family, 16, a->data);
36cfb7
 
36cfb7
-			est_len = strlen(ap);
36cfb7
-			if (est_len <= addr_width)
36cfb7
-				est_len = addr_width;
36cfb7
-			else
36cfb7
-				est_len = addr_width + ((est_len-addr_width+3)/4)*4;
36cfb7
+		/* Numeric IPv6 addresses should be bracketed */
36cfb7
+		if (strchr(ap, ':')) {
36cfb7
+			snprintf(buf, sizeof(buf),
36cfb7
+				 "[%s]", ap);
36cfb7
+			ap = buf;
36cfb7
 		}
36cfb7
+
36cfb7
+		est_len = strlen(ap);
36cfb7
+		if (est_len <= addr_width)
36cfb7
+			est_len = addr_width;
36cfb7
+		else
36cfb7
+			est_len = addr_width + ((est_len-addr_width+3)/4)*4;
36cfb7
 	}
36cfb7
 
36cfb7
 	if (ifindex) {
36cfb7
-- 
36cfb7
2.20.1
36cfb7