summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/tcpip')
-rw-r--r--pkg/tcpip/tcpip.go5
-rw-r--r--pkg/tcpip/tcpip_state_autogen.go27
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))