Skip to content

Commit

Permalink
Merge pull request loxilb-io#551 from nik-netlox/main
Browse files Browse the repository at this point in the history
BFD config auto-apply on restart
  • Loading branch information
UltraInstinct14 authored Feb 27, 2024
2 parents a92bb7f + 71317ee commit e6e4a3a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
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
8 changes: 8 additions & 0 deletions loxinet/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e6e4a3a

Please sign in to comment.