diff --git a/loxilb_test.go b/loxilb_test.go index d44e331e..105e60a9 100644 --- a/loxilb_test.go +++ b/loxilb_test.go @@ -17,7 +17,7 @@ package main import ( "fmt" - ln "github.com/loxilb-io/loxilb/loxinet" + ln "github.com/loxilb-io/loxilb/pkg/loxinet" "testing" ) diff --git a/main.go b/main.go index ad0a8e1d..13c56e82 100644 --- a/main.go +++ b/main.go @@ -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" diff --git a/loxinet/apiclient.go b/pkg/loxinet/apiclient.go similarity index 100% rename from loxinet/apiclient.go rename to pkg/loxinet/apiclient.go diff --git a/loxinet/cluster.go b/pkg/loxinet/cluster.go similarity index 92% rename from loxinet/cluster.go rename to pkg/loxinet/cluster.go index 763365be..9561a079 100644 --- a/loxinet/cluster.go +++ b/pkg/loxinet/cluster.go @@ -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 @@ -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") @@ -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") @@ -308,7 +305,7 @@ 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) @@ -316,7 +313,7 @@ func (h *CIStateH) CIBFDSessionAdd(bm cmn.BFDMod) (int, error) { 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 } @@ -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") } diff --git a/loxinet/dpbroker.go b/pkg/loxinet/dpbroker.go similarity index 100% rename from loxinet/dpbroker.go rename to pkg/loxinet/dpbroker.go diff --git a/loxinet/dpebpf_linux.go b/pkg/loxinet/dpebpf_linux.go similarity index 99% rename from loxinet/dpebpf_linux.go rename to pkg/loxinet/dpebpf_linux.go index 5bf92d25..a86be4a0 100644 --- a/loxinet/dpebpf_linux.go +++ b/pkg/loxinet/dpebpf_linux.go @@ -33,13 +33,13 @@ package loxinet #include #include #include -#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 ( diff --git a/loxinet/dpebpf_windows.go b/pkg/loxinet/dpebpf_windows.go similarity index 100% rename from loxinet/dpebpf_windows.go rename to pkg/loxinet/dpebpf_windows.go diff --git a/loxinet/gobgpclient.go b/pkg/loxinet/gobgpclient.go similarity index 100% rename from loxinet/gobgpclient.go rename to pkg/loxinet/gobgpclient.go diff --git a/loxinet/layer2.go b/pkg/loxinet/layer2.go similarity index 100% rename from loxinet/layer2.go rename to pkg/loxinet/layer2.go diff --git a/loxinet/layer3.go b/pkg/loxinet/layer3.go similarity index 100% rename from loxinet/layer3.go rename to pkg/loxinet/layer3.go diff --git a/loxinet/loxinet.go b/pkg/loxinet/loxinet.go similarity index 100% rename from loxinet/loxinet.go rename to pkg/loxinet/loxinet.go diff --git a/loxinet/loxinet_test.go b/pkg/loxinet/loxinet_test.go similarity index 100% rename from loxinet/loxinet_test.go rename to pkg/loxinet/loxinet_test.go diff --git a/loxinet/loxinettest.go b/pkg/loxinet/loxinettest.go similarity index 100% rename from loxinet/loxinettest.go rename to pkg/loxinet/loxinettest.go diff --git a/loxinet/mirror.go b/pkg/loxinet/mirror.go similarity index 100% rename from loxinet/mirror.go rename to pkg/loxinet/mirror.go diff --git a/loxinet/neighbor.go b/pkg/loxinet/neighbor.go similarity index 100% rename from loxinet/neighbor.go rename to pkg/loxinet/neighbor.go diff --git a/loxinet/port.go b/pkg/loxinet/port.go similarity index 100% rename from loxinet/port.go rename to pkg/loxinet/port.go diff --git a/loxinet/qospol.go b/pkg/loxinet/qospol.go similarity index 100% rename from loxinet/qospol.go rename to pkg/loxinet/qospol.go diff --git a/loxinet/route.go b/pkg/loxinet/route.go similarity index 100% rename from loxinet/route.go rename to pkg/loxinet/route.go diff --git a/loxinet/rules.go b/pkg/loxinet/rules.go similarity index 100% rename from loxinet/rules.go rename to pkg/loxinet/rules.go diff --git a/loxinet/session.go b/pkg/loxinet/session.go similarity index 100% rename from loxinet/session.go rename to pkg/loxinet/session.go diff --git a/loxinet/utils.go b/pkg/loxinet/utils.go similarity index 100% rename from loxinet/utils.go rename to pkg/loxinet/utils.go diff --git a/loxinet/vlan.go b/pkg/loxinet/vlan.go similarity index 100% rename from loxinet/vlan.go rename to pkg/loxinet/vlan.go diff --git a/loxinet/xsync.pb.go b/pkg/loxinet/xsync.pb.go similarity index 100% rename from loxinet/xsync.pb.go rename to pkg/loxinet/xsync.pb.go diff --git a/loxinet/xsync.proto b/pkg/loxinet/xsync.proto similarity index 100% rename from loxinet/xsync.proto rename to pkg/loxinet/xsync.proto diff --git a/loxinet/xsync_client.go b/pkg/loxinet/xsync_client.go similarity index 100% rename from loxinet/xsync_client.go rename to pkg/loxinet/xsync_client.go diff --git a/loxinet/xsync_grpc.pb.go b/pkg/loxinet/xsync_grpc.pb.go similarity index 100% rename from loxinet/xsync_grpc.pb.go rename to pkg/loxinet/xsync_grpc.pb.go diff --git a/loxinet/xsync_server.go b/pkg/loxinet/xsync_server.go similarity index 100% rename from loxinet/xsync_server.go rename to pkg/loxinet/xsync_server.go diff --git a/loxinet/zones.go b/pkg/loxinet/zones.go similarity index 100% rename from loxinet/zones.go rename to pkg/loxinet/zones.go diff --git a/proto/bfd.go b/pkg/proto/bfd.go similarity index 100% rename from proto/bfd.go rename to pkg/proto/bfd.go