Skip to content

Commit

Permalink
Merge pull request #740 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
gh-726 Added a proxy only mode
  • Loading branch information
UltraInstinct14 authored Jul 25, 2024
2 parents 999a94e + 1cc75f3 commit d91a7dc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion loxilb-ebpf
1 change: 1 addition & 0 deletions options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ var Opts struct {
LocalSockPolicy bool `long:"localsockpolicy" description:"support local socket policies (experimental)"`
SockMapSupport bool `long:"sockmapsupport" description:"Support sockmap based L4 proxying (experimental)"`
ConfigPath string `long:"config-path" description:"Config file path" default:"/etc/loxilb/"`
ProxyModeOnly bool `long:"proxyonlymode" description:"Run loxilb in proxy mode only, no Datapath"`
}
14 changes: 13 additions & 1 deletion pkg/loxinet/dpebpf_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func DpEbpfSetLogLevel(logLevel tk.LogLevelT) {
}

// DpEbpfInit - initialize the ebpf dp subsystem
func DpEbpfInit(clusterEn, rssEn, egrHooks, localSockPolicy, sockMapEn bool, nodeNum int, logLevel tk.LogLevelT) *DpEbpfH {
func DpEbpfInit(clusterEn, rssEn, egrHooks, localSockPolicy, sockMapEn bool, nodeNum int, disBPF bool, logLevel tk.LogLevelT) *DpEbpfH {
var cfg C.struct_ebpfcfg

if clusterEn {
Expand All @@ -291,6 +291,12 @@ func DpEbpfInit(clusterEn, rssEn, egrHooks, localSockPolicy, sockMapEn bool, nod
cfg.have_sockmap = 0
}

if disBPF {
cfg.have_noebpf = 1
} else {
cfg.have_noebpf = 0
}

cfg.nodenum = C.int(nodeNum)
cfg.loglevel = 1
cfg.no_loader = 0
Expand Down Expand Up @@ -404,6 +410,9 @@ func convDPv6Addr2NetIP(addr unsafe.Pointer) net.IP {

// loadEbpfPgm - load loxilb eBPF program to an interface
func (e *DpEbpfH) loadEbpfPgm(name string) int {
if mh.disBPF {
return 0
}
ifStr := C.CString(name)
xSection := C.CString(string(C.XDP_LL_SEC_DEFAULT))
link, err := nlp.LinkByName(name)
Expand Down Expand Up @@ -439,6 +448,9 @@ func (e *DpEbpfH) loadEbpfPgm(name string) int {

// unLoadEbpfPgm - unload loxilb eBPF program from an interface
func (e *DpEbpfH) unLoadEbpfPgm(name string) int {
if mh.disBPF {
return 0
}
ifStr := C.CString(name)
xSection := C.CString(string(C.XDP_LL_SEC_DEFAULT))

Expand Down
4 changes: 3 additions & 1 deletion pkg/loxinet/loxinet.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type loxiNetH struct {
eHooks bool
lSockPolicy bool
sockMapEn bool
disBPF bool
pFile *os.File
}

Expand Down Expand Up @@ -219,6 +220,7 @@ func loxiNetInit() {
mh.pProbe = opts.Opts.PassiveEPProbe
mh.lSockPolicy = opts.Opts.LocalSockPolicy
mh.sockMapEn = opts.Opts.SockMapSupport
mh.disBPF = opts.Opts.ProxyModeOnly
mh.sigCh = make(chan os.Signal, 5)
signal.Notify(mh.sigCh, os.Interrupt, syscall.SIGCHLD, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)

Expand Down Expand Up @@ -247,7 +249,7 @@ func loxiNetInit() {
RunCommand(MkMountCG2, false)
}
// Initialize the ebpf datapath subsystem
mh.dpEbpf = DpEbpfInit(clusterMode, mh.rssEn, mh.eHooks, mh.lSockPolicy, mh.sockMapEn, mh.self, -1)
mh.dpEbpf = DpEbpfInit(clusterMode, mh.rssEn, mh.eHooks, mh.lSockPolicy, mh.sockMapEn, mh.self, mh.disBPF, -1)
mh.dp = DpBrokerInit(mh.dpEbpf, rpcMode)

// Initialize the security zone subsystem
Expand Down

0 comments on commit d91a7dc

Please sign in to comment.