From 6c8a0b77d86910e38cb0b92d5c90111553206136 Mon Sep 17 00:00:00 2001 From: kshangx Date: Thu, 22 Feb 2024 17:39:10 -0800 Subject: [PATCH] Fix leak in netstack's tunnel The upstream netstack's virtual tunnel device has a leaky Close implementation - the virtual network is not being shut down properly. What's missing is this one line change to shut down all the go routines associated with the userspace networking stack. This change is verbatim copied from kshangx's PR - https://github.com/WireGuard/wireguard-go/pull/101 Signed-off-by: kshangx --- tun/netstack/tun.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tun/netstack/tun.go b/tun/netstack/tun.go index 37c879d5..efad5641 100644 --- a/tun/netstack/tun.go +++ b/tun/netstack/tun.go @@ -157,6 +157,7 @@ func (tun *netTun) Flush() error { func (tun *netTun) Close() error { tun.stack.RemoveNIC(1) + tun.stack.Close() if tun.events != nil { close(tun.events)