diff --git a/loxinet/cluster.go b/loxinet/cluster.go index 0a8946f9..03938ddc 100644 --- a/loxinet/cluster.go +++ b/loxinet/cluster.go @@ -100,10 +100,9 @@ func (ci *CIStateH) startBFDProto() { txInterval = uint32(ci.Interval) } - bs := bfd.StructNew(cmn.BFDPort) - bfdSessConfigArgs := bfd.ConfigArgs{RemoteIP: ci.RemoteIP.String(), SourceIP: ci.SourceIP.String(), + bfdSessConfigArgs := bfd.ConfigArgs{RemoteIP: ci.RemoteIP.String(), SourceIP: ci.SourceIP.String(), Port: cmn.BFDPort, Interval: txInterval, Multi: cmn.BFDDefRetryCount, Instance: cmn.CIDefault} - err := bs.BFDAddRemote(bfdSessConfigArgs, ci) + err := ci.Bs.BFDAddRemote(bfdSessConfigArgs, ci) if err != nil { tk.LogIt(tk.LogCritical, "KA - Cant add BFD remote\n") os.Exit(1) @@ -281,7 +280,7 @@ func (h *CIStateH) CIBFDSessionAdd(bm cmn.BFDMod) (int, error) { tk.LogIt(tk.LogError, "[CLUSTER] BFD SU - Cluster Instance %s not found\n", bm.Instance) return -1, errors.New("cluster instance not found") } - + bfdSessConfigArgs := bfd.ConfigArgs{RemoteIP: h.RemoteIP.String(), SourceIP: h.SourceIP.String(), Port: 3784, Interval: uint32(bm.Interval), Multi: bm.RetryCount, Instance: bm.Instance} err := h.Bs.BFDAddRemote(bfdSessConfigArgs, h) if err != nil { @@ -298,7 +297,7 @@ func (h *CIStateH) CIBFDSessionGet() ([]cmn.BFDMod, error) { tk.LogIt(tk.LogError, "[CLUSTER] BFD sessions not running\n") return nil, errors.New("bfd session not running") } - + return h.Bs.BFDGet() } diff --git a/proto/bfd.go b/proto/bfd.go index 1dcaf7d4..043c07bb 100644 --- a/proto/bfd.go +++ b/proto/bfd.go @@ -21,13 +21,13 @@ import ( "errors" "fmt" "net" + "strconv" + "strings" "sync" "time" - "strings" - "strconv" - tk "github.com/loxilb-io/loxilib" cmn "github.com/loxilb-io/loxilb/common" + tk "github.com/loxilb-io/loxilib" ) type SessionState uint8 @@ -39,11 +39,11 @@ const ( BFDUp ) -var BFDStateMap = map[uint8]string { - uint8(BFDAdminDown):"BFDAdminDown", - uint8(BFDDown): "BFDDown", - uint8(BFDInit): "BFDInit", - uint8(BFDUp): "BFDUp", +var BFDStateMap = map[uint8]string{ + uint8(BFDAdminDown): "BFDAdminDown", + uint8(BFDDown): "BFDDown", + uint8(BFDInit): "BFDInit", + uint8(BFDUp): "BFDUp", } const ( @@ -154,7 +154,7 @@ func (bs *Struct) BFDAddRemote(args ConfigArgs, cbs Notifer) error { sess = new(bfdSession) sess.Instance = args.Instance sess.Notify = cbs - + err := sess.initialize(args.RemoteIP, args.SourceIP, args.Port, args.Interval, args.Multi) if err != nil { return errors.New("bfd failed to init session")