Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions pkg/sentry/kernel/kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ import (
"gvisor.dev/gvisor/pkg/sentry/vfs"
"gvisor.dev/gvisor/pkg/state"
"gvisor.dev/gvisor/pkg/sync"
"gvisor.dev/gvisor/pkg/tcpip/stack"

uspb "gvisor.dev/gvisor/pkg/sentry/unimpl/unimplemented_syscall_go_proto"
)
Expand Down Expand Up @@ -694,9 +693,7 @@ func (k *Kernel) SaveTo(ctx context.Context, stateFile, pagesMetadata io.WriteCl
if rootNS := k.rootNetworkNamespace; rootNS != nil && rootNS.Stack() != nil {
// Pause the network stack.
netstackPauseStart := time.Now()
if resume {
ctx = context.WithValue(ctx, stack.CtxResumeStack, resume)
} else {
if !resume {
k.rootNetworkNamespace.Stack().SetRemoveNICs()
}
log.Infof("Pausing root network namespace")
Expand Down
17 changes: 3 additions & 14 deletions pkg/tcpip/link/fdbased/processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,9 @@ func (m *processorManager) start() {

// afterLoad is invoked by stateify.
func (m *processorManager) afterLoad(ctx context.Context) {
// Do not start the processors for save/restore. New NICs and
// processors will be created during restore.
resume := stack.ResumeStackFromContext(ctx)
if !resume {
return
}
m.wg.Add(len(m.processors))
m.start()
// Close all the old/saved processors. There are new NICs and
// processors created during restore.
m.close()
}

func (m *processorManager) connectionHash(cid *connectionID) uint32 {
Expand Down Expand Up @@ -281,9 +276,3 @@ func (m *processorManager) wakeReady() {
m.ready[i] = false
}
}

// beforeSave is invoked by stateify.
func (m *processorManager) beforeSave() {
m.close()
m.wg.Wait()
}
13 changes: 0 additions & 13 deletions pkg/tcpip/stack/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -2521,9 +2521,6 @@ type contextID int
const (
// CtxRestoreStack is a Context.Value key for the stack to be used in restore.
CtxRestoreStack contextID = iota

// CtxResumeStack is a Context.Value key for the stack to be used in resume.
CtxResumeStack contextID = iota
)

// RestoreStackFromContext returns the stack to be used during restore.
Expand All @@ -2534,16 +2531,6 @@ func RestoreStackFromContext(ctx context.Context) *Stack {
return nil
}

// ResumeStackFromContext returns the stack to be used during restore.
func ResumeStackFromContext(ctx context.Context) bool {
// If we are resuming, the context should have a value set to true. If
// restoring it will be false or not exist.
if resume := ctx.Value(CtxResumeStack); resume != nil {
return resume.(bool)
}
return false
}

// SetRemoveNICs sets the removeNICs in stack to true during save/restore.
func (s *Stack) SetRemoveNICs() {
s.mu.Lock()
Expand Down
Loading