Skip to content

Commit acaa5a7

Browse files
nybidarigvisor-bot
authored andcommitted
Do not save timers in netstack.
Timers should not be saved and new timers if required, should be created during restore. PiperOrigin-RevId: 833505133
1 parent 4304bcd commit acaa5a7

File tree

8 files changed

+12
-22
lines changed

8 files changed

+12
-22
lines changed

pkg/tcpip/faketime/faketime.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import (
2525
)
2626

2727
// NullClock implements a clock that never advances.
28-
//
29-
// +stateify savable
3028
type NullClock struct{}
3129

3230
var _ tcpip.Clock = (*NullClock)(nil)
@@ -42,8 +40,6 @@ func (*NullClock) NowMonotonic() tcpip.MonotonicTime {
4240
}
4341

4442
// nullTimer implements a timer that never fires.
45-
//
46-
// +stateify savable
4743
type nullTimer struct{}
4844

4945
var _ tcpip.Timer = (*nullTimer)(nil)
@@ -96,9 +92,8 @@ func (n *notificationChannels) wait() {
9692
}
9793
}
9894

99-
// +stateify savable
10095
type manualClockMutex struct {
101-
sync.RWMutex `state:"nosave"`
96+
sync.RWMutex
10297

10398
// now is the current (fake) time of the clock.
10499
now time.Time
@@ -334,23 +329,19 @@ func (mc *ManualClock) stopTimer(mt *manualTimer) bool {
334329
return true
335330
}
336331

337-
// +stateify savable
338332
type manualTimerMu struct {
339-
sync.Mutex `state:"nosave"`
333+
sync.Mutex
340334

341335
// firesAt is the time when the timer will fire.
342336
//
343337
// Zero only when the timer is not active.
344338
firesAt time.Time
345339
}
346340

347-
// +stateify savable
348341
type manualTimer struct {
349342
clock *ManualClock
350-
// TODO(b/341946753): Restore when netstack is savable.
351-
f func() `state:"nosave"`
352-
353-
mu manualTimerMu
343+
f func()
344+
mu manualTimerMu
354345
}
355346

356347
var _ tcpip.Timer = (*manualTimer)(nil)

pkg/tcpip/network/internal/ip/duplicate_address_detection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type dadState struct {
3939
extendRequest extendRequest
4040

4141
done *bool
42-
timer tcpip.Timer
42+
timer tcpip.Timer `state:"nosave"`
4343

4444
completionHandlers []stack.DADCompletionHandler
4545
}

pkg/tcpip/network/internal/ip/generic_multicast_protocol.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,13 @@ type GenericMulticastProtocolState struct {
291291
robustnessVariable uint8
292292
queryInterval time.Duration
293293
mode protocolMode
294-
modeTimer tcpip.Timer
294+
modeTimer tcpip.Timer `state:"nosave"`
295295

296-
generalQueryV2Timer tcpip.Timer
296+
generalQueryV2Timer tcpip.Timer `state:"nosave"`
297297
// TODO(b/341946753): Restore when netstack is savable.
298298
generalQueryV2TimerFiresAt time.Time `state:"nosave"`
299299

300-
stateChangedReportV2Timer tcpip.Timer
300+
stateChangedReportV2Timer tcpip.Timer `state:"nosave"`
301301
stateChangedReportV2TimerSet bool
302302
}
303303

pkg/tcpip/network/internal/multicast/route_table.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type RouteTable struct {
5757
// cleanupPendingRoutesTimer is a timer that triggers a routine to remove
5858
// pending routes that are expired.
5959
// +checklocks:pendingMu
60-
cleanupPendingRoutesTimer tcpip.Timer
60+
cleanupPendingRoutesTimer tcpip.Timer `state:"nosave"`
6161
// +checklocks:pendingMu
6262
isCleanupRoutineRunning bool
6363

pkg/tcpip/network/ipv6/ndp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ type timer struct {
471471
// done indicates to the timer that the timer was stopped.
472472
done *bool
473473

474-
timer tcpip.Timer
474+
timer tcpip.Timer `state:"nosave"`
475475
}
476476

477477
// +stateify savable

pkg/tcpip/stack/iptables_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const (
8282
type IPTables struct {
8383
connections ConnTrack
8484

85-
reaper tcpip.Timer
85+
reaper tcpip.Timer `state:"nosave"`
8686

8787
mu ipTablesRWMutex `state:"nosave"`
8888
// v4Tables and v6tables map tableIDs to tables. They hold builtin

pkg/tcpip/stdclock.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ func (*stdClock) AfterFunc(d time.Duration, f func()) Timer {
9191
}
9292
}
9393

94-
// +stateify savable
9594
type stdTimer struct {
9695
t *time.Timer
9796
}

pkg/tcpip/timer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ import (
5959
//
6060
// +stateify savable
6161
type jobInstance struct {
62-
timer Timer
62+
timer Timer `state:"nosave"`
6363

6464
// Used to inform the timer to early return when it gets stopped while the
6565
// lock the timer tries to obtain when fired is held (T1 is a goroutine that

0 commit comments

Comments
 (0)