naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone

Blame SOURCES/0006-ss-Fix-for-added-diag-support-check.patch

cd1737
From 2dc48cc4101b9788dcafd38b07a82f8c91b4d3f6 Mon Sep 17 00:00:00 2001
cd1737
From: Phil Sutter <psutter@redhat.com>
cd1737
Date: Thu, 31 Aug 2017 14:23:11 +0200
cd1737
Subject: [PATCH] ss: Fix for added diag support check
cd1737
cd1737
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1487152
cd1737
Upstream Status: iproute2.git commit 6c6bbc30f4e7f
cd1737
cd1737
commit 6c6bbc30f4e7fedc74381627f7ec86d26050b404
cd1737
Author: Phil Sutter <phil@nwl.cc>
cd1737
Date:   Mon Aug 28 19:31:22 2017 +0200
cd1737
cd1737
    ss: Fix for added diag support check
cd1737
cd1737
    Commit 9f66764e308e9 ("libnetlink: Add test for error code returned from
cd1737
    netlink reply") changed rtnl_dump_filter_l() to return an error in case
cd1737
    NLMSG_DONE would contain one, even if it was ENOENT.
cd1737
cd1737
    This in turn breaks ss when it tries to dump DCCP sockets on a system
cd1737
    without support for it: The function tcp_show(), which is shared between
cd1737
    TCP and DCCP, will start parsing /proc since inet_show_netlink() returns
cd1737
    an error - yet it parses /proc/net/tcp which doesn't make sense for DCCP
cd1737
    sockets at all.
cd1737
cd1737
    On my system, a call to 'ss' without further arguments prints the list
cd1737
    of connected TCP sockets twice.
cd1737
cd1737
    Fix this by introducing a dedicated function dccp_show() which does not
cd1737
    have a fallback to /proc, just like sctp_show(). And since tcp_show()
cd1737
    is no longer "multi-purpose", drop it's socktype parameter.
cd1737
cd1737
    Fixes: 9f66764e308e9 ("libnetlink: Add test for error code returned from netlink reply")
cd1737
    Signed-off-by: Phil Sutter <phil@nwl.cc>
cd1737
---
cd1737
 misc/ss.c | 20 ++++++++++++++++----
cd1737
 1 file changed, 16 insertions(+), 4 deletions(-)
cd1737
cd1737
diff --git a/misc/ss.c b/misc/ss.c
cd1737
index 12763c9..b84baf3 100644
cd1737
--- a/misc/ss.c
cd1737
+++ b/misc/ss.c
cd1737
@@ -2735,7 +2735,7 @@ static int tcp_show_netlink_file(struct filter *f)
cd1737
 	}
cd1737
 }
cd1737
 
cd1737
-static int tcp_show(struct filter *f, int socktype)
cd1737
+static int tcp_show(struct filter *f)
cd1737
 {
cd1737
 	FILE *fp = NULL;
cd1737
 	char *buf = NULL;
cd1737
@@ -2750,7 +2750,7 @@ static int tcp_show(struct filter *f, int socktype)
cd1737
 		return tcp_show_netlink_file(f);
cd1737
 
cd1737
 	if (!getenv("PROC_NET_TCP") && !getenv("PROC_ROOT")
cd1737
-	    && inet_show_netlink(f, NULL, socktype) == 0)
cd1737
+	    && inet_show_netlink(f, NULL, IPPROTO_TCP) == 0)
cd1737
 		return 0;
cd1737
 
cd1737
 	/* Sigh... We have to parse /proc/net/tcp... */
cd1737
@@ -2818,6 +2818,18 @@ outerr:
cd1737
 	} while (0);
cd1737
 }
cd1737
 
cd1737
+static int dccp_show(struct filter *f)
cd1737
+{
cd1737
+	if (!filter_af_get(f, AF_INET) && !filter_af_get(f, AF_INET6))
cd1737
+		return 0;
cd1737
+
cd1737
+	if (!getenv("PROC_NET_DCCP") && !getenv("PROC_ROOT")
cd1737
+	    && inet_show_netlink(f, NULL, IPPROTO_DCCP) == 0)
cd1737
+		return 0;
cd1737
+
cd1737
+	return 0;
cd1737
+}
cd1737
+
cd1737
 static int sctp_show(struct filter *f)
cd1737
 {
cd1737
 	if (!filter_af_get(f, AF_INET) && !filter_af_get(f, AF_INET6))
cd1737
@@ -4368,9 +4380,9 @@ int main(int argc, char *argv[])
cd1737
 	if (current_filter.dbs & (1<
cd1737
 		udp_show(&current_filter);
cd1737
 	if (current_filter.dbs & (1<
cd1737
-		tcp_show(&current_filter, IPPROTO_TCP);
cd1737
+		tcp_show(&current_filter);
cd1737
 	if (current_filter.dbs & (1<
cd1737
-		tcp_show(&current_filter, IPPROTO_DCCP);
cd1737
+		dccp_show(&current_filter);
cd1737
 	if (current_filter.dbs & (1<
cd1737
 		sctp_show(&current_filter);
cd1737
 
cd1737
-- 
cd1737
1.8.3.1
cd1737