From b7839dca0513825ab8138a0ee39577ff9d8fdc5e Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Thu, 18 Jan 2024 01:02:05 +0900 Subject: [PATCH] gh-494 Fixes for ipvs-compat mode --- loxinet/rules.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/loxinet/rules.go b/loxinet/rules.go index ac8e02f14..538828876 100644 --- a/loxinet/rules.go +++ b/loxinet/rules.go @@ -1431,10 +1431,12 @@ func (R *RuleH) AddNatLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIPArg, if r.ruleNum < RtMaximumLbs { R.tables[RtLB].rArr[r.ruleNum] = r } - R.vipMap[sNetAddr.IP.String()]++ + if !strings.Contains(r.name, "ipvs") { + R.vipMap[sNetAddr.IP.String()]++ - if R.vipMap[sNetAddr.IP.String()] == 1 && !strings.Contains(r.name, "ipvs") { - R.AdvRuleVIPIfL2(sNetAddr.IP) + if R.vipMap[sNetAddr.IP.String()] == 1 { + R.AdvRuleVIPIfL2(sNetAddr.IP) + } } r.DP(DpCreate) @@ -1496,13 +1498,15 @@ func (R *RuleH) DeleteNatLbRule(serv cmn.LbServiceArg) (int, error) { R.tables[RtLB].rArr[rule.ruleNum] = nil } - R.vipMap[sNetAddr.IP.String()]-- + if !strings.Contains(rule.name, "ipvs") { + R.vipMap[sNetAddr.IP.String()]-- - if R.vipMap[sNetAddr.IP.String()] == 0 { - if IsIPHostAddr(sNetAddr.IP.String()) && !strings.Contains(rule.name, "ipvs") { - loxinlp.DelAddrNoHook(sNetAddr.IP.String()+"/32", "lo") + if R.vipMap[sNetAddr.IP.String()] == 0 { + if IsIPHostAddr(sNetAddr.IP.String()) { + loxinlp.DelAddrNoHook(sNetAddr.IP.String()+"/32", "lo") + } + delete(R.vipMap, sNetAddr.IP.String()) } - delete(R.vipMap, sNetAddr.IP.String()) } tk.LogIt(tk.LogDebug, "nat lb-rule deleted %s-%s\n", rule.tuples.String(), rule.act.String())