From 514539b611082b89e4b4e7f4f6e8e6a1686ef0dc Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 23 Oct 2023 19:07:24 -0700 Subject: [PATCH] wgengine/magicsock: close disco listeners on Conn.Close, fix Linux root TestNewConn TestNewConn now passes as root on Linux. It wasn't closing the BPF listeners and their goroutines. The code is still a mess of two Close overlapping code paths, but that can be refactored later. For now, make the two close paths more similar. Updates #9945 Change-Id: I8a3cf5fb04d22ba29094243b8e645de293d9ed85 Signed-off-by: Brad Fitzpatrick --- wgengine/magicsock/magicsock.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index 0bc6a4113..5f1288e0e 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -2134,6 +2134,12 @@ func (c *Conn) Close() error { // They will frequently have been closed already by a call to connBind.Close. c.pconn6.Close() c.pconn4.Close() + if c.closeDisco4 != nil { + c.closeDisco4.Close() + } + if c.closeDisco6 != nil { + c.closeDisco6.Close() + } // Wait on goroutines updating right at the end, once everything is // already closed. We want everything else in the Conn to be