From 5b774d9324bb7d95e6231813dc078bc4c26bddb0 Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Sun, 12 Jan 2025 21:44:48 +0900 Subject: [PATCH] zoning: allow any instance names --- common/common.go | 2 +- pkg/loxinet/cluster.go | 12 ------------ pkg/loxinet/gobgpclient.go | 14 ++++++++------ 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/common/common.go b/common/common.go index e95794d3d..6e3e5b6b0 100644 --- a/common/common.go +++ b/common/common.go @@ -37,7 +37,7 @@ const BFDPort = 3784 const BFDDefRetryCount = 3 const ( // CIDefault - Default CI Instance name - CIDefault = "default" + CIDefault = "llb-inst0" ) const ( diff --git a/pkg/loxinet/cluster.go b/pkg/loxinet/cluster.go index dec6c46cf..f62b96970 100644 --- a/pkg/loxinet/cluster.go +++ b/pkg/loxinet/cluster.go @@ -170,18 +170,6 @@ func (h *CIStateH) CIStateGetInst(inst string) (string, error) { return ci.StateStr, nil } - if inst == cmn.CIDefault { - for ciStr, ci := range h.ClusterMap { - instNum, err := parseInstance(ciStr) - if err != nil { - continue - } - if instNum == 0 { - return ci.StateStr, nil - } - } - } - return "NOT_DEFINED", errors.New("not found") } diff --git a/pkg/loxinet/gobgpclient.go b/pkg/loxinet/gobgpclient.go index dd65f5a17..cd26fff4d 100644 --- a/pkg/loxinet/gobgpclient.go +++ b/pkg/loxinet/gobgpclient.go @@ -776,10 +776,11 @@ func (gbh *GoBgpH) initBgpClient() { gbh.advertiseAllVIPs(ciname) } - if ciname == cmn.CIDefault { - if ci.hastate == cmn.CIStateBackup { + ciState, err := mh.has.CIStateGetInst(cmn.CIDefault) + if err == nil { + if ciState == "BACKUP" { gbh.resetBGPPolicy(true) - } else if ci.hastate == cmn.CIStateMaster { + } else if ciState == "MASTER" { gbh.resetBGPPolicy(false) } } @@ -850,10 +851,11 @@ func (gbh *GoBgpH) UpdateCIState(instance string, state int, vip net.IP) { gbh.advertiseAllVIPs(instance) if update { - if instance == cmn.CIDefault { - if ci.hastate == cmn.CIStateBackup { + ciState, err := mh.has.CIStateGetInst(cmn.CIDefault) + if err == nil { + if ciState == "BACKUP" { gbh.resetBGPPolicy(true) - } else if ci.hastate == cmn.CIStateMaster { + } else if ciState == "MASTER" { gbh.resetBGPPolicy(false) } }