mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Rename Resume() to Restore() in netstack.
The existing Resume method in netstack is doing the work of Restore. This method does not resume endpoints as the resumable endpoints are only stored during the Restore of the sandbox, rename the method appropriately. PiperOrigin-RevId: 613320887
This commit is contained in:
committed by
gVisor bot
parent
1676e8a877
commit
a76911efa9
@@ -84,8 +84,8 @@ type Stack interface {
|
||||
// Pause pauses the network stack before save.
|
||||
Pause()
|
||||
|
||||
// Resume restarts the network stack after restore.
|
||||
Resume()
|
||||
// Restore restarts the network stack after restore.
|
||||
Restore()
|
||||
|
||||
// Destroy the network stack.
|
||||
Destroy()
|
||||
|
||||
@@ -152,8 +152,8 @@ func (s *TestStack) RouteTable() []Route {
|
||||
// Pause implements Stack.
|
||||
func (s *TestStack) Pause() {}
|
||||
|
||||
// Resume implements Stack.
|
||||
func (s *TestStack) Resume() {}
|
||||
// Restore implements Stack.
|
||||
func (s *TestStack) Restore() {}
|
||||
|
||||
// RegisteredEndpoints implements Stack.
|
||||
func (s *TestStack) RegisteredEndpoints() []stack.TransportEndpoint {
|
||||
|
||||
@@ -627,7 +627,7 @@ func (k *Kernel) SaveTo(ctx context.Context, w wire.Writer) error {
|
||||
netstackPauseStart := time.Now()
|
||||
log.Infof("Pausing root network namespace")
|
||||
k.rootNetworkNamespace.Stack().Pause()
|
||||
defer k.rootNetworkNamespace.Stack().Resume()
|
||||
defer k.rootNetworkNamespace.Stack().Restore()
|
||||
log.Infof("Pausing root network namespace took [%s].", time.Since(netstackPauseStart))
|
||||
}
|
||||
|
||||
@@ -740,7 +740,7 @@ func (k *Kernel) LoadFrom(ctx context.Context, r wire.Reader, timeReady chan str
|
||||
}
|
||||
|
||||
if net != nil {
|
||||
net.Resume()
|
||||
net.Restore()
|
||||
}
|
||||
|
||||
if err := k.vfs.CompleteRestore(ctx, vfsOpts); err != nil {
|
||||
|
||||
@@ -326,8 +326,8 @@ func (s *Stack) RouteTable() []inet.Route {
|
||||
// Pause implements inet.Stack.Pause.
|
||||
func (*Stack) Pause() {}
|
||||
|
||||
// Resume implements inet.Stack.Resume.
|
||||
func (*Stack) Resume() {}
|
||||
// Restore implements inet.Stack.Restore.
|
||||
func (*Stack) Restore() {}
|
||||
|
||||
// RegisteredEndpoints implements inet.Stack.RegisteredEndpoints.
|
||||
func (*Stack) RegisteredEndpoints() []stack.TransportEndpoint { return nil }
|
||||
|
||||
@@ -474,9 +474,9 @@ func (s *Stack) Pause() {
|
||||
s.Stack.Pause()
|
||||
}
|
||||
|
||||
// Resume implements inet.Stack.Resume.
|
||||
func (s *Stack) Resume() {
|
||||
s.Stack.Resume()
|
||||
// Restore implements inet.Stack.Restore.
|
||||
func (s *Stack) Restore() {
|
||||
s.Stack.Restore()
|
||||
}
|
||||
|
||||
// RegisteredEndpoints implements inet.Stack.RegisteredEndpoints.
|
||||
|
||||
+17
-17
@@ -48,13 +48,13 @@ type transportProtocolState struct {
|
||||
defaultHandler func(id TransportEndpointID, pkt *PacketBuffer) bool
|
||||
}
|
||||
|
||||
// ResumableEndpoint is an endpoint that needs to be resumed after restore.
|
||||
type ResumableEndpoint interface {
|
||||
// Resume resumes an endpoint after restore. This can be used to restart
|
||||
// background workers such as protocol goroutines. This must be called after
|
||||
// all indirect dependencies of the endpoint has been restored, which
|
||||
// RestoredEndpoint is an endpoint that needs to be restored.
|
||||
type RestoredEndpoint interface {
|
||||
// Restore restores an endpoint. This can be used to restart background
|
||||
// workers such as protocol goroutines. This must be called after all
|
||||
// indirect dependencies of the endpoint has been restored, which
|
||||
// generally implies at the end of the restore process.
|
||||
Resume(*Stack)
|
||||
Restore(*Stack)
|
||||
}
|
||||
|
||||
// uniqueIDGenerator is a default unique ID generator.
|
||||
@@ -115,9 +115,9 @@ type Stack struct {
|
||||
// TODO(gvisor.dev/issue/4595): S/R this field.
|
||||
tables *IPTables
|
||||
|
||||
// resumableEndpoints is a list of endpoints that need to be resumed if the
|
||||
// restoredEndpoints is a list of endpoints that need to be restored if the
|
||||
// stack is being restored.
|
||||
resumableEndpoints []ResumableEndpoint
|
||||
restoredEndpoints []RestoredEndpoint
|
||||
|
||||
// icmpRateLimiter is a global rate limiter for all ICMP messages generated
|
||||
// by the stack.
|
||||
@@ -1713,9 +1713,9 @@ func (s *Stack) UnregisterRawTransportEndpoint(netProto tcpip.NetworkProtocolNum
|
||||
|
||||
// RegisterRestoredEndpoint records e as an endpoint that has been restored on
|
||||
// this stack.
|
||||
func (s *Stack) RegisterRestoredEndpoint(e ResumableEndpoint) {
|
||||
func (s *Stack) RegisterRestoredEndpoint(e RestoredEndpoint) {
|
||||
s.mu.Lock()
|
||||
s.resumableEndpoints = append(s.resumableEndpoints, e)
|
||||
s.restoredEndpoints = append(s.restoredEndpoints, e)
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
@@ -1811,17 +1811,17 @@ func (s *Stack) Pause() {
|
||||
}
|
||||
}
|
||||
|
||||
// Resume restarts the stack after a restore. This must be called after the
|
||||
// Restore restarts the stack after a restore. This must be called after the
|
||||
// entire system has been restored.
|
||||
func (s *Stack) Resume() {
|
||||
// ResumableEndpoint.Resume() may call other methods on s, so we can't hold
|
||||
// s.mu while resuming the endpoints.
|
||||
func (s *Stack) Restore() {
|
||||
// RestoredEndpoint.Restore() may call other methods on s, so we can't hold
|
||||
// s.mu while restoring the endpoints.
|
||||
s.mu.Lock()
|
||||
eps := s.resumableEndpoints
|
||||
s.resumableEndpoints = nil
|
||||
eps := s.restoredEndpoints
|
||||
s.restoredEndpoints = nil
|
||||
s.mu.Unlock()
|
||||
for _, e := range eps {
|
||||
e.Resume(s)
|
||||
e.Restore(s)
|
||||
}
|
||||
// Now resume any protocol level background workers.
|
||||
for _, p := range s.transportProtocols {
|
||||
|
||||
@@ -255,7 +255,7 @@ func (*fakeTransportEndpoint) State() uint32 {
|
||||
|
||||
func (*fakeTransportEndpoint) ModerateRecvBuf(copied int) {}
|
||||
|
||||
func (*fakeTransportEndpoint) Resume(*stack.Stack) {}
|
||||
func (*fakeTransportEndpoint) Restore(*stack.Stack) {}
|
||||
|
||||
func (*fakeTransportEndpoint) Wait() {}
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ func (e *endpoint) beforeSave() {
|
||||
e.freeze()
|
||||
}
|
||||
|
||||
// Resume implements tcpip.ResumableEndpoint.Resume.
|
||||
func (e *endpoint) Resume(s *stack.Stack) {
|
||||
// Restore implements tcpip.RestoredEndpoint.Restore.
|
||||
func (e *endpoint) Restore(s *stack.Stack) {
|
||||
e.thaw()
|
||||
|
||||
e.net.Resume(s)
|
||||
|
||||
@@ -43,8 +43,8 @@ func (e *endpoint) beforeSave() {
|
||||
e.setReceiveDisabled(true)
|
||||
}
|
||||
|
||||
// Resume implements tcpip.ResumableEndpoint.Resume.
|
||||
func (e *endpoint) Resume(s *stack.Stack) {
|
||||
// Restore implements tcpip.RestoredEndpoint.Restore.
|
||||
func (e *endpoint) Restore(s *stack.Stack) {
|
||||
e.net.Resume(s)
|
||||
|
||||
e.setReceiveDisabled(false)
|
||||
|
||||
@@ -114,13 +114,13 @@ func (e *endpoint) afterLoad(ctx context.Context) {
|
||||
// RacyLoad() can be used because we are initializing e.
|
||||
e.origEndpointState = e.state.RacyLoad()
|
||||
// Restore the endpoint to InitialState as it will be moved to
|
||||
// its origEndpointState during Resume.
|
||||
// its origEndpointState during Restore.
|
||||
e.state = atomicbitops.FromUint32(uint32(StateInitial))
|
||||
stack.RestoreStackFromContext(ctx).RegisterRestoredEndpoint(e)
|
||||
}
|
||||
|
||||
// Resume implements tcpip.ResumableEndpoint.Resume.
|
||||
func (e *endpoint) Resume(s *stack.Stack) {
|
||||
// Restore implements tcpip.RestoredEndpoint.Restore.
|
||||
func (e *endpoint) Restore(s *stack.Stack) {
|
||||
if !e.EndpointState().closed() {
|
||||
e.keepalive.timer.init(s.Clock(), timerHandler(e, e.keepaliveTimerExpired))
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ func (e *endpoint) beforeSave() {
|
||||
e.freeze()
|
||||
}
|
||||
|
||||
// Resume implements tcpip.ResumableEndpoint.Resume.
|
||||
func (e *endpoint) Resume(s *stack.Stack) {
|
||||
// Restore implements tcpip.RestoredEndpoint.Restore.
|
||||
func (e *endpoint) Restore(s *stack.Stack) {
|
||||
e.thaw()
|
||||
|
||||
e.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user