[PATCH] tun/netstack: close stack on netTun close

Nick Goossens ngoossens at duckduckgo.com
Mon Oct 23 14:33:47 UTC 2023


If the stack is not closed when closing netTun then goroutines
will be leaked because the the transport protocols remain open.
This adds the needed close call.

Signed-off-by: Nick Goossens <ngoossens at duckduckgo.com>
---
 tun/netstack/tun.go | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tun/netstack/tun.go b/tun/netstack/tun.go
index 2b73054..a06bc21 100644
--- a/tun/netstack/tun.go
+++ b/tun/netstack/tun.go
@@ -167,6 +167,7 @@ func (tun *netTun) WriteNotify() {
 
 func (tun *netTun) Close() error {
 	tun.stack.RemoveNIC(1)
+	tun.stack.Close()
 
 	if tun.events != nil {
 		close(tun.events)
-- 
2.42.0



More information about the WireGuard mailing list