From 64aee33ed0e1a422c3e2954de8f1d3f219ed14b8 Mon Sep 17 00:00:00 2001 From: Ghanan Gowripalan Date: Tue, 19 Oct 2021 16:27:33 -0700 Subject: Continue reaping bucket after reaping a tuple Reaping an expired tuple removes it from its bucket so we need to grab the succeeding tuple in the bucket before reaping the expired tuple. Before this change, only the first expired tuple in a bucket was reaped per reaper run on the bucket. This change just allows more connections to be reaped. PiperOrigin-RevId: 404392925 --- pkg/tcpip/stack/conntrack.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'pkg/tcpip') diff --git a/pkg/tcpip/stack/conntrack.go b/pkg/tcpip/stack/conntrack.go index 89f8ef09f..a3f403855 100644 --- a/pkg/tcpip/stack/conntrack.go +++ b/pkg/tcpip/stack/conntrack.go @@ -562,11 +562,16 @@ func (ct *ConnTrack) reapUnused(start int, prevInterval time.Duration) (int, tim idx = (i + start) % len(ct.buckets) bkt := &ct.buckets[idx] bkt.mu.Lock() - for tuple := bkt.tuples.Front(); tuple != nil; tuple = tuple.Next() { + for tuple := bkt.tuples.Front(); tuple != nil; { + // reapTupleLocked updates tuple's next pointer so we grab it here. + nextTuple := tuple.Next() + checked++ if ct.reapTupleLocked(tuple, idx, bkt, now) { expired++ } + + tuple = nextTuple } bkt.mu.Unlock() } -- cgit v1.2.3