Page MenuHomeFreeBSD

tcp: Correctly compute the TCP goodput in bits per second by using SEQ_SUB().
ClosedPublic

Authored by hselasky on Jun 16 2022, 3:10 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Feb 1, 6:46 PM
Unknown Object (File)
Mon, Jan 27, 4:54 PM
Unknown Object (File)
Dec 4 2024, 2:24 AM
Unknown Object (File)
Oct 22 2024, 5:47 AM
Unknown Object (File)
Oct 18 2024, 1:43 AM
Unknown Object (File)
Sep 26 2024, 4:23 PM
Unknown Object (File)
Sep 24 2024, 4:09 AM
Unknown Object (File)
Sep 11 2024, 2:48 PM

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Should we generally use the SEQ_SUB macro throughout, to prevent casting issues? (mechanically replace all instances, where a type tcpseq is subtracted from another type tcpseq?)

This revision is now accepted and ready to land.Jun 16 2022, 6:15 AM

Maybe. Most places where TCP sequence numbers are subtracted, they end up in integers, so then there is no problem.

I need to look at closer at this.

sys/netinet/tcp_input.c
324

I think we need to add SEQ_GET(th->th_ack, tp->gput_seq) here too, just to ensure that the SEQ_SUB() doesn't return a signed negative value.

324

SEQ_GET -> SEQ_GEQ

BTW: The current code seems OK, but may be confusing to review.

BTW: The current code seems OK, but may be confusing to review.

You shouldn't end up doing this calculation on ACKs from below the left edge of the window (th_ack < snd_una)

Right, so then the SEQ_SUB() shouldn't become negative?

Right, so then the SEQ_SUB() shouldn't become negative?

During normal processing, th_ack should always be in the range snd_una ... snd_max. All cases outside of this window should be addressed before normal congestion-control processing. The cases with explicit unsigned int typcasting should be adressed for formal reasons, but generally, those calculations should return positive values.