When checking for a full sized segment, take all TCP options that will be included into account.
This fixes a bug which can trigger the "sent too much" KASSERT related to limited transmit.
Details
Details
- Reviewers
olivier rscheff rrs peter.lei_ieee.org nickbanks_netflix.com - Group Reviewers
transport - Commits
- rGd174085f9f89: tcp: improve sender side SWS avoidance
Run the following packetdrill-script, which is based on the one provided by Olivier in PR 107.
// Reproducer for "tcp_do_segment: sent too much" (PR 282605), the case // where a retransmission timeout is still in effect (t_rxtshift > 0). // // An INVARIANTS kernel panics in the limited transmit branch of // tcp_do_segment(): "sent too much: 1982>988". Run it in a throwaway VM. // A kernel without INVARIANTS, or with the fix, passes: two full // segments and a 6 byte tail go out on the first duplicate ACK. // // The four conditions, all seen in a server crash dump: // 1. Our ACKs carry a SACK block, so a segment holds 988 bytes // (tcp_maxseg()) while the SWS check in tcp_output() needs 1000 // (t_maxseg). // 2. Two RTOs leave t_rxtshift at 2, so the limited transmit code does // not reset snd_cwnd to the flight size. // 3. 994 bytes of cwnd are free but stay unused: less than t_maxseg, // with more data in the send buffer. // 4. The first SACK duplicate ACK adds one segment of cwnd: 1982 bytes // go out, which is 2 * 988 or more. --ip_version=ipv4 0.00 `sysctl -w net.inet.tcp.functions_default=freebsd` +0.00 `sysctl -w net.inet.tcp.hostcache.purgenow=1` +0.00 `sysctl -w net.inet.tcp.sack.enable=1` +0.00 `sysctl -w net.inet.tcp.rfc3042=1` +0.00 `kldload -n cc_newreno` +0.00 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 +0.00 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 +0.00 setsockopt(3, IPPROTO_TCP, TCP_CONGESTION, "newreno", 8) = 0 +0.00 bind(3, ..., ...) = 0 +0.00 listen(3, 1) = 0 +0.00 < S 0:0(0) win 65535 <mss 1000,sackOK,eol,eol> +0.00 > S. 0:0(0) ack 1 <mss 1460,sackOK,eol,eol> +0.10 < . 1:1(0) ack 1 win 65535 +0.00 accept(3, ..., ...) = 4 +0.00 setsockopt(4, IPPROTO_TCP, TCP_NODELAY, [1], 4) = 0 // Condition 1: the peer leaves a hole in its data. From now on every // segment we send carries <nop,nop,sack 201:301>, 12 bytes of options. +0.00 < P. 1:101(100) ack 1 win 65535 +0.00 < P. 201:301(100) ack 1 win 65535 +0.00 > . 1:1(0) ack 101 <nop,nop,sack 201:301> // Condition 2: one segment, lost twice. +0.00 write(4, ..., 988) = 988 +0.00 > P. 1:989(988) ack 101 <nop,nop,sack 201:301> +0.20~+3.50 > P. 1:989(988) ack 101 <nop,nop,sack 201:301> +0.40~+7.00 > P. 1:989(988) ack 101 <nop,nop,sack 201:301> // No RTT sample from a retransmitted segment: t_rxtshift stays 2. // Slow start: cwnd 1000 + 988 = 1988. +0.00 < . 101:101(0) ack 989 win 65535 // Condition 3: 994 bytes in flight, 994 bytes of cwnd free. +0.00 write(4, ..., 994) = 994 +0.00 > . 989:1977(988) ack 101 <nop,nop,sack 201:301> +0.00 > P. 1977:1983(6) ack 101 <nop,nop,sack 201:301> // 994 < t_maxseg (1000) and more data waits: SWS holds it, nothing sent. +0.00 write(4, ..., 1982) = 1982 +0.00 > . 1983:2971(988) ack 101 <nop,nop,sack 201:301> // Condition 4: the first duplicate ACK. INVARIANTS kernels panic here. +0.10 < . 101:101(0) ack 989 win 65535 <nop,nop,sack 1983:2971> +0.00 > . 2971:3959(988) ack 101 <nop,nop,sack 201:301> +0.00 > P. 3959:3965(6) ack 101 <nop,nop,sack 201:301> +0.00 close(4) = 0 +0.00 close(3) = 0
Diff Detail
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable