From 40f5d9cc44305fed7ed64cf1d2e26e4c360d2e0d Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Thu, 19 Mar 2020 18:42:00 +0100 Subject: WIP add tuntap fd --- pkg/tcpip/config/config.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pkg/tcpip/config/config.go b/pkg/tcpip/config/config.go index d021bf6a3..4eb0eacaf 100644 --- a/pkg/tcpip/config/config.go +++ b/pkg/tcpip/config/config.go @@ -62,6 +62,7 @@ type Tuntap struct { Common `yaml:",inline"` Mode string `yaml:"mode"` Name string `yaml:"name"` + Fd int `yaml:"fd"` } type WireguardKey []byte @@ -163,13 +164,17 @@ func addTunLink(s *stack.Stack, nic tcpip.NICID, id string, tap bool, addr tcpip } var fd int - if tap { - fd, err = tun.OpenTAP(tunName) + if tuntap.Fd != 0 { + fd = tuntap.Fd } else { - fd, err = tun.Open(tunName) - } - if err != nil { - log.Fatalf("Open %s %b %s", err, tap, tunName) + if tap { + fd, err = tun.OpenTAP(tunName) + } else { + fd, err = tun.Open(tunName) + } + if err != nil { + log.Fatalf("Open %s %b %s", err, tap, tunName) + } } linkEP, err := fdbased.New(&fdbased.Options{ -- cgit v1.2.3