Skip to content

Commit

Permalink
Merge branch 'epmodiy' of https://github.com/loxilb-io/loxilb into ep…
Browse files Browse the repository at this point in the history
…modiy
  • Loading branch information
TrekkieCoder committed Jun 19, 2024
2 parents 34035f8 + 8c85ac5 commit feca864
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 26 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ For deploying telco-cloud with cloud-native functions, loxilb can be used as a S
- [K3s : loxilb with calico](https://github.com/loxilb-io/loxilbdocs/blob/main/docs/k3s_quick_start_calico.md)
- [K3s : loxilb with cilium](https://github.com/loxilb-io/loxilbdocs/blob/main/docs/quick_start_with_cilium.md)
- [K0s : loxilb with default kube-router networking](https://github.com/loxilb-io/loxilbdocs/blob/main/docs/k0s_quick_start.md)
- [EKS : loxilb ext-mode](https://github.com/loxilb-io/loxilbdocs/blob/main/docs/eks-external.md)

#### loxilb as in-cluster pod
- [K3s : loxilb in-cluster mode](https://github.com/loxilb-io/loxilbdocs/blob/main/docs/k3s_quick_start_incluster.md)
- [K0s : loxilb in-cluster mode](https://github.com/loxilb-io/loxilbdocs/blob/main/docs/k0s_quick_start_incluster.md)
- [MicroK8s : loxilb in-cluster mode](https://github.com/loxilb-io/loxilbdocs/blob/main/docs/microk8s_quick_start_incluster.md)
- [EKS : loxilb in-cluster mode](https://github.com/loxilb-io/loxilbdocs/blob/main/docs/eks-incluster.md)

#### loxilb as service-proxy (kube-proxy replacement)
- [K3s : loxilb service-proxy with flannel](https://github.com/loxilb-io/loxilbdocs/blob/main/docs/service-proxy-flannel.md)
Expand Down
62 changes: 36 additions & 26 deletions pkg/loxinet/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -1242,17 +1242,22 @@ func (R *RuleH) unFoldRecursiveEPs(r *ruleEnt) {
// addVIPSys - system specific operations for VIPs of a LB rule
func (R *RuleH) addVIPSys(r *ruleEnt) {
if !strings.Contains(r.name, "ipvs") && !strings.Contains(r.name, "static") {
R.vipMap[r.tuples.l3Dst.addr.IP.String()]++

if R.vipMap[r.tuples.l3Dst.addr.IP.String()] == 1 {
R.AdvRuleVIPIfL2(r.tuples.l3Dst.addr.IP)
if !r.tuples.l3Dst.addr.IP.IsUnspecified() {
R.vipMap[r.tuples.l3Dst.addr.IP.String()]++

if R.vipMap[r.tuples.l3Dst.addr.IP.String()] == 1 {
R.AdvRuleVIPIfL2(r.tuples.l3Dst.addr.IP)
}
}

// Take care of any secondary VIPs
for _, sVIP := range r.secIP {
R.vipMap[sVIP.sIP.String()]++
if R.vipMap[sVIP.sIP.String()] == 1 {
R.AdvRuleVIPIfL2(sVIP.sIP)
if !sVIP.sIP.IsUnspecified() {
R.vipMap[sVIP.sIP.String()]++
if R.vipMap[sVIP.sIP.String()] == 1 {
R.AdvRuleVIPIfL2(sVIP.sIP)
}
}
}
}
Expand Down Expand Up @@ -1598,33 +1603,38 @@ func (R *RuleH) AddNatLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIPArg,
// deleteVIPSys - system specific operations for deleting VIPs of a LB rule
func (R *RuleH) deleteVIPSys(r *ruleEnt) {
if !strings.Contains(r.name, "ipvs") && !strings.Contains(r.name, "static") {
R.vipMap[r.tuples.l3Dst.addr.IP.String()]--

if R.vipMap[r.tuples.l3Dst.addr.IP.String()] == 0 {
if utils.IsIPHostAddr(r.tuples.l3Dst.addr.IP.String()) {
loxinlp.DelAddrNoHook(r.tuples.l3Dst.addr.IP.String()+"/32", "lo")
}
dev := fmt.Sprintf("llb-rule-%s", r.tuples.l3Dst.addr.IP.String())
ret, _ := mh.zr.L3.IfaFind(dev, r.tuples.l3Dst.addr.IP)
if ret == 0 {
mh.zr.L3.IfaDelete(dev, r.tuples.l3Dst.addr.IP.String()+"/32")
if !r.tuples.l3Dst.addr.IP.IsUnspecified() {
R.vipMap[r.tuples.l3Dst.addr.IP.String()]--

if R.vipMap[r.tuples.l3Dst.addr.IP.String()] == 0 {
if utils.IsIPHostAddr(r.tuples.l3Dst.addr.IP.String()) {
loxinlp.DelAddrNoHook(r.tuples.l3Dst.addr.IP.String()+"/32", "lo")
}
dev := fmt.Sprintf("llb-rule-%s", r.tuples.l3Dst.addr.IP.String())
ret, _ := mh.zr.L3.IfaFind(dev, r.tuples.l3Dst.addr.IP)
if ret == 0 {
mh.zr.L3.IfaDelete(dev, r.tuples.l3Dst.addr.IP.String()+"/32")
}
delete(R.vipMap, r.tuples.l3Dst.addr.IP.String())
}
delete(R.vipMap, r.tuples.l3Dst.addr.IP.String())
}

// Take care of any secondary VIPs
for _, sVIP := range r.secIP {
R.vipMap[sVIP.sIP.String()]--
if R.vipMap[sVIP.sIP.String()] == 0 {
if utils.IsIPHostAddr(sVIP.sIP.String()) {
loxinlp.DelAddrNoHook(sVIP.sIP.String()+"/32", "lo")
}
dev := fmt.Sprintf("llb-rule-%s", sVIP.sIP.String())
ret, _ := mh.zr.L3.IfaFind(dev, sVIP.sIP)
if ret == 0 {
mh.zr.L3.IfaDelete(dev, sVIP.sIP.String()+"/32")
if !sVIP.sIP.IsUnspecified() {
R.vipMap[sVIP.sIP.String()]--
if R.vipMap[sVIP.sIP.String()] == 0 {
if utils.IsIPHostAddr(sVIP.sIP.String()) {
loxinlp.DelAddrNoHook(sVIP.sIP.String()+"/32", "lo")
}
dev := fmt.Sprintf("llb-rule-%s", sVIP.sIP.String())
ret, _ := mh.zr.L3.IfaFind(dev, sVIP.sIP)
if ret == 0 {
mh.zr.L3.IfaDelete(dev, sVIP.sIP.String()+"/32")
}
delete(R.vipMap, sVIP.sIP.String())
}
delete(R.vipMap, sVIP.sIP.String())
}
}
}
Expand Down

0 comments on commit feca864

Please sign in to comment.