diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-03-19 18:42:00 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-03-19 18:42:00 +0100 |
commit | 40f5d9cc44305fed7ed64cf1d2e26e4c360d2e0d (patch) | |
tree | 7f9cb39716fe7e4218fb1d26a638fe4a1dbb65e4 /pkg/tcpip/config/config.go | |
parent | b3a4513d3d17f10dee499e42db184fc89917bcd5 (diff) |
WIP add tuntap fd
Diffstat (limited to 'pkg/tcpip/config/config.go')
-rw-r--r-- | pkg/tcpip/config/config.go | 17 |
1 files 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{ |