Skip to content

Commit b15656d

Browse files
kevinGCgvisor-bot
authored andcommitted
netstack: remove mention of the long-dead protocol goroutine
Bhasker removed this years ago. PiperOrigin-RevId: 698915055
1 parent a5542f1 commit b15656d

File tree

3 files changed

+15
-34
lines changed

3 files changed

+15
-34
lines changed

pkg/tcpip/transport/tcp/connect.go

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ const (
4040
// https://github.com/torvalds/linux/blob/7c636d4d20f/include/net/tcp.h#L142
4141
InitialRTO = time.Second
4242

43-
// maxSegmentsPerWake is the maximum number of segments to process in the main
44-
// protocol goroutine per wake-up. Yielding [after this number of segments are
45-
// processed] allows other events to be processed as well (e.g., timeouts,
46-
// resets, etc.).
43+
// maxSegmentsPerWake is the maximum number of segments to process per
44+
// wake-up. Yielding [after this number of segments are processed]
45+
// allows other events to be processed as well (e.g., timeouts, resets,
46+
// etc.).
4747
maxSegmentsPerWake = 100
4848
)
4949

@@ -543,7 +543,7 @@ func (h *handshake) processSegments() tcpip.Error {
543543

544544
// We stop processing packets once the handshake is completed,
545545
// otherwise we may process packets meant to be processed by
546-
// the main protocol goroutine.
546+
// the TCP processor goroutine.
547547
if h.state == handshakeCompleted {
548548
break
549549
}
@@ -1032,8 +1032,7 @@ func (e *Endpoint) sendData(next *segment) {
10321032

10331033
// resetConnectionLocked puts the endpoint in an error state with the given
10341034
// error code and sends a RST if and only if the error is not ErrConnectionReset
1035-
// indicating that the connection is being reset due to receiving a RST. This
1036-
// method must only be called from the protocol goroutine.
1035+
// indicating that the connection is being reset due to receiving a RST.
10371036
// +checklocks:e.mu
10381037
func (e *Endpoint) resetConnectionLocked(err tcpip.Error) {
10391038
// Only send a reset if the connection is being aborted for a reason
@@ -1167,10 +1166,6 @@ func (e *Endpoint) handleReset(s *segment) (ok bool, err tcpip.Error) {
11671166
// except SYN-SENT, all reset (RST) segments are
11681167
// validated by checking their SEQ-fields." So
11691168
// we only process it if it's acceptable.
1170-
1171-
// Notify protocol goroutine. This is required when
1172-
// handleSegment is invoked from the processor goroutine
1173-
// rather than the worker goroutine.
11741169
return false, &tcpip.ErrConnectionReset{}
11751170
}
11761171
}
@@ -1292,12 +1287,7 @@ func (e *Endpoint) handleSegmentLocked(s *segment) (cont bool, err tcpip.Error)
12921287
state := e.EndpointState()
12931288
if state == StateClose {
12941289
// When we get into StateClose while processing from the queue,
1295-
// return immediately and let the protocolMainloop handle it.
1296-
//
1297-
// We can reach StateClose only while processing a previous segment
1298-
// or a notification from the protocolMainLoop (caller goroutine).
1299-
// This means that with this return, the segment dequeue below can
1300-
// never occur on a closed endpoint.
1290+
// return immediately and let the TCP processors handle it.
13011291
return false, nil
13021292
}
13031293

pkg/tcpip/transport/tcp/endpoint.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,6 @@ func (*Stats) IsEndpointStats() {}
287287
type sndQueueInfo struct {
288288
sndQueueMu sync.Mutex `state:"nosave"`
289289
stack.TCPSndBufState
290-
291-
// sndWaker is used to signal the protocol goroutine when there may be
292-
// segments that need to be sent.
293-
sndWaker sleep.Waker `state:"manual"`
294290
}
295291

296292
// CloneState clones sq into other. It is not thread safe
@@ -524,8 +520,6 @@ type Endpoint struct {
524520
// +checklocks:acceptMu
525521
acceptQueue acceptQueue
526522

527-
// The following are only used from the protocol goroutine, and
528-
// therefore don't need locks to protect them.
529523
rcv *receiver `state:"wait"`
530524
snd *sender `state:"wait"`
531525

@@ -1450,8 +1444,7 @@ func (e *Endpoint) Read(dst io.Writer, opts tcpip.ReadOptions) (tcpip.ReadResult
14501444
if memDelta > 0 {
14511445
// If the window was small before this read and if the read freed up
14521446
// enough buffer space, to either fit an aMSS or half a receive buffer
1453-
// (whichever smaller), then notify the protocol goroutine to send a
1454-
// window update.
1447+
// (whichever smaller), then send a window update.
14551448
if crossed, above := e.windowCrossedACKThresholdLocked(memDelta, int(e.ops.GetReceiveBufferSize())); crossed && above {
14561449
sendNonZeroWindowUpdate = true
14571450
}
@@ -2475,7 +2468,6 @@ func (e *Endpoint) connect(addr tcpip.FullAddress, handshake bool) tcpip.Error {
24752468
for _, l := range []segmentList{e.segmentQueue.list, e.snd.writeList} {
24762469
for s := l.Front(); s != nil; s = s.Next() {
24772470
s.id = e.TransportEndpointInfo.ID
2478-
e.sndQueueInfo.sndWaker.Assert()
24792471
}
24802472
}
24812473
e.segmentQueue.mu.Unlock()
@@ -2962,8 +2954,8 @@ func (e *Endpoint) HandleError(transErr stack.TransportError, pkt *stack.PacketB
29622954
}
29632955
}
29642956

2965-
// updateSndBufferUsage is called by the protocol goroutine when room opens up
2966-
// in the send buffer. The number of newly available bytes is v.
2957+
// updateSndBufferUsage is called by when room opens up in the send buffer. The
2958+
// number of newly available bytes is v.
29672959
func (e *Endpoint) updateSndBufferUsage(v int) {
29682960
sendBufferSize := e.getSendBufferSize()
29692961
e.sndQueueInfo.sndQueueMu.Lock()
@@ -2987,9 +2979,8 @@ func (e *Endpoint) updateSndBufferUsage(v int) {
29872979
}
29882980
}
29892981

2990-
// readyToRead is called by the protocol goroutine when a new segment is ready
2991-
// to be read, or when the connection is closed for receiving (in which case
2992-
// s will be nil).
2982+
// readyToRead is called when a new segment is ready to be read, or when the
2983+
// connection is closed for receiving (in which case s will be nil).
29932984
//
29942985
// +checklocks:e.mu
29952986
func (e *Endpoint) readyToRead(s *segment) {

pkg/tcpip/transport/tcp/test/e2e/tcp_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ func TestClosingWithEnqueuedSegments(t *testing.T) {
863863
t.Errorf("unexpected endpoint state: want %s, got %s", want, got)
864864
}
865865

866-
// Pause the endpoint`s protocolMainLoop.
866+
// Pause the endpoint.
867867
ep.(interface{ StopWork() }).StopWork()
868868

869869
// Enqueue last ACK followed by an ACK matching the endpoint
@@ -889,10 +889,10 @@ func TestClosingWithEnqueuedSegments(t *testing.T) {
889889
RcvWnd: 30000,
890890
})
891891

892-
// Unpause endpoint`s protocolMainLoop.
892+
// Unpause endpoint.
893893
ep.(interface{ ResumeWork() }).ResumeWork()
894894

895-
// Wait for the protocolMainLoop to resume and update state.
895+
// Wait for the endpoint to resume and update state.
896896
time.Sleep(10 * time.Millisecond)
897897

898898
// Expect the endpoint to be closed.

0 commit comments

Comments
 (0)