diff --git a/pkg/loxinet/layer2.go b/pkg/loxinet/layer2.go index 0aea6c805..cc1961c1d 100644 --- a/pkg/loxinet/layer2.go +++ b/pkg/loxinet/layer2.go @@ -111,7 +111,6 @@ func l2FdbAttrCopy(dst *FdbAttr, src *FdbAttr) { dst.Dst = src.Dst } - func (f *FdbEnt) tryResolveUpper(zn *Zone, addr net.IP) { if f.Port == nil { return @@ -121,7 +120,7 @@ func (f *FdbEnt) tryResolveUpper(zn *Zone, addr net.IP) { name = f.Port.SInfo.PortReal.Name } - ret, Sip, _ := zn.L3.IfaSelect(name, addr, true) + ret, Sip, _ := zn.L3.IfaSelect(name, addr, true) if ret != 0 { tk.LogIt(tk.LogDebug, "tryResolve: failed to select l3 ifa select (%s:%s)\n", name, addr.String()) return diff --git a/pkg/loxinet/loxinet.go b/pkg/loxinet/loxinet.go index 812881299..3dc52d160 100644 --- a/pkg/loxinet/loxinet.go +++ b/pkg/loxinet/loxinet.go @@ -207,6 +207,7 @@ func loxiNetInit() { RunCommand(MkfsScript, true) } } + utils.MkTunFsIfNotExist() sysctlInit() diff --git a/pkg/utils/net.go b/pkg/utils/net.go index e2a71fc0f..4dbbd4edf 100644 --- a/pkg/utils/net.go +++ b/pkg/utils/net.go @@ -23,9 +23,11 @@ import ( "crypto/x509" "encoding/binary" "errors" + "golang.org/x/sys/unix" "io" "net" "net/http" + "os" "syscall" "time" "unsafe" @@ -336,3 +338,21 @@ func ArpResolver(dIP uint32) { return } } + +func MkTunFsIfNotExist() error { + tunPath := "/dev/net" + tunFile := "/dev/net/tun" + if _, err := os.Stat(tunPath); os.IsNotExist(err) { + if err := os.MkdirAll("/dev/net", 0751); err != nil { + return err + } + } + + if _, err := os.Stat(tunFile); os.IsNotExist(err) { + dev := unix.Mkdev(10, 200) + if err := unix.Mknod("/dev/net/tun", 0600|unix.S_IFCHR, int(dev)); err != nil { + return err + } + } + return nil +}