From 1b31c86aad54da4f6d1df111ba80a7b34eeefd01 Mon Sep 17 00:00:00 2001 From: Murtaza Aliakbar Date: Tue, 28 Jan 2025 16:22:38 +0530 Subject: [PATCH] tunnel: wireup ownership info to netstack --- tunnel/tunnel.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index 8b964603..9a2a2050 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -29,6 +29,7 @@ import ( "fmt" "os" "path/filepath" + "strconv" "sync" "sync/atomic" "syscall" @@ -189,13 +190,15 @@ func NewGTunnel(pctx context.Context, fd, mtu int, l3 string, hdl netstack.GConn } netstack.Route(stack, l3) + who := strconv.Itoa(ep.Cur()) + var nic tcpip.NICID // Enabled() may temporarily return false when Up() is in progress. - if nic, err = netstack.Up(stack, ep, hdl); err != nil { // attach new endpoint + if nic, err = netstack.Up(who, stack, ep, hdl); err != nil { // attach new endpoint return nil, nil, err } - rev = netstack.NewReverseGConnHandler(pctx, stack, nic, ep, hdl) + rev = netstack.NewReverseGConnHandler(who, pctx, stack, nic, ep, hdl) log.I("tun: new netstack(%d) up; fd(%d=>%d), mtu(%d)", nic, fd, dupfd, mtu)