Skip to content

Commit

Permalink
loxilb-iogh-877 Initial support for egress
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed Dec 14, 2024
1 parent 7db0331 commit 3f20e04
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
3 changes: 2 additions & 1 deletion common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,8 @@ type BFDMod struct {
// ClusterNodeMod - information related to a cluster node instance
type ClusterNodeMod struct {
// Instance - Cluster Instance
Addr net.IP `json:"Addr"`
Addr net.IP `json:"Addr"`
Egress bool `json:"egress"`
}

const (
Expand Down
17 changes: 16 additions & 1 deletion pkg/loxinet/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type ClusterInstance struct {
// ClusterNode - Struct for Cluster Node Information
type ClusterNode struct {
Addr net.IP
Egress bool
Status DpStatusT
}

Expand Down Expand Up @@ -119,7 +120,7 @@ func (ci *CIStateH) startBFDProto(bfdSessConfigArgs bfd.ConfigArgs) {
}

// CITicker - Periodic ticker for Cluster module
func (h *CIStateH) CITicker() {
func (ci *CIStateH) CITicker() {
// Nothing to do currently
}

Expand Down Expand Up @@ -400,6 +401,7 @@ func (h *CIStateH) ClusterNodeAdd(node cmn.ClusterNodeMod) (int, error) {

cNode = new(ClusterNode)
cNode.Addr = node.Addr
cNode.Egress = node.Egress
h.NodeMap[node.Addr.String()] = cNode

cNode.DP(DpCreate)
Expand Down Expand Up @@ -513,6 +515,19 @@ func (h *CIStateH) CIBFDSessionGet() ([]cmn.BFDMod, error) {
// DP - sync state of cluster-node entity to data-path
func (cn *ClusterNode) DP(work DpWorkT) int {

if cn.Egress {
if work == DpCreate {
ret := nlp.AddVxLANPeerNoHook(ClusterNetID, cn.Addr.String())
if ret != 0 {
cn.Status = DpCreateErr
}
return 0
} else {
nlp.AddVxLANPeerNoHook(ClusterNetID, cn.Addr.String())
return 0
}
}

pwq := new(PeerDpWorkQ)
pwq.Work = work
pwq.PeerIP = cn.Addr
Expand Down
14 changes: 14 additions & 0 deletions pkg/loxinet/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ type epHostOpts struct {
currProbeDuration uint32
probePort uint16
probeActivated bool
egress bool
}

type epHost struct {
Expand Down Expand Up @@ -2356,7 +2357,11 @@ func (R *RuleH) AddEPHost(apiCall bool, hostName string, name string, args epHos
ep := R.epMap[epKey]
if ep != nil {
if apiCall {
egress := ep.opts.egress
ep.opts = args
if egress {
ep.opts.egress = egress
}
ep.opts.currProbeDuration = ep.opts.probeDuration
ep.initProberOn = true
return 0, nil
Expand All @@ -2383,6 +2388,15 @@ func (R *RuleH) AddEPHost(apiCall bool, hostName string, name string, args epHos
ep.hID = 0
}

if args.egress {
epNode := cmn.ClusterNodeMod{Addr: net.ParseIP(hostName),
Egress: true}
_, err := mh.has.ClusterNodeAdd(epNode)
if err != nil {
return -1, errors.New("ep-host add failed as cluster node")
}
}

R.epMap[epKey] = ep

tk.LogIt(tk.LogDebug, "ep-host added %v:%d\n", epKey, ep.hID)
Expand Down

0 comments on commit 3f20e04

Please sign in to comment.