diff options
Diffstat (limited to 'pkg/tcpip')
-rw-r--r-- | pkg/tcpip/network/fragmentation/fragmentation.go | 8 | ||||
-rwxr-xr-x | pkg/tcpip/network/fragmentation/reassembler_list.go | 8 | ||||
-rwxr-xr-x | pkg/tcpip/stack/linkaddrentry_list.go | 8 | ||||
-rwxr-xr-x | pkg/tcpip/transport/icmp/icmp_packet_list.go | 8 | ||||
-rwxr-xr-x | pkg/tcpip/transport/packet/packet_list.go | 8 | ||||
-rwxr-xr-x | pkg/tcpip/transport/raw/raw_packet_list.go | 8 | ||||
-rwxr-xr-x | pkg/tcpip/transport/tcp/tcp_endpoint_list.go | 8 | ||||
-rwxr-xr-x | pkg/tcpip/transport/tcp/tcp_segment_list.go | 8 | ||||
-rwxr-xr-x | pkg/tcpip/transport/udp/udp_packet_list.go | 8 |
9 files changed, 53 insertions, 19 deletions
diff --git a/pkg/tcpip/network/fragmentation/fragmentation.go b/pkg/tcpip/network/fragmentation/fragmentation.go index 92f2aa13a..f42abc4bb 100644 --- a/pkg/tcpip/network/fragmentation/fragmentation.go +++ b/pkg/tcpip/network/fragmentation/fragmentation.go @@ -115,10 +115,12 @@ func (f *Fragmentation) Process(id uint32, first, last uint16, more bool, vv buf // Evict reassemblers if we are consuming more memory than highLimit until // we reach lowLimit. if f.size > f.highLimit { - tail := f.rList.Back() - for f.size > f.lowLimit && tail != nil { + for f.size > f.lowLimit { + tail := f.rList.Back() + if tail == nil { + break + } f.release(tail) - tail = tail.Prev() } } f.mu.Unlock() diff --git a/pkg/tcpip/network/fragmentation/reassembler_list.go b/pkg/tcpip/network/fragmentation/reassembler_list.go index d571d7ae5..a48422c97 100755 --- a/pkg/tcpip/network/fragmentation/reassembler_list.go +++ b/pkg/tcpip/network/fragmentation/reassembler_list.go @@ -135,8 +135,9 @@ func (l *reassemblerList) InsertBefore(a, e *reassembler) { // Remove removes e from l. func (l *reassemblerList) Remove(e *reassembler) { - prev := reassemblerElementMapper{}.linkerFor(e).Prev() - next := reassemblerElementMapper{}.linkerFor(e).Next() + linker := reassemblerElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { reassemblerElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *reassemblerList) Remove(e *reassembler) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/tcpip/stack/linkaddrentry_list.go b/pkg/tcpip/stack/linkaddrentry_list.go index 1494aeca1..6697281cd 100755 --- a/pkg/tcpip/stack/linkaddrentry_list.go +++ b/pkg/tcpip/stack/linkaddrentry_list.go @@ -135,8 +135,9 @@ func (l *linkAddrEntryList) InsertBefore(a, e *linkAddrEntry) { // Remove removes e from l. func (l *linkAddrEntryList) Remove(e *linkAddrEntry) { - prev := linkAddrEntryElementMapper{}.linkerFor(e).Prev() - next := linkAddrEntryElementMapper{}.linkerFor(e).Next() + linker := linkAddrEntryElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { linkAddrEntryElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *linkAddrEntryList) Remove(e *linkAddrEntry) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/tcpip/transport/icmp/icmp_packet_list.go b/pkg/tcpip/transport/icmp/icmp_packet_list.go index deeab60ae..ddee31adb 100755 --- a/pkg/tcpip/transport/icmp/icmp_packet_list.go +++ b/pkg/tcpip/transport/icmp/icmp_packet_list.go @@ -135,8 +135,9 @@ func (l *icmpPacketList) InsertBefore(a, e *icmpPacket) { // Remove removes e from l. func (l *icmpPacketList) Remove(e *icmpPacket) { - prev := icmpPacketElementMapper{}.linkerFor(e).Prev() - next := icmpPacketElementMapper{}.linkerFor(e).Next() + linker := icmpPacketElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { icmpPacketElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *icmpPacketList) Remove(e *icmpPacket) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/tcpip/transport/packet/packet_list.go b/pkg/tcpip/transport/packet/packet_list.go index e8c4cba0d..ad27c7c06 100755 --- a/pkg/tcpip/transport/packet/packet_list.go +++ b/pkg/tcpip/transport/packet/packet_list.go @@ -135,8 +135,9 @@ func (l *packetList) InsertBefore(a, e *packet) { // Remove removes e from l. func (l *packetList) Remove(e *packet) { - prev := packetElementMapper{}.linkerFor(e).Prev() - next := packetElementMapper{}.linkerFor(e).Next() + linker := packetElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { packetElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *packetList) Remove(e *packet) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/tcpip/transport/raw/raw_packet_list.go b/pkg/tcpip/transport/raw/raw_packet_list.go index a0138e8cc..e8c1bc997 100755 --- a/pkg/tcpip/transport/raw/raw_packet_list.go +++ b/pkg/tcpip/transport/raw/raw_packet_list.go @@ -135,8 +135,9 @@ func (l *rawPacketList) InsertBefore(a, e *rawPacket) { // Remove removes e from l. func (l *rawPacketList) Remove(e *rawPacket) { - prev := rawPacketElementMapper{}.linkerFor(e).Prev() - next := rawPacketElementMapper{}.linkerFor(e).Next() + linker := rawPacketElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { rawPacketElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *rawPacketList) Remove(e *rawPacket) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/tcpip/transport/tcp/tcp_endpoint_list.go b/pkg/tcpip/transport/tcp/tcp_endpoint_list.go index 32ac43dca..62c042aff 100755 --- a/pkg/tcpip/transport/tcp/tcp_endpoint_list.go +++ b/pkg/tcpip/transport/tcp/tcp_endpoint_list.go @@ -135,8 +135,9 @@ func (l *endpointList) InsertBefore(a, e *endpoint) { // Remove removes e from l. func (l *endpointList) Remove(e *endpoint) { - prev := endpointElementMapper{}.linkerFor(e).Prev() - next := endpointElementMapper{}.linkerFor(e).Next() + linker := endpointElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { endpointElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *endpointList) Remove(e *endpoint) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/tcpip/transport/tcp/tcp_segment_list.go b/pkg/tcpip/transport/tcp/tcp_segment_list.go index 9b21b87ad..27f17f037 100755 --- a/pkg/tcpip/transport/tcp/tcp_segment_list.go +++ b/pkg/tcpip/transport/tcp/tcp_segment_list.go @@ -135,8 +135,9 @@ func (l *segmentList) InsertBefore(a, e *segment) { // Remove removes e from l. func (l *segmentList) Remove(e *segment) { - prev := segmentElementMapper{}.linkerFor(e).Prev() - next := segmentElementMapper{}.linkerFor(e).Next() + linker := segmentElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { segmentElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *segmentList) Remove(e *segment) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/tcpip/transport/udp/udp_packet_list.go b/pkg/tcpip/transport/udp/udp_packet_list.go index 00535d242..2ae846eaa 100755 --- a/pkg/tcpip/transport/udp/udp_packet_list.go +++ b/pkg/tcpip/transport/udp/udp_packet_list.go @@ -135,8 +135,9 @@ func (l *udpPacketList) InsertBefore(a, e *udpPacket) { // Remove removes e from l. func (l *udpPacketList) Remove(e *udpPacket) { - prev := udpPacketElementMapper{}.linkerFor(e).Prev() - next := udpPacketElementMapper{}.linkerFor(e).Next() + linker := udpPacketElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { udpPacketElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *udpPacketList) Remove(e *udpPacket) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields |