[PATCH iproute2] misc/ss: tcp cwnd should be unsigned

Subsystems: the rest

STALE3680d

3 messages, 3 authors, 2016-09-22 · open the first message on its own page

[PATCH iproute2] misc/ss: tcp cwnd should be unsigned

From: Hangbin Liu <hidden>
Date: 2016-09-22 08:40:49

tcp->snd_cwd is a u32, but ss treats it like a signed int. This may
results in negative bandwidth calculations.

Signed-off-by: Hangbin Liu <redacted>
---
 misc/ss.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index 3b268d9..f67557a 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -754,11 +754,12 @@ struct tcpstat {
 	int		    probes;
 	char		    cong_alg[16];
 	double		    rto, ato, rtt, rttvar;
-	int		    qack, cwnd, ssthresh, backoff;
+	int		    qack, ssthresh, backoff;
 	double		    send_bps;
 	int		    snd_wscale;
 	int		    rcv_wscale;
 	int		    mss;
+	unsigned int	    cwnd;
 	unsigned int	    lastsnd;
 	unsigned int	    lastrcv;
 	unsigned int	    lastack;
@@ -1756,7 +1757,7 @@ static void tcp_stats_print(struct tcpstat *s)
 	if (s->mss)
 		printf(" mss:%d", s->mss);
 	if (s->cwnd)
-		printf(" cwnd:%d", s->cwnd);
+		printf(" cwnd:%u", s->cwnd);
 	if (s->ssthresh)
 		printf(" ssthresh:%d", s->ssthresh);
 
@@ -1856,7 +1857,7 @@ static int tcp_show_line(char *line, const struct filter *f, int family)
 		return 0;
 
 	opt[0] = 0;
-	n = sscanf(data, "%x %x:%x %x:%x %x %d %d %u %d %llx %d %d %d %d %d %[^\n]\n",
+	n = sscanf(data, "%x %x:%x %x:%x %x %d %d %u %d %llx %d %d %d %u %d %[^\n]\n",
 		   &s.ss.state, &s.ss.wq, &s.ss.rq,
 		   &s.timer, &s.timeout, &s.retrans, &s.ss.uid, &s.probes,
 		   &s.ss.ino, &s.ss.refcnt, &s.ss.sk, &rto, &ato, &s.qack, &s.cwnd,
-- 
2.5.5

Re: [PATCH iproute2] misc/ss: tcp cwnd should be unsigned

From: Phil Sutter <phil@nwl.cc>
Date: 2016-09-22 08:48:22

On Thu, Sep 22, 2016 at 04:40:28PM +0800, Hangbin Liu wrote:
tcp->snd_cwd is a u32, but ss treats it like a signed int. This may
results in negative bandwidth calculations.

Signed-off-by: Hangbin Liu <redacted>
Acked-by: Phil Sutter <phil@nwl.cc>

Re: [PATCH iproute2] misc/ss: tcp cwnd should be unsigned

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2016-09-22 23:39:12

On Thu, 22 Sep 2016 16:40:28 +0800
Hangbin Liu [off-list ref] wrote:
tcp->snd_cwd is a u32, but ss treats it like a signed int. This may
results in negative bandwidth calculations.

Signed-off-by: Hangbin Liu <redacted>
Sure applied.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help