diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-12-10 00:05:25 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-12-10 00:05:25 +0000 |
commit | 1faf5799ed1fb83a36c6433b22a7c8f495395943 (patch) | |
tree | f7409128707e75963a47d9b2b77adae4c4643b93 /pkg/tcpip | |
parent | e9cf884608ab709c8659683a39c6c37f471ebe1d (diff) | |
parent | 992769c7748d886e7ee1580f0c6cfdfa7ce0eb75 (diff) |
Merge release-20201130.0-71-g992769c77 (automated)
Diffstat (limited to 'pkg/tcpip')
-rw-r--r-- | pkg/tcpip/tcpip.go | 5 | ||||
-rw-r--r-- | pkg/tcpip/tcpip_state_autogen.go | 27 |
2 files changed, 30 insertions, 2 deletions
diff --git a/pkg/tcpip/tcpip.go b/pkg/tcpip/tcpip.go index 2bd472811..23e597365 100644 --- a/pkg/tcpip/tcpip.go +++ b/pkg/tcpip/tcpip.go @@ -49,8 +49,9 @@ const ipv4AddressSize = 4 // Error represents an error in the netstack error space. Using a special type // ensures that errors outside of this space are not accidentally introduced. // -// Note: to support save / restore, it is important that all tcpip errors have -// distinct error messages. +// All errors must have unique msg strings. +// +// +stateify savable type Error struct { msg string diff --git a/pkg/tcpip/tcpip_state_autogen.go b/pkg/tcpip/tcpip_state_autogen.go index 1be97b085..94e40e30e 100644 --- a/pkg/tcpip/tcpip_state_autogen.go +++ b/pkg/tcpip/tcpip_state_autogen.go @@ -74,6 +74,32 @@ func (so *SocketOptions) StateLoad(stateSourceObject state.Source) { stateSourceObject.Load(15, &so.corkOptionEnabled) } +func (e *Error) StateTypeName() string { + return "pkg/tcpip.Error" +} + +func (e *Error) StateFields() []string { + return []string{ + "msg", + "ignoreStats", + } +} + +func (e *Error) beforeSave() {} + +func (e *Error) StateSave(stateSinkObject state.Sink) { + e.beforeSave() + stateSinkObject.Save(0, &e.msg) + stateSinkObject.Save(1, &e.ignoreStats) +} + +func (e *Error) afterLoad() {} + +func (e *Error) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &e.msg) + stateSourceObject.Load(1, &e.ignoreStats) +} + func (f *FullAddress) StateTypeName() string { return "pkg/tcpip.FullAddress" } @@ -236,6 +262,7 @@ func (i *IPPacketInfo) StateLoad(stateSourceObject state.Source) { func init() { state.Register((*SocketOptions)(nil)) + state.Register((*Error)(nil)) state.Register((*FullAddress)(nil)) state.Register((*ControlMessages)(nil)) state.Register((*LinkPacketInfo)(nil)) |