From 12f6b63c3169215276f98ac44dc1bb5f37fb77d8 Mon Sep 17 00:00:00 2001 From: Kevin Krakauer Date: Thu, 15 Jun 2023 12:48:58 -0700 Subject: [PATCH] netstack: clear buckets upon close It was possible for `close` and `dispatch` to race, each trying to `DecRef` the same packet. We now clear the bucket of packets upon `close` so that `DecRef` occurs only once. PiperOrigin-RevId: 540663408 --- pkg/tcpip/stack/gro.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/tcpip/stack/gro.go b/pkg/tcpip/stack/gro.go index fc9be3d23..2a2a30131 100644 --- a/pkg/tcpip/stack/gro.go +++ b/pkg/tcpip/stack/gro.go @@ -678,8 +678,9 @@ func (gd *groDispatcher) close() { for i := range gd.buckets { bucket := &gd.buckets[i] bucket.mu.Lock() - for groPkt := bucket.packets.Front(); groPkt != nil; groPkt = groPkt.Next() { + for groPkt := bucket.packets.Front(); groPkt != nil; groPkt = bucket.packets.Front() { groPkt.pkt.DecRef() + bucket.removeOne(groPkt) } bucket.mu.Unlock() }