lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180502202801.5255-6-stephen@networkplumber.org>
Date:   Wed,  2 May 2018 13:28:01 -0700
From:   Stephen Hemminger <stephen@...workplumber.org>
To:     netdev@...r.kernel.org
Cc:     Stephen Hemminger <sthemmin@...rosoft.com>,
        Stephen Hemminger <stephen@...workplumber.org>
Subject: [RFC iproute2-next 5/5] ss: use correct slab statistics

From: Stephen Hemminger <sthemmin@...rosoft.com>

The slabinfo names changed years ago, and ss statistics were broken.
This changes to use current slab names and handle TCP IPv6.

Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
---
 misc/ss.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/misc/ss.c b/misc/ss.c
index 97304cd8abfc..66c767cc415b 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -742,12 +742,12 @@ static int get_slabstat(struct slabstat *s)
 {
 	char buf[256];
 	FILE *fp;
-	int cnt;
+	int *stats = (int *) s;
 	static int slabstat_valid;
 	static const char * const slabstat_ids[] = {
-		"sock",
-		"tcp_tw_bucket",
-		"tcp_open_request",
+		"sock_inode_cache",
+		"tw_sock_TCP",
+		"request_sock_TCP",
 	};
 
 	if (slabstat_valid)
@@ -759,24 +759,23 @@ static int get_slabstat(struct slabstat *s)
 	if (!fp)
 		return -1;
 
-	cnt = sizeof(*s)/sizeof(int);
-
 	if (!fgets(buf, sizeof(buf), fp)) {
 		fclose(fp);
 		return -1;
 	}
+
 	while (fgets(buf, sizeof(buf), fp) != NULL) {
-		int i;
+		int i, v;
 
 		for (i = 0; i < ARRAY_SIZE(slabstat_ids); i++) {
-			if (memcmp(buf, slabstat_ids[i], strlen(slabstat_ids[i])) == 0) {
-				sscanf(buf, "%*s%d", ((int *)s) + i);
-				cnt--;
+			if (memcmp(buf, slabstat_ids[i], strlen(slabstat_ids[i])) != 0)
+				continue;
+
+			if (sscanf(buf, "%*s%d", &v) == 1) {
+				stats[i] += v;
 				break;
 			}
 		}
-		if (cnt <= 0)
-			break;
 	}
 
 	slabstat_valid = 1;
-- 
2.17.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ