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