Skip to content

Commit df97ff9

Browse files
nybidarigvisor-bot
authored andcommitted
Do not close processors during save, but instead close during restore.
Before this change, the processors were closed in beforeSave which caused the packet processing for established connections to stop even in the case of save/resume. Do not close in beforeSave, instead close these processors in afterLoad for restore. PiperOrigin-RevId: 821714849
1 parent afee3fa commit df97ff9

File tree

3 files changed

+4
-31
lines changed

3 files changed

+4
-31
lines changed

pkg/sentry/kernel/kernel.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ import (
8080
"gvisor.dev/gvisor/pkg/sentry/vfs"
8181
"gvisor.dev/gvisor/pkg/state"
8282
"gvisor.dev/gvisor/pkg/sync"
83-
"gvisor.dev/gvisor/pkg/tcpip/stack"
8483

8584
uspb "gvisor.dev/gvisor/pkg/sentry/unimpl/unimplemented_syscall_go_proto"
8685
)
@@ -694,9 +693,7 @@ func (k *Kernel) SaveTo(ctx context.Context, stateFile, pagesMetadata io.WriteCl
694693
if rootNS := k.rootNetworkNamespace; rootNS != nil && rootNS.Stack() != nil {
695694
// Pause the network stack.
696695
netstackPauseStart := time.Now()
697-
if resume {
698-
ctx = context.WithValue(ctx, stack.CtxResumeStack, resume)
699-
} else {
696+
if !resume {
700697
k.rootNetworkNamespace.Stack().SetRemoveNICs()
701698
}
702699
log.Infof("Pausing root network namespace")

pkg/tcpip/link/fdbased/processors.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,9 @@ func (m *processorManager) start() {
128128

129129
// afterLoad is invoked by stateify.
130130
func (m *processorManager) afterLoad(ctx context.Context) {
131-
// Do not start the processors for save/restore. New NICs and
132-
// processors will be created during restore.
133-
resume := stack.ResumeStackFromContext(ctx)
134-
if !resume {
135-
return
136-
}
137-
m.wg.Add(len(m.processors))
138-
m.start()
131+
// Close all the old/saved processors. There are new NICs and
132+
// processors created during restore.
133+
m.close()
139134
}
140135

141136
func (m *processorManager) connectionHash(cid *connectionID) uint32 {
@@ -281,9 +276,3 @@ func (m *processorManager) wakeReady() {
281276
m.ready[i] = false
282277
}
283278
}
284-
285-
// beforeSave is invoked by stateify.
286-
func (m *processorManager) beforeSave() {
287-
m.close()
288-
m.wg.Wait()
289-
}

pkg/tcpip/stack/stack.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2521,9 +2521,6 @@ type contextID int
25212521
const (
25222522
// CtxRestoreStack is a Context.Value key for the stack to be used in restore.
25232523
CtxRestoreStack contextID = iota
2524-
2525-
// CtxResumeStack is a Context.Value key for the stack to be used in resume.
2526-
CtxResumeStack contextID = iota
25272524
)
25282525

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

2537-
// ResumeStackFromContext returns the stack to be used during restore.
2538-
func ResumeStackFromContext(ctx context.Context) bool {
2539-
// If we are resuming, the context should have a value set to true. If
2540-
// restoring it will be false or not exist.
2541-
if resume := ctx.Value(CtxResumeStack); resume != nil {
2542-
return resume.(bool)
2543-
}
2544-
return false
2545-
}
2546-
25472534
// SetRemoveNICs sets the removeNICs in stack to true during save/restore.
25482535
func (s *Stack) SetRemoveNICs() {
25492536
s.mu.Lock()

0 commit comments

Comments
 (0)