mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Restore listening connections when netstack s/r is enabled.
This CL restores the listening connections when netstack s/r is enabled. The changes include: - New method as a workaround to replace the new routes and nics to the loaded stack after restore. - New Restore() for transport layer protocols to restore the protocol level background workers. - Adds afterLoad() method for fdbased processors. - Adds a test to verify listening connection is restored after checkpointing with netstack s/r enabled. - Few other changes to save restore fields to enable netstack s/r. PiperOrigin-RevId: 698453124
This commit is contained in:
committed by
gVisor bot
parent
488d5d2f48
commit
df9ba5fb67
@@ -34,7 +34,7 @@ func (s *sock) loadTimestamp(_ context.Context, nsec int64) {
|
||||
}
|
||||
|
||||
func (s *Stack) saveStack() *stack.Stack {
|
||||
if s.shouldSaveRestoreStack {
|
||||
if s.IsSaveRestoreEnabled() {
|
||||
return s.Stack
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
|
||||
// afterLoad is invoked by stateify.
|
||||
func (s *Stack) afterLoad(ctx context.Context) {
|
||||
if s.shouldSaveRestoreStack {
|
||||
if s.IsSaveRestoreEnabled() {
|
||||
// This indicates that netstack s/r is enabled and the stack
|
||||
// should not be replaced with the new stack from context.
|
||||
return
|
||||
|
||||
@@ -40,16 +40,23 @@ import (
|
||||
//
|
||||
// +stateify savable
|
||||
type Stack struct {
|
||||
Stack *stack.Stack `state:".(*stack.Stack)"`
|
||||
shouldSaveRestoreStack bool
|
||||
Stack *stack.Stack `state:".(*stack.Stack)"`
|
||||
}
|
||||
|
||||
// EnableSaveRestore enables netstack s/r.
|
||||
func (s *Stack) EnableSaveRestore() error {
|
||||
s.shouldSaveRestoreStack = true
|
||||
s.Stack.EnableSaveRestore()
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsSaveRestoreEnabled implements inet.Stack.IsSaveRestoreEnabled.
|
||||
func (s *Stack) IsSaveRestoreEnabled() bool {
|
||||
if s.Stack == nil {
|
||||
return false
|
||||
}
|
||||
return s.Stack.IsSaveRestoreEnabled()
|
||||
}
|
||||
|
||||
// Destroy implements inet.Stack.Destroy.
|
||||
func (s *Stack) Destroy() {
|
||||
s.Stack.Close()
|
||||
@@ -912,6 +919,14 @@ func (s *Stack) Restore() {
|
||||
s.Stack.Restore()
|
||||
}
|
||||
|
||||
// ReplaceConfig implements inet.Stack.ReplaceConfig.
|
||||
func (s *Stack) ReplaceConfig(st inet.Stack) {
|
||||
if _, ok := st.(*Stack); !ok {
|
||||
panic("netstack.Stack cannot be nil when netstack s/r is enabled")
|
||||
}
|
||||
s.Stack.ReplaceConfig(st.(*Stack).Stack)
|
||||
}
|
||||
|
||||
// Resume implements inet.Stack.Resume.
|
||||
func (s *Stack) Resume() {
|
||||
s.Stack.Resume()
|
||||
|
||||
Reference in New Issue
Block a user