From 434e58d261210ebfd60fe133c1b01f6804fbe06f Mon Sep 17 00:00:00 2001 From: Bhasker Hariharan Date: Tue, 25 Jan 2022 12:22:37 -0800 Subject: [PATCH] Remove NICs on stack shutdown to ensure qdisc cleanup. PiperOrigin-RevId: 424149803 --- pkg/tcpip/stack/stack.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/tcpip/stack/stack.go b/pkg/tcpip/stack/stack.go index cbcb32775..e4ba3a9b3 100644 --- a/pkg/tcpip/stack/stack.go +++ b/pkg/tcpip/stack/stack.go @@ -1530,9 +1530,13 @@ func (s *Stack) Wait() { p.Wait() } - s.mu.RLock() - defer s.mu.RUnlock() - for _, n := range s.nics { + s.mu.Lock() + defer s.mu.Unlock() + + for id, n := range s.nics { + // Remove NIC to ensure that qDisc goroutines are correctly + // terminated on stack teardown. + s.removeNICLocked(id) n.NetworkLinkEndpoint.Wait() } }