Skip to content

Commit

Permalink
Merge pull request #542 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
bfd: Fix to use the right context
  • Loading branch information
UltraInstinct14 authored Feb 22, 2024
2 parents 1a85096 + e0cffe6 commit 79968dc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
9 changes: 4 additions & 5 deletions loxinet/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand All @@ -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()
}

Expand Down
18 changes: 9 additions & 9 deletions proto/bfd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 (
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 79968dc

Please sign in to comment.