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

99be8f
From 04453080a3a92071227fd79a039137f72fa82e15 Mon Sep 17 00:00:00 2001
99be8f
From: Andrea Claudi <aclaudi@redhat.com>
99be8f
Date: Wed, 12 Jun 2019 15:00:33 +0200
99be8f
Subject: [PATCH] ss: use [::] for any address/any family sockets
99be8f
99be8f
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1588122
99be8f
Upstream Status: RHEL-only
99be8f
99be8f
commit d981824803999a339f4b8fb9ad36d9d5990d9eab
99be8f
Author: Andrea Claudi <aclaudi@redhat.com>
99be8f
Date:   Wed Jun 12 14:49:07 2019 +0200
99be8f
99be8f
    ss: use [::] for any address/any family sockets
99be8f
99be8f
    commit aba9c23a6e1cb ("ss: enclose IPv6 address in brackets")
99be8f
    brings in the unintended side effect of showing as "*" sockets
99be8f
    listening to any address in any family. This is consistent with
99be8f
    upstream iproute and RHEL 8 iproute version, but not with
99be8f
    previous versions of RHEL 7 iproute.
99be8f
99be8f
    This commit partially reverts aba9c23a6e1cb using "[::]" for
99be8f
    any family sockets when -f inet6 is used.
99be8f
99be8f
    Tested with
99be8f
    # ss -ln -f inet6
99be8f
99be8f
    ("ss: enclose IPv6 address in brackets")
99be8f
---
99be8f
 misc/ss.c | 29 ++++++++++++-----------------
99be8f
 1 file changed, 12 insertions(+), 17 deletions(-)
99be8f
99be8f
diff --git a/misc/ss.c b/misc/ss.c
99be8f
index 6aaae1b5390e4..8f184fb929d31 100644
99be8f
--- a/misc/ss.c
99be8f
+++ b/misc/ss.c
99be8f
@@ -1090,25 +1090,20 @@ 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
-		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
+		ap = format_host(a->family, 16, a->data);
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
+		/* 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
 	if (ifindex) {
99be8f
-- 
99be8f
2.20.1
99be8f