iovisor/bcc

Incorrect calculation of recv throughput in tcptop.py

Open

#5,352 opened on Jul 4, 2025

View on GitHub
 (11 comments) (6 reactions) (0 assignees)C (4,051 forks)batch import
bughelp wanted

Repository metrics

Stars
 (22,409 stars)
PR merge metrics
 (Avg merge 12d 6h) (12 merged PRs in 30d)

Description

tcp_cleanup_rbuf is called several times in a loop inside tcp_recvmsg. At the same time, it is passed the accumulated parameter "copied". Thus, the same data is taken into account several times.

int tcp_recvmsg(...) {
     ...
     int copied = 0;
     ...
     do {
         ...
         tcp_cleanup_rbuf(sk, copied);
         ...
         copied += used;
         ...
     } while (len > 0);
     
     tcp_cleanup_rbuf(sk, copied);
     return copied;
     ...
}

Contributor guide