Skip to content

Commit

Permalink
BFD config auto-apply on restart
Browse files Browse the repository at this point in the history
  • Loading branch information
nik-netlox committed Feb 27, 2024
1 parent a92bb7f commit cf5ccfb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
21 changes: 21 additions & 0 deletions api/loxinlp/nlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
9 changes: 8 additions & 1 deletion loxinet/loxinet.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,16 @@ func loxiNetInit() {
prometheus.Init()
}

if !opts.Opts.BgpPeerMode {
if !opts.Opts.BgpPeerMode && clusterMode {
// Spawn CI maintenance application
mh.has.CISpawn()
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()
}
}
// Initialize the loxinet global ticker(s)
mh.tDone = make(chan bool)
Expand Down

0 comments on commit cf5ccfb

Please sign in to comment.