summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorZhaozhong Ni <nzz@google.com>2018-07-17 10:13:57 -0700
committerShentubot <shentubot@google.com>2018-07-17 10:15:00 -0700
commitbeb89bb75749620969b0e1dea65240bf5d4324b2 (patch)
tree68d97bd27e40bdf4f927d0dd0f0dfebe859197bd /pkg
parent29e00c943a61dfcfd4ac8d3f6f526eab641c44a6 (diff)
netstack: update goroutine save / restore safety comments.
PiperOrigin-RevId: 204930314 Change-Id: Ifc4c41ed28616cd57fafbf7c92e87141a945c41f
Diffstat (limited to 'pkg')
-rw-r--r--pkg/tcpip/link/fdbased/endpoint.go5
-rw-r--r--pkg/tcpip/link/sharedmem/sharedmem.go5
-rw-r--r--pkg/tcpip/sample/tun_tcp_connect/main.go2
-rw-r--r--pkg/tcpip/sample/tun_tcp_echo/main.go2
-rw-r--r--pkg/tcpip/stack/linkaddrcache.go2
-rw-r--r--pkg/tcpip/transport/tcp/forwarder.go2
6 files changed, 12 insertions, 6 deletions
diff --git a/pkg/tcpip/link/fdbased/endpoint.go b/pkg/tcpip/link/fdbased/endpoint.go
index 413f77dcc..8fc009160 100644
--- a/pkg/tcpip/link/fdbased/endpoint.go
+++ b/pkg/tcpip/link/fdbased/endpoint.go
@@ -108,7 +108,10 @@ func New(opts *Options) tcpip.LinkEndpointID {
// dispatches them via the provided dispatcher.
func (e *endpoint) Attach(dispatcher stack.NetworkDispatcher) {
e.attached = true
- go e.dispatchLoop(dispatcher) // S/R-FIXME
+ // Link endpoints are not savable. When transportation endpoints are
+ // saved, they stop sending outgoing packets and all incoming packets
+ // are rejected.
+ go e.dispatchLoop(dispatcher) // S/R-SAFE: See above.
}
// IsAttached implements stack.LinkEndpoint.IsAttached.
diff --git a/pkg/tcpip/link/sharedmem/sharedmem.go b/pkg/tcpip/link/sharedmem/sharedmem.go
index 223eb3a1b..eabf35bd3 100644
--- a/pkg/tcpip/link/sharedmem/sharedmem.go
+++ b/pkg/tcpip/link/sharedmem/sharedmem.go
@@ -142,7 +142,10 @@ func (e *endpoint) Attach(dispatcher stack.NetworkDispatcher) {
if !e.workerStarted && atomic.LoadUint32(&e.stopRequested) == 0 {
e.workerStarted = true
e.completed.Add(1)
- go e.dispatchLoop(dispatcher) // S/R-FIXME
+ // Link endpoints are not savable. When transportation endpoints
+ // are saved, they stop sending outgoing packets and all
+ // incoming packets are rejected.
+ go e.dispatchLoop(dispatcher) // S/R-SAFE: see above.
}
e.mu.Unlock()
}
diff --git a/pkg/tcpip/sample/tun_tcp_connect/main.go b/pkg/tcpip/sample/tun_tcp_connect/main.go
index 8309ee3a0..1915f7ef9 100644
--- a/pkg/tcpip/sample/tun_tcp_connect/main.go
+++ b/pkg/tcpip/sample/tun_tcp_connect/main.go
@@ -187,7 +187,7 @@ func main() {
// Start the writer in its own goroutine.
writerCompletedCh := make(chan struct{})
- go writer(writerCompletedCh, ep) // S/R-FIXME
+ go writer(writerCompletedCh, ep) // S/R-SAFE: sample code.
// Read data and write to standard output until the peer closes the
// connection from its side.
diff --git a/pkg/tcpip/sample/tun_tcp_echo/main.go b/pkg/tcpip/sample/tun_tcp_echo/main.go
index a4d955c7a..e01adf635 100644
--- a/pkg/tcpip/sample/tun_tcp_echo/main.go
+++ b/pkg/tcpip/sample/tun_tcp_echo/main.go
@@ -187,6 +187,6 @@ func main() {
log.Fatal("Accept() failed:", err)
}
- go echo(wq, n) // S/R-FIXME
+ go echo(wq, n) // S/R-SAFE: sample code.
}
}
diff --git a/pkg/tcpip/stack/linkaddrcache.go b/pkg/tcpip/stack/linkaddrcache.go
index a1645c7bf..04b8f251a 100644
--- a/pkg/tcpip/stack/linkaddrcache.go
+++ b/pkg/tcpip/stack/linkaddrcache.go
@@ -262,7 +262,7 @@ func (c *linkAddrCache) startAddressResolution(k tcpip.FullAddress, linkRes Link
e := c.makeAndAddEntry(k, "")
e.addWaker(waker)
- go func() { // S/R-FIXME
+ go func() { // S/R-SAFE: link non-savable; wakers dropped synchronously.
for i := 0; ; i++ {
// Send link request, then wait for the timeout limit and check
// whether the request succeeded.
diff --git a/pkg/tcpip/transport/tcp/forwarder.go b/pkg/tcpip/transport/tcp/forwarder.go
index 71eb89795..8a873db73 100644
--- a/pkg/tcpip/transport/tcp/forwarder.go
+++ b/pkg/tcpip/transport/tcp/forwarder.go
@@ -90,7 +90,7 @@ func (f *Forwarder) HandlePacket(r *stack.Route, id stack.TransportEndpointID, v
// Launch a new goroutine to handle the request.
f.inFlight[id] = struct{}{}
s.incRef()
- go f.handler(&ForwarderRequest{ // S/R-FIXME
+ go f.handler(&ForwarderRequest{ // S/R-SAFE: not used by Sentry.
forwarder: f,
segment: s,
synOptions: opts,