diff options
Diffstat (limited to 'pkg/tcpip/transport/raw')
-rw-r--r-- | pkg/tcpip/transport/raw/raw_packet_list.go | 6 | ||||
-rw-r--r-- | pkg/tcpip/transport/raw/raw_state_autogen.go | 175 |
2 files changed, 122 insertions, 59 deletions
diff --git a/pkg/tcpip/transport/raw/raw_packet_list.go b/pkg/tcpip/transport/raw/raw_packet_list.go index 15a8c845b..5f955e86a 100644 --- a/pkg/tcpip/transport/raw/raw_packet_list.go +++ b/pkg/tcpip/transport/raw/raw_packet_list.go @@ -56,7 +56,7 @@ func (l *rawPacketList) Back() *rawPacket { // // NOTE: This is an O(n) operation. func (l *rawPacketList) Len() (count int) { - for e := l.Front(); e != nil; e = e.Next() { + for e := l.Front(); e != nil; e = (rawPacketElementMapper{}.linkerFor(e)).Next() { count++ } return count @@ -148,13 +148,13 @@ func (l *rawPacketList) Remove(e *rawPacket) { if prev != nil { rawPacketElementMapper{}.linkerFor(prev).SetNext(next) - } else { + } else if l.head == e { l.head = next } if next != nil { rawPacketElementMapper{}.linkerFor(next).SetPrev(prev) - } else { + } else if l.tail == e { l.tail = prev } diff --git a/pkg/tcpip/transport/raw/raw_state_autogen.go b/pkg/tcpip/transport/raw/raw_state_autogen.go index 875ebda36..669477cf9 100644 --- a/pkg/tcpip/transport/raw/raw_state_autogen.go +++ b/pkg/tcpip/transport/raw/raw_state_autogen.go @@ -7,88 +7,151 @@ import ( "gvisor.dev/gvisor/pkg/tcpip/buffer" ) +func (x *rawPacket) StateTypeName() string { + return "pkg/tcpip/transport/raw.rawPacket" +} + +func (x *rawPacket) StateFields() []string { + return []string{ + "rawPacketEntry", + "data", + "timestampNS", + "senderAddr", + } +} + func (x *rawPacket) beforeSave() {} -func (x *rawPacket) save(m state.Map) { + +func (x *rawPacket) StateSave(m state.Sink) { x.beforeSave() var data buffer.VectorisedView = x.saveData() - m.SaveValue("data", data) - m.Save("rawPacketEntry", &x.rawPacketEntry) - m.Save("timestampNS", &x.timestampNS) - m.Save("senderAddr", &x.senderAddr) + m.SaveValue(1, data) + m.Save(0, &x.rawPacketEntry) + m.Save(2, &x.timestampNS) + m.Save(3, &x.senderAddr) } func (x *rawPacket) afterLoad() {} -func (x *rawPacket) load(m state.Map) { - m.Load("rawPacketEntry", &x.rawPacketEntry) - m.Load("timestampNS", &x.timestampNS) - m.Load("senderAddr", &x.senderAddr) - m.LoadValue("data", new(buffer.VectorisedView), func(y interface{}) { x.loadData(y.(buffer.VectorisedView)) }) + +func (x *rawPacket) StateLoad(m state.Source) { + m.Load(0, &x.rawPacketEntry) + m.Load(2, &x.timestampNS) + m.Load(3, &x.senderAddr) + m.LoadValue(1, new(buffer.VectorisedView), func(y interface{}) { x.loadData(y.(buffer.VectorisedView)) }) } -func (x *endpoint) save(m state.Map) { +func (x *endpoint) StateTypeName() string { + return "pkg/tcpip/transport/raw.endpoint" +} + +func (x *endpoint) StateFields() []string { + return []string{ + "TransportEndpointInfo", + "waiterQueue", + "associated", + "rcvList", + "rcvBufSize", + "rcvBufSizeMax", + "rcvClosed", + "sndBufSize", + "sndBufSizeMax", + "closed", + "connected", + "bound", + "owner", + } +} + +func (x *endpoint) StateSave(m state.Sink) { x.beforeSave() var rcvBufSizeMax int = x.saveRcvBufSizeMax() - m.SaveValue("rcvBufSizeMax", rcvBufSizeMax) - m.Save("TransportEndpointInfo", &x.TransportEndpointInfo) - m.Save("waiterQueue", &x.waiterQueue) - m.Save("associated", &x.associated) - m.Save("rcvList", &x.rcvList) - m.Save("rcvBufSize", &x.rcvBufSize) - m.Save("rcvClosed", &x.rcvClosed) - m.Save("sndBufSize", &x.sndBufSize) - m.Save("sndBufSizeMax", &x.sndBufSizeMax) - m.Save("closed", &x.closed) - m.Save("connected", &x.connected) - m.Save("bound", &x.bound) - m.Save("owner", &x.owner) -} - -func (x *endpoint) load(m state.Map) { - m.Load("TransportEndpointInfo", &x.TransportEndpointInfo) - m.Load("waiterQueue", &x.waiterQueue) - m.Load("associated", &x.associated) - m.Load("rcvList", &x.rcvList) - m.Load("rcvBufSize", &x.rcvBufSize) - m.Load("rcvClosed", &x.rcvClosed) - m.Load("sndBufSize", &x.sndBufSize) - m.Load("sndBufSizeMax", &x.sndBufSizeMax) - m.Load("closed", &x.closed) - m.Load("connected", &x.connected) - m.Load("bound", &x.bound) - m.Load("owner", &x.owner) - m.LoadValue("rcvBufSizeMax", new(int), func(y interface{}) { x.loadRcvBufSizeMax(y.(int)) }) + m.SaveValue(5, rcvBufSizeMax) + m.Save(0, &x.TransportEndpointInfo) + m.Save(1, &x.waiterQueue) + m.Save(2, &x.associated) + m.Save(3, &x.rcvList) + m.Save(4, &x.rcvBufSize) + m.Save(6, &x.rcvClosed) + m.Save(7, &x.sndBufSize) + m.Save(8, &x.sndBufSizeMax) + m.Save(9, &x.closed) + m.Save(10, &x.connected) + m.Save(11, &x.bound) + m.Save(12, &x.owner) +} + +func (x *endpoint) StateLoad(m state.Source) { + m.Load(0, &x.TransportEndpointInfo) + m.Load(1, &x.waiterQueue) + m.Load(2, &x.associated) + m.Load(3, &x.rcvList) + m.Load(4, &x.rcvBufSize) + m.Load(6, &x.rcvClosed) + m.Load(7, &x.sndBufSize) + m.Load(8, &x.sndBufSizeMax) + m.Load(9, &x.closed) + m.Load(10, &x.connected) + m.Load(11, &x.bound) + m.Load(12, &x.owner) + m.LoadValue(5, new(int), func(y interface{}) { x.loadRcvBufSizeMax(y.(int)) }) m.AfterLoad(x.afterLoad) } +func (x *rawPacketList) StateTypeName() string { + return "pkg/tcpip/transport/raw.rawPacketList" +} + +func (x *rawPacketList) StateFields() []string { + return []string{ + "head", + "tail", + } +} + func (x *rawPacketList) beforeSave() {} -func (x *rawPacketList) save(m state.Map) { + +func (x *rawPacketList) StateSave(m state.Sink) { x.beforeSave() - m.Save("head", &x.head) - m.Save("tail", &x.tail) + m.Save(0, &x.head) + m.Save(1, &x.tail) } func (x *rawPacketList) afterLoad() {} -func (x *rawPacketList) load(m state.Map) { - m.Load("head", &x.head) - m.Load("tail", &x.tail) + +func (x *rawPacketList) StateLoad(m state.Source) { + m.Load(0, &x.head) + m.Load(1, &x.tail) +} + +func (x *rawPacketEntry) StateTypeName() string { + return "pkg/tcpip/transport/raw.rawPacketEntry" +} + +func (x *rawPacketEntry) StateFields() []string { + return []string{ + "next", + "prev", + } } func (x *rawPacketEntry) beforeSave() {} -func (x *rawPacketEntry) save(m state.Map) { + +func (x *rawPacketEntry) StateSave(m state.Sink) { x.beforeSave() - m.Save("next", &x.next) - m.Save("prev", &x.prev) + m.Save(0, &x.next) + m.Save(1, &x.prev) } func (x *rawPacketEntry) afterLoad() {} -func (x *rawPacketEntry) load(m state.Map) { - m.Load("next", &x.next) - m.Load("prev", &x.prev) + +func (x *rawPacketEntry) StateLoad(m state.Source) { + m.Load(0, &x.next) + m.Load(1, &x.prev) } func init() { - state.Register("pkg/tcpip/transport/raw.rawPacket", (*rawPacket)(nil), state.Fns{Save: (*rawPacket).save, Load: (*rawPacket).load}) - state.Register("pkg/tcpip/transport/raw.endpoint", (*endpoint)(nil), state.Fns{Save: (*endpoint).save, Load: (*endpoint).load}) - state.Register("pkg/tcpip/transport/raw.rawPacketList", (*rawPacketList)(nil), state.Fns{Save: (*rawPacketList).save, Load: (*rawPacketList).load}) - state.Register("pkg/tcpip/transport/raw.rawPacketEntry", (*rawPacketEntry)(nil), state.Fns{Save: (*rawPacketEntry).save, Load: (*rawPacketEntry).load}) + state.Register((*rawPacket)(nil)) + state.Register((*endpoint)(nil)) + state.Register((*rawPacketList)(nil)) + state.Register((*rawPacketEntry)(nil)) } |