Skip to content

Commit

Permalink
netstack: revert SND.NXT when purging the write queue
Browse files Browse the repository at this point in the history
There are only 3 places we remove from the write queue. The other two are
fairly self-contained and don't look suspicious. They are:

- tcp.sender.maybeSendSegment - removes iff the segments are merged
- tcp.sender.handleRcvdSegment - removes iff the whole segment is covered by an
  incoming ACK

Given that the panic occurs when the write queue is empty and SND.NXT !=
SND.UNA, the bug likely occurs when either the writeList removes a segment or
SND.NXT increments.

PiperOrigin-RevId: 698885878
  • Loading branch information
kevinGC authored and gvisor-bot committed Nov 22, 2024
1 parent b15656d commit 6dd069b
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pkg/tcpip/transport/tcp/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -1013,16 +1013,13 @@ func (e *Endpoint) purgeWriteQueue() {
e.sndQueueInfo.sndQueueMu.Lock()
defer e.sndQueueInfo.sndQueueMu.Unlock()
e.snd.updateWriteNext(nil)
for {
s := e.snd.writeList.Front()
if s == nil {
break
}
for s := e.snd.writeList.Front(); s != nil; s = e.snd.writeList.Front() {
e.snd.writeList.Remove(s)
s.DecRef()
}
e.sndQueueInfo.SndBufUsed = 0
e.sndQueueInfo.SndClosed = true
e.snd.SndNxt = e.snd.SndUna
}
}

Expand Down

0 comments on commit 6dd069b

Please sign in to comment.