Call ConfirmReachable only once per batch of packets.

ConfirmReachable does not need to be called on every packet processed
as we process packets in batches. Its more efficient to do so once
for every batch in handleSegmentsLocked.

PiperOrigin-RevId: 439402884
This commit is contained in:
Bhasker Hariharan
2022-04-04 13:52:39 -07:00
committed by gVisor bot
parent fa8f71f2ec
commit 399199e4b7
2 changed files with 11 additions and 12 deletions
+11
View File
@@ -1142,6 +1142,7 @@ func (e *endpoint) handleReset(s *segment) (ok bool, err tcpip.Error) {
// +checklocksalias:e.snd.ep.mu=e.mu
func (e *endpoint) handleSegmentsLocked(fastPath bool) tcpip.Error {
checkRequeue := true
sndUna := e.snd.SndUna
for i := 0; i < maxSegmentsPerWake; i++ {
if state := e.EndpointState(); state.closed() || state == StateTimeWait {
return nil
@@ -1162,6 +1163,16 @@ func (e *endpoint) handleSegmentsLocked(fastPath bool) tcpip.Error {
}
}
// The remote ACK-ing at least 1 byte is an indication that we have a
// full-duplex connection to the remote as the only way we will receive an
// ACK is if the remote received data that we previously sent.
//
// As of writing, Linux seems to only confirm a route as reachable when
// forward progress is made which is indicated by an ACK that removes data
// from the retransmit queue, i.e. sender makes forward progress.
if sndUna.LessThan(e.snd.SndUna) {
e.route.ConfirmReachable()
}
// When fastPath is true we don't want to wake up the worker
// goroutine. If the endpoint has more segments to process the
// dispatcher will call handleSegments again anyway.
-12
View File
@@ -1496,18 +1496,6 @@ func (s *sender) handleRcvdSegment(rcvdSeg *segment) {
// Remove all acknowledged data from the write list.
acked := s.SndUna.Size(ack)
s.SndUna = ack
// The remote ACK-ing at least 1 byte is an indication that we have a
// full-duplex connection to the remote as the only way we will receive an
// ACK is if the remote received data that we previously sent.
//
// As of writing, linux seems to only confirm a route as reachable when
// forward progress is made which is indicated by an ACK that removes data
// from the retransmit queue.
if acked > 0 {
s.ep.route.ConfirmReachable()
}
ackLeft := acked
originalOutstanding := s.Outstanding
for ackLeft > 0 {