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 15, 2024
1 parent 77477e8 commit 202e077
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
14 changes: 9 additions & 5 deletions pkg/loxinet/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,14 +517,18 @@ 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
if !utils.IsIPHostAddr(cn.Addr.String()) {
ret := nlp.AddVxLANPeerNoHook(ClusterNetID, cn.Addr.String())
if ret != 0 {
cn.Status = DpCreateErr
}
}
return 0
} else {
nlp.AddVxLANPeerNoHook(ClusterNetID, cn.Addr.String())
return 0
if !utils.IsIPHostAddr(cn.Addr.String()) {
nlp.DelVxLANPeerNoHook(ClusterNetID, cn.Addr.String())
return 0
}
}
}

Expand Down
14 changes: 9 additions & 5 deletions pkg/loxinet/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ func validateXlateEPWeights(servEndPoints []cmn.LbEndPointArg) (int, error) {
return 0, nil
}

func (R *RuleH) modNatEpHost(r *ruleEnt, endpoints []ruleLBEp, doAddOp bool, liveCheckEn bool) {
func (R *RuleH) modNatEpHost(r *ruleEnt, endpoints []ruleLBEp, doAddOp bool, liveCheckEn bool, egressEps bool) {
var hopts epHostOpts
pType := ""
pPort := uint16(0)
Expand Down Expand Up @@ -934,6 +934,10 @@ func (R *RuleH) modNatEpHost(r *ruleEnt, endpoints []ruleLBEp, doAddOp bool, liv
hopts.probeActivated = true
}

if egressEps {
hopts.egress = true
}

epKey := makeEPKey(nep.xIP.String(), pType, pPort)

if doAddOp {
Expand Down Expand Up @@ -1758,8 +1762,8 @@ func (R *RuleH) AddLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIPArg, al
// eRule.managed = serv.Managed

if !serv.Snat {
R.modNatEpHost(eRule, delEps, false, activateProbe)
R.modNatEpHost(eRule, retEps, true, activateProbe)
R.modNatEpHost(eRule, delEps, false, activateProbe, eRule.egress)
R.modNatEpHost(eRule, retEps, true, activateProbe, eRule.egress)
R.electEPSrc(eRule)
}

Expand Down Expand Up @@ -1845,7 +1849,7 @@ func (R *RuleH) AddLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIPArg, al

if !serv.Snat {
R.foldRecursiveEPs(r)
R.modNatEpHost(r, lBActs.endPoints, true, activateProbe)
R.modNatEpHost(r, lBActs.endPoints, true, activateProbe, r.egress)
R.electEPSrc(r)
if serv.Mode == cmn.LBModeHostOneArm {
R.mkHostAssocs(r)
Expand Down Expand Up @@ -1924,7 +1928,7 @@ func (R *RuleH) DeleteLbRule(serv cmn.LbServiceArg) (int, error) {
activatedProbe = true
}
if rule.act.actType != RtActSnat {
R.modNatEpHost(rule, eEps, false, activatedProbe)
R.modNatEpHost(rule, eEps, false, activatedProbe, rule.egress)
R.unFoldRecursiveEPs(rule)
}

Expand Down

0 comments on commit 202e077

Please sign in to comment.