Skip to content

Commit

Permalink
gh-494 Fixes for ipvs-compat mode
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed Jan 17, 2024
1 parent 9c652eb commit b7839dc
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions loxinet/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit b7839dc

Please sign in to comment.