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