Skip to content

Commit

Permalink
Merge pull request #678 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
gh-654 loxilb non-privileged mode support for k8s
  • Loading branch information
UltraInstinct14 authored May 14, 2024
2 parents 0d472b0 + 19ea58c commit d241544
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/loxinet/layer2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/loxinet/loxinet.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ func loxiNetInit() {
RunCommand(MkfsScript, true)
}
}
utils.MkTunFsIfNotExist()

sysctlInit()

Expand Down
20 changes: 20 additions & 0 deletions pkg/utils/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ import (
"crypto/x509"
"encoding/binary"
"errors"
"golang.org/x/sys/unix"
"io"
"net"
"net/http"
"os"
"syscall"
"time"
"unsafe"
Expand Down Expand Up @@ -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
}

0 comments on commit d241544

Please sign in to comment.