{"id":806674,"url":"http://patchwork.ozlabs.org/api/1.0/patches/806674/?format=json","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.0/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20170828173122.11458-1-phil@nwl.cc>","date":"2017-08-28T17:31:22","name":"[iproute] ss: Fix for added diag support check","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"dd96ac655acc59477dffb6c36d7d69d52ddb92ee","submitter":{"id":4285,"url":"http://patchwork.ozlabs.org/api/1.0/people/4285/?format=json","name":"Phil Sutter","email":"phil@nwl.cc"},"delegate":{"id":389,"url":"http://patchwork.ozlabs.org/api/1.0/users/389/?format=json","username":"shemminger","first_name":"stephen","last_name":"hemminger","email":"shemminger@vyatta.com"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170828173122.11458-1-phil@nwl.cc/mbox/","series":[{"id":223,"url":"http://patchwork.ozlabs.org/api/1.0/series/223/?format=json","date":"2017-08-28T17:31:22","name":"[iproute] ss: Fix for added diag support check","version":1,"mbox":"http://patchwork.ozlabs.org/series/223/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/806674/checks/","tags":{},"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xgzMs2Wvmz9sMN\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 29 Aug 2017 03:31:37 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751425AbdH1Rbf (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 28 Aug 2017 13:31:35 -0400","from orbyte.nwl.cc ([151.80.46.58]:47593 \"EHLO mail.nwl.cc\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751269AbdH1Rbe (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tMon, 28 Aug 2017 13:31:34 -0400","from mail.nwl.cc (orbyte.nwl.cc [127.0.0.1])\n\tby mail.nwl.cc (Postfix) with ESMTP id 8842665A5E;\n\tMon, 28 Aug 2017 19:31:33 +0200 (CEST)","from xsao (localhost [IPv6:::1])\n\tby mail.nwl.cc (Postfix) with ESMTP id 68472644CF;\n\tMon, 28 Aug 2017 19:31:33 +0200 (CEST)"],"From":"Phil Sutter <phil@nwl.cc>","To":"Stephen Hemminger <stephen@networkplumber.org>","Cc":"netdev@vger.kernel.org","Subject":"[iproute PATCH] ss: Fix for added diag support check","Date":"Mon, 28 Aug 2017 19:31:22 +0200","Message-Id":"<20170828173122.11458-1-phil@nwl.cc>","X-Mailer":"git-send-email 2.13.1","X-Virus-Scanned":"ClamAV using ClamSMTP","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"Commit 9f66764e308e9 (\"libnetlink: Add test for error code returned from\nnetlink reply\") changed rtnl_dump_filter_l() to return an error in case\nNLMSG_DONE would contain one, even if it was ENOENT.\n\nThis in turn breaks ss when it tries to dump DCCP sockets on a system\nwithout support for it: The function tcp_show(), which is shared between\nTCP and DCCP, will start parsing /proc since inet_show_netlink() returns\nan error - yet it parses /proc/net/tcp which doesn't make sense for DCCP\nsockets at all.\n\nOn my system, a call to 'ss' without further arguments prints the list\nof connected TCP sockets twice.\n\nFix this by introducing a dedicated function dccp_show() which does not\nhave a fallback to /proc, just like sctp_show(). And since tcp_show()\nis no longer \"multi-purpose\", drop it's socktype parameter.\n\nFixes: 9f66764e308e9 (\"libnetlink: Add test for error code returned from netlink reply\")\nSigned-off-by: Phil Sutter <phil@nwl.cc>\n---\n misc/ss.c | 20 ++++++++++++++++----\n 1 file changed, 16 insertions(+), 4 deletions(-)","diff":"diff --git a/misc/ss.c b/misc/ss.c\nindex fcc3cf9282c49..2c9e80e696595 100644\n--- a/misc/ss.c\n+++ b/misc/ss.c\n@@ -2753,7 +2753,7 @@ static int tcp_show_netlink_file(struct filter *f)\n \treturn err;\n }\n \n-static int tcp_show(struct filter *f, int socktype)\n+static int tcp_show(struct filter *f)\n {\n \tFILE *fp = NULL;\n \tchar *buf = NULL;\n@@ -2768,7 +2768,7 @@ static int tcp_show(struct filter *f, int socktype)\n \t\treturn tcp_show_netlink_file(f);\n \n \tif (!getenv(\"PROC_NET_TCP\") && !getenv(\"PROC_ROOT\")\n-\t    && inet_show_netlink(f, NULL, socktype) == 0)\n+\t    && inet_show_netlink(f, NULL, IPPROTO_TCP) == 0)\n \t\treturn 0;\n \n \t/* Sigh... We have to parse /proc/net/tcp... */\n@@ -2836,6 +2836,18 @@ outerr:\n \t} while (0);\n }\n \n+static int dccp_show(struct filter *f)\n+{\n+\tif (!filter_af_get(f, AF_INET) && !filter_af_get(f, AF_INET6))\n+\t\treturn 0;\n+\n+\tif (!getenv(\"PROC_NET_DCCP\") && !getenv(\"PROC_ROOT\")\n+\t    && inet_show_netlink(f, NULL, IPPROTO_DCCP) == 0)\n+\t\treturn 0;\n+\n+\treturn 0;\n+}\n+\n static int sctp_show(struct filter *f)\n {\n \tif (!filter_af_get(f, AF_INET) && !filter_af_get(f, AF_INET6))\n@@ -4390,9 +4402,9 @@ int main(int argc, char *argv[])\n \tif (current_filter.dbs & (1<<UDP_DB))\n \t\tudp_show(&current_filter);\n \tif (current_filter.dbs & (1<<TCP_DB))\n-\t\ttcp_show(&current_filter, IPPROTO_TCP);\n+\t\ttcp_show(&current_filter);\n \tif (current_filter.dbs & (1<<DCCP_DB))\n-\t\ttcp_show(&current_filter, IPPROTO_DCCP);\n+\t\tdccp_show(&current_filter);\n \tif (current_filter.dbs & (1<<SCTP_DB))\n \t\tsctp_show(&current_filter);\n \n","prefixes":["iproute"]}