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

chore: go packages reorganized #616

Merged
merged 4 commits into from
Apr 1, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion loxilb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package main

import (
"fmt"
ln "github.com/loxilb-io/loxilb/loxinet"
ln "github.com/loxilb-io/loxilb/pkg/loxinet"
"testing"
)

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"time"

"github.com/jessevdk/go-flags"
ln "github.com/loxilb-io/loxilb/loxinet"
opts "github.com/loxilb-io/loxilb/options"
ln "github.com/loxilb-io/loxilb/pkg/loxinet"
)

var version string = "0.9.2-beta"
Expand Down
File renamed without changes.
33 changes: 15 additions & 18 deletions loxinet/cluster.go → pkg/loxinet/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@ package loxinet

import (
"errors"
"fmt"
nlp "github.com/loxilb-io/loxilb/api/loxinlp"
cmn "github.com/loxilb-io/loxilb/common"
bfd "github.com/loxilb-io/loxilb/pkg/proto"
tk "github.com/loxilb-io/loxilib"
"net"
"os"
"time"

cmn "github.com/loxilb-io/loxilb/common"
opts "github.com/loxilb-io/loxilb/options"
bfd "github.com/loxilb-io/loxilb/proto"
tk "github.com/loxilb-io/loxilib"
)

// error codes for cluster module
Expand Down Expand Up @@ -83,13 +80,9 @@ func (ci *CIStateH) BFDSessionNotify(instance string, remote string, ciState str
}

func (ci *CIStateH) startBFDProto(bfdSessConfigArgs bfd.ConfigArgs) {
url := fmt.Sprintf("http://127.0.0.1:%d/config/params", opts.Opts.Port)
for {
if IsLoxiAPIActive(url) {
break
}
tk.LogIt(tk.LogDebug, "KA - waiting for API server\n")
time.Sleep(1 * time.Second)

if ci.Bs == nil {
return
}

mh.dp.WaitXsyncReady("ka")
Expand Down Expand Up @@ -275,6 +268,10 @@ func (h *CIStateH) ClusterNodeDelete(node cmn.ClusterNodeMod) (int, error) {
// CIBFDSessionAdd - routine to add BFD session
func (h *CIStateH) CIBFDSessionAdd(bm cmn.BFDMod) (int, error) {

if h.Bs == nil {
return -1, errors.New("bfd not initialized")
}

if bm.Interval != 0 && bm.Interval < bfd.BFDMinSysTXIntervalUs {
tk.LogIt(tk.LogError, "[CLUSTER] BFD session Interval value too low\n")
return -1, errors.New("bfd interval too low")
Expand Down Expand Up @@ -308,15 +305,15 @@ func (h *CIStateH) CIBFDSessionAdd(bm cmn.BFDMod) (int, error) {
Multi: bm.RetryCount, Instance: bm.Instance}
go h.startBFDProto(bfdSessConfigArgs)
} else {
bfdSessConfigArgs := bfd.ConfigArgs{RemoteIP: h.RemoteIP.String(), SourceIP: h.SourceIP.String(),
bfdSessConfigArgs := bfd.ConfigArgs{RemoteIP: bm.RemoteIP.String(), SourceIP: bm.SourceIP.String(),
Port: cmn.BFDPort, Interval: uint32(bm.Interval),
Multi: bm.RetryCount, Instance: bm.Instance}
err := h.Bs.BFDAddRemote(bfdSessConfigArgs, h)
if err != nil {
tk.LogIt(tk.LogCritical, "KA - Cant add BFD remote: %s\n", err.Error())
return -1, err
}
tk.LogIt(tk.LogInfo, "KA - BFD remote %s:%s:%vus Added\n", h.RemoteIP.String(), h.SourceIP.String(), bm.Interval)
tk.LogIt(tk.LogInfo, "KA - BFD remote %s:%s:%vus Added\n", bm.RemoteIP.String(), bm.SourceIP.String(), bm.Interval)
}
return 0, nil
}
Expand All @@ -335,20 +332,20 @@ func (h *CIStateH) CIBFDSessionDel(bm cmn.BFDMod) (int, error) {
return -1, errors.New("cluster instance not found")
}

bfdSessConfigArgs := bfd.ConfigArgs{RemoteIP: h.RemoteIP.String()}
bfdSessConfigArgs := bfd.ConfigArgs{RemoteIP: bm.RemoteIP.String()}
err := h.Bs.BFDDeleteRemote(bfdSessConfigArgs)
if err != nil {
tk.LogIt(tk.LogCritical, "KA - Cant delete BFD remote\n")
return -1, err
}
h.SpawnKa = false
tk.LogIt(tk.LogInfo, "KA - BFD remote %s:%s:%vus deleted\n", h.RemoteIP.String(), h.SourceIP.String(), bm.Interval)
tk.LogIt(tk.LogInfo, "KA - BFD remote %s:%s deleted\n", bm.Instance, bm.RemoteIP.String())
return 0, nil
}

// CIBFDSessionGet - routine to get BFD session info
func (h *CIStateH) CIBFDSessionGet() ([]cmn.BFDMod, error) {
if !h.SpawnKa {
if !h.SpawnKa || h.Bs == nil {
tk.LogIt(tk.LogError, "[CLUSTER] BFD sessions not running\n")
return nil, errors.New("bfd session not running")
}
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions loxinet/dpebpf_linux.go → pkg/loxinet/dpebpf_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ package loxinet
#include <sys/ioctl.h>
#include <net/if.h>
#include <pthread.h>
#include "../loxilb-ebpf/kernel/loxilb_libdp.h"
#include "../../loxilb-ebpf/kernel/loxilb_libdp.h"
int bpf_map_get_next_key(int fd, const void *key, void *next_key);
int bpf_map_lookup_elem(int fd, const void *key, void *value);
extern void goMapNotiHandler(struct ll_dp_map_notif *);
extern void goLinuxArpResolver(unsigned int);
#cgo CFLAGS: -I./../loxilb-ebpf/libbpf/src/ -I./../loxilb-ebpf/common
#cgo LDFLAGS: -L. -L/lib64 -L./../loxilb-ebpf/kernel -L./../loxilb-ebpf/libbpf/src/build/usr/lib64/ -Wl,-rpath=/lib64/ -lloxilbdp -lbpf -lelf -lz
#cgo CFLAGS: -I./../../loxilb-ebpf/libbpf/src/ -I./../../loxilb-ebpf/common
#cgo LDFLAGS: -L. -L/lib64 -L./../../loxilb-ebpf/kernel -L./../../loxilb-ebpf/libbpf/src/build/usr/lib64/ -Wl,-rpath=/lib64/ -lloxilbdp -lbpf -lelf -lz
*/
import "C"
import (
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.