diff --git a/api/loxinlp/nlp.go b/api/loxinlp/nlp.go index dd8296c8..a84c1b38 100644 --- a/api/loxinlp/nlp.go +++ b/api/loxinlp/nlp.go @@ -217,6 +217,27 @@ func applyEPConfig() bool { return true } +func ApplyBFDConfig() bool { + var resp struct { + Attr []cmn.BFDMod `json:"Attr"` + } + byteBuf, err := os.ReadFile("/etc/loxilb/BFDconfig.txt") + if err != nil { + fmt.Println(err.Error()) + return false + } + + // Unmashal to Json + if err := json.Unmarshal(byteBuf, &resp); err != nil { + fmt.Printf("Error: Failed to unmarshal File: (%s)\n", err.Error()) + return false + } + for _, bfd := range resp.Attr { + hooks.NetBFDAdd(&bfd) + } + return true +} + func applyRoutes(name string) { tk.LogIt(tk.LogDebug, "[NLP] Applying Route Config for %s \n", name) command := "loxicmd apply --per-intf " + name + " -r -c /etc/loxilb/ipconfig/" diff --git a/loxinet/cluster.go b/loxinet/cluster.go index 03938ddc..0bb002e5 100644 --- a/loxinet/cluster.go +++ b/loxinet/cluster.go @@ -22,6 +22,7 @@ import ( "net" "os" "time" + nlp "github.com/loxilb-io/loxilb/api/loxinlp" cmn "github.com/loxilb-io/loxilb/common" opts "github.com/loxilb-io/loxilb/options" @@ -108,6 +109,13 @@ func (ci *CIStateH) startBFDProto() { os.Exit(1) } tk.LogIt(tk.LogInfo, "KA - Added BFD remote %s:%s:%vus\n", ci.RemoteIP.String(), ci.SourceIP.String(), txInterval) + if _, err := os.Stat("/etc/loxilb/BFDconfig.txt"); errors.Is(err, os.ErrNotExist) { + if err != nil { + tk.LogIt(tk.LogInfo, "[Init] No BFD config file : %s \n", err.Error()) + } + } else { + nlp.ApplyBFDConfig() + } } // CITicker - Periodic ticker for Cluster module