diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-06-24 06:37:35 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-06-24 06:37:35 +0000 |
commit | 9183888b520beeee8609170819a28bea89202909 (patch) | |
tree | 3cdcfa4de9ced4c539ab7c57e4cf58ffea980f6c /pkg/tcpip/transport/packet | |
parent | cab13958a54419262aba2a0cd7f1075ed02c8ee0 (diff) | |
parent | 364ac92baf83f2352f78b718090472639bd92a76 (diff) |
Merge release-20200608.0-119-g364ac92ba (automated)
Diffstat (limited to 'pkg/tcpip/transport/packet')
-rw-r--r-- | pkg/tcpip/transport/packet/packet_list.go | 6 | ||||
-rw-r--r-- | pkg/tcpip/transport/packet/packet_state_autogen.go | 165 |
2 files changed, 116 insertions, 55 deletions
diff --git a/pkg/tcpip/transport/packet/packet_list.go b/pkg/tcpip/transport/packet/packet_list.go index 5231b066f..22a41872a 100644 --- a/pkg/tcpip/transport/packet/packet_list.go +++ b/pkg/tcpip/transport/packet/packet_list.go @@ -56,7 +56,7 @@ func (l *packetList) Back() *packet { // // NOTE: This is an O(n) operation. func (l *packetList) Len() (count int) { - for e := l.Front(); e != nil; e = e.Next() { + for e := l.Front(); e != nil; e = (packetElementMapper{}.linkerFor(e)).Next() { count++ } return count @@ -148,13 +148,13 @@ func (l *packetList) Remove(e *packet) { if prev != nil { packetElementMapper{}.linkerFor(prev).SetNext(next) - } else { + } else if l.head == e { l.head = next } if next != nil { packetElementMapper{}.linkerFor(next).SetPrev(prev) - } else { + } else if l.tail == e { l.tail = prev } diff --git a/pkg/tcpip/transport/packet/packet_state_autogen.go b/pkg/tcpip/transport/packet/packet_state_autogen.go index 8ff339e08..209b6dcb0 100644 --- a/pkg/tcpip/transport/packet/packet_state_autogen.go +++ b/pkg/tcpip/transport/packet/packet_state_autogen.go @@ -7,84 +7,145 @@ import ( "gvisor.dev/gvisor/pkg/tcpip/buffer" ) +func (x *packet) StateTypeName() string { + return "pkg/tcpip/transport/packet.packet" +} + +func (x *packet) StateFields() []string { + return []string{ + "packetEntry", + "data", + "timestampNS", + "senderAddr", + } +} + func (x *packet) beforeSave() {} -func (x *packet) save(m state.Map) { + +func (x *packet) StateSave(m state.Sink) { x.beforeSave() var data buffer.VectorisedView = x.saveData() - m.SaveValue("data", data) - m.Save("packetEntry", &x.packetEntry) - m.Save("timestampNS", &x.timestampNS) - m.Save("senderAddr", &x.senderAddr) + m.SaveValue(1, data) + m.Save(0, &x.packetEntry) + m.Save(2, &x.timestampNS) + m.Save(3, &x.senderAddr) } func (x *packet) afterLoad() {} -func (x *packet) load(m state.Map) { - m.Load("packetEntry", &x.packetEntry) - 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 *packet) StateLoad(m state.Source) { + m.Load(0, &x.packetEntry) + 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/packet.endpoint" +} + +func (x *endpoint) StateFields() []string { + return []string{ + "TransportEndpointInfo", + "netProto", + "waiterQueue", + "cooked", + "rcvList", + "rcvBufSizeMax", + "rcvBufSize", + "rcvClosed", + "sndBufSize", + "closed", + "bound", + } +} + +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("netProto", &x.netProto) - m.Save("waiterQueue", &x.waiterQueue) - m.Save("cooked", &x.cooked) - m.Save("rcvList", &x.rcvList) - m.Save("rcvBufSize", &x.rcvBufSize) - m.Save("rcvClosed", &x.rcvClosed) - m.Save("sndBufSize", &x.sndBufSize) - m.Save("closed", &x.closed) - m.Save("bound", &x.bound) -} - -func (x *endpoint) load(m state.Map) { - m.Load("TransportEndpointInfo", &x.TransportEndpointInfo) - m.Load("netProto", &x.netProto) - m.Load("waiterQueue", &x.waiterQueue) - m.Load("cooked", &x.cooked) - m.Load("rcvList", &x.rcvList) - m.Load("rcvBufSize", &x.rcvBufSize) - m.Load("rcvClosed", &x.rcvClosed) - m.Load("sndBufSize", &x.sndBufSize) - m.Load("closed", &x.closed) - m.Load("bound", &x.bound) - 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.netProto) + m.Save(2, &x.waiterQueue) + m.Save(3, &x.cooked) + m.Save(4, &x.rcvList) + m.Save(6, &x.rcvBufSize) + m.Save(7, &x.rcvClosed) + m.Save(8, &x.sndBufSize) + m.Save(9, &x.closed) + m.Save(10, &x.bound) +} + +func (x *endpoint) StateLoad(m state.Source) { + m.Load(0, &x.TransportEndpointInfo) + m.Load(1, &x.netProto) + m.Load(2, &x.waiterQueue) + m.Load(3, &x.cooked) + m.Load(4, &x.rcvList) + m.Load(6, &x.rcvBufSize) + m.Load(7, &x.rcvClosed) + m.Load(8, &x.sndBufSize) + m.Load(9, &x.closed) + m.Load(10, &x.bound) + m.LoadValue(5, new(int), func(y interface{}) { x.loadRcvBufSizeMax(y.(int)) }) m.AfterLoad(x.afterLoad) } +func (x *packetList) StateTypeName() string { + return "pkg/tcpip/transport/packet.packetList" +} + +func (x *packetList) StateFields() []string { + return []string{ + "head", + "tail", + } +} + func (x *packetList) beforeSave() {} -func (x *packetList) save(m state.Map) { + +func (x *packetList) 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 *packetList) afterLoad() {} -func (x *packetList) load(m state.Map) { - m.Load("head", &x.head) - m.Load("tail", &x.tail) + +func (x *packetList) StateLoad(m state.Source) { + m.Load(0, &x.head) + m.Load(1, &x.tail) +} + +func (x *packetEntry) StateTypeName() string { + return "pkg/tcpip/transport/packet.packetEntry" +} + +func (x *packetEntry) StateFields() []string { + return []string{ + "next", + "prev", + } } func (x *packetEntry) beforeSave() {} -func (x *packetEntry) save(m state.Map) { + +func (x *packetEntry) 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 *packetEntry) afterLoad() {} -func (x *packetEntry) load(m state.Map) { - m.Load("next", &x.next) - m.Load("prev", &x.prev) + +func (x *packetEntry) StateLoad(m state.Source) { + m.Load(0, &x.next) + m.Load(1, &x.prev) } func init() { - state.Register("pkg/tcpip/transport/packet.packet", (*packet)(nil), state.Fns{Save: (*packet).save, Load: (*packet).load}) - state.Register("pkg/tcpip/transport/packet.endpoint", (*endpoint)(nil), state.Fns{Save: (*endpoint).save, Load: (*endpoint).load}) - state.Register("pkg/tcpip/transport/packet.packetList", (*packetList)(nil), state.Fns{Save: (*packetList).save, Load: (*packetList).load}) - state.Register("pkg/tcpip/transport/packet.packetEntry", (*packetEntry)(nil), state.Fns{Save: (*packetEntry).save, Load: (*packetEntry).load}) + state.Register((*packet)(nil)) + state.Register((*endpoint)(nil)) + state.Register((*packetList)(nil)) + state.Register((*packetEntry)(nil)) } |