From 202e077a5fffaf89eb888a14f52017be299c8c87 Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Sun, 15 Dec 2024 20:54:03 +0900 Subject: [PATCH] gh-877 Initial support for egress --- pkg/loxinet/cluster.go | 14 +++++++++----- pkg/loxinet/rules.go | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/pkg/loxinet/cluster.go b/pkg/loxinet/cluster.go index 89c22c591..edbb2a266 100644 --- a/pkg/loxinet/cluster.go +++ b/pkg/loxinet/cluster.go @@ -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 + } } } diff --git a/pkg/loxinet/rules.go b/pkg/loxinet/rules.go index 511f3954d..db1fa71f8 100644 --- a/pkg/loxinet/rules.go +++ b/pkg/loxinet/rules.go @@ -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) @@ -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 { @@ -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) } @@ -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) @@ -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) }