From: Bryton Lee Date: Thu, 12 Feb 2015 06:16:04 +0000 (+0800) Subject: prevent the read ahead of /proc/slabinfo in ss X-Git-Tag: v4.0.0~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a221d621bb4af414b974ccc40bba26481337d7cf;p=thirdparty%2Fiproute2.git prevent the read ahead of /proc/slabinfo in ss Signed-off-by: Bryton Lee --- diff --git a/misc/ss.c b/misc/ss.c index a5c482f65..2678033fc 100644 --- a/misc/ss.c +++ b/misc/ss.c @@ -618,7 +618,7 @@ struct slabstat int skbs; }; -struct slabstat slabstat; +static struct slabstat slabstat; static const char *slabstat_ids[] = { @@ -634,6 +634,10 @@ static int get_slabstat(struct slabstat *s) char buf[256]; FILE *fp; int cnt; + static int slabstat_valid; + + if (slabstat_valid) + return 0; memset(s, 0, sizeof(*s)); @@ -657,6 +661,8 @@ static int get_slabstat(struct slabstat *s) break; } + slabstat_valid = 1; + fclose(fp); return 0; } @@ -2297,6 +2303,8 @@ static int tcp_show(struct filter *f, int socktype) * it is able to give us some memory for snapshot. */ if (1) { + get_slabstat(&slabstat); + int guess = slabstat.socks+slabstat.tcp_syns; if (f->states&(1<