diff options
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{ |