Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-726 Added a proxy only mode #740

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading