Skip to content

Commit 0bb00ae

Browse files
manninglucasgvisor-bot
authored andcommitted
Check if CtxResumeStack exists in ResumeStackFromContext.
This change also removes the check for "resume" from processor's afterLoad. This method is only invoked on restore. PiperOrigin-RevId: 807408179
1 parent 9041e23 commit 0bb00ae

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pkg/tcpip/stack/stack.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2528,12 +2528,20 @@ const (
25282528

25292529
// RestoreStackFromContext returns the stack to be used during restore.
25302530
func RestoreStackFromContext(ctx context.Context) *Stack {
2531-
return ctx.Value(CtxRestoreStack).(*Stack)
2531+
if st := ctx.Value(CtxRestoreStack); st != nil {
2532+
return st.(*Stack)
2533+
}
2534+
return nil
25322535
}
25332536

25342537
// ResumeStackFromContext returns the stack to be used during restore.
25352538
func ResumeStackFromContext(ctx context.Context) bool {
2536-
return ctx.Value(CtxResumeStack).(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
25372545
}
25382546

25392547
// SetRemoveNICs sets the removeNICs in stack to true during save/restore.

0 commit comments

Comments
 (0)