Skip to content

Commit

Permalink
Merge pull request #812 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
PR: loxilb-io/kube-loxilb#184 Clear inactive endpoints on LB endpoint update
  • Loading branch information
UltraInstinct14 authored Sep 27, 2024
2 parents 6016f53 + 9a3e036 commit a3cdc82
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 149 deletions.
4 changes: 2 additions & 2 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,9 @@ const (
type LBOp int32

const (
// LBOPAdd - Add te LB rule (replace if existing)
// LBOPAdd - Add the LB rule (replace if existing)
LBOPAdd LBOp = iota
// LBModeOneArm - Attach End-Points
// LBOPAttach - Attach End-Points
LBOPAttach
// LBOPDetach - Detach End-Points
LBOPDetach
Expand Down
2 changes: 1 addition & 1 deletion loxilb-ebpf
Submodule loxilb-ebpf updated 1 files
+23 −7 common/sockproxy.c
8 changes: 4 additions & 4 deletions pkg/loxinet/apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func (na *NetAPIStruct) NetLbRuleAdd(lm *cmn.LbRuleMod) (int, error) {
mh.mtx.Lock()
defer mh.mtx.Unlock()
var ips []string
ret, err := mh.zr.Rules.AddNatLbRule(lm.Serv, lm.SecIPs[:], lm.Eps[:])
ret, err := mh.zr.Rules.AddLbRule(lm.Serv, lm.SecIPs[:], lm.Eps[:])
if err == nil && lm.Serv.Bgp {
if mh.bgp != nil {
ips = append(ips, lm.Serv.ServIP)
Expand All @@ -354,8 +354,8 @@ func (na *NetAPIStruct) NetLbRuleDel(lm *cmn.LbRuleMod) (int, error) {
mh.mtx.Lock()
defer mh.mtx.Unlock()

ips := mh.zr.Rules.GetNatLbRuleSecIPs(lm.Serv)
ret, err := mh.zr.Rules.DeleteNatLbRule(lm.Serv)
ips := mh.zr.Rules.GetLBRuleSecIPs(lm.Serv)
ret, err := mh.zr.Rules.DeleteLbRule(lm.Serv)
if lm.Serv.Bgp {
if mh.bgp != nil {
ips = append(ips, lm.Serv.ServIP)
Expand All @@ -372,7 +372,7 @@ func (na *NetAPIStruct) NetLbRuleGet() ([]cmn.LbRuleMod, error) {
if na.BgpPeerMode {
return nil, errors.New("running in bgp only mode")
}
ret, err := mh.zr.Rules.GetNatLbRule()
ret, err := mh.zr.Rules.GetLBRule()
return ret, err
}

Expand Down
18 changes: 9 additions & 9 deletions pkg/loxinet/dpbroker.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ const (
DpE2EHTTPS
)

// NatDpWorkQ - work queue entry for nat related operation
type NatDpWorkQ struct {
// LBDpWorkQ - work queue entry for lb related operation
type LBDpWorkQ struct {
Work DpWorkT
Status *DpStatusT
ZoneNum int
Expand Down Expand Up @@ -431,8 +431,8 @@ type DpHookInterface interface {
DpNextHopDel(*NextHopDpWorkQ) int
DpRouteAdd(*RouteDpWorkQ) int
DpRouteDel(*RouteDpWorkQ) int
DpNatLbRuleAdd(*NatDpWorkQ) int
DpNatLbRuleDel(*NatDpWorkQ) int
DpLBRuleAdd(*LBDpWorkQ) int
DpLBRuleDel(*LBDpWorkQ) int
DpFwRuleAdd(w *FwDpWorkQ) int
DpFwRuleDel(w *FwDpWorkQ) int
DpStat(*StatDpWorkQ) int
Expand Down Expand Up @@ -685,11 +685,11 @@ func (dp *DpH) DpWorkOnRoute(rtWq *RouteDpWorkQ) DpRetT {
}

// DpWorkOnNatLb - routine to work on a NAT lb work queue request
func (dp *DpH) DpWorkOnNatLb(nWq *NatDpWorkQ) DpRetT {
func (dp *DpH) DpWorkOnNatLb(nWq *LBDpWorkQ) DpRetT {
if nWq.Work == DpCreate {
return dp.DpHooks.DpNatLbRuleAdd(nWq)
return dp.DpHooks.DpLBRuleAdd(nWq)
} else if nWq.Work == DpRemove {
return dp.DpHooks.DpNatLbRuleDel(nWq)
return dp.DpHooks.DpLBRuleDel(nWq)
}

return DpWqUnkErr
Expand Down Expand Up @@ -808,7 +808,7 @@ func DpWorkSingle(dp *DpH, m interface{}) DpRetT {
ret = dp.DpWorkOnNextHop(mq)
case *RouteDpWorkQ:
ret = dp.DpWorkOnRoute(mq)
case *NatDpWorkQ:
case *LBDpWorkQ:
ret = dp.DpWorkOnNatLb(mq)
case *UlClDpWorkQ:
ret = dp.DpWorkOnUlCl(mq)
Expand Down Expand Up @@ -875,7 +875,7 @@ func (dp *DpH) DpMapGetCt4() []cmn.CtInfo {
for _, dCti := range r {
servName = "-"
mh.mtx.Lock()
rule := mh.zr.Rules.GetNatLbRuleByID(dCti.RuleID)
rule := mh.zr.Rules.GetLBRuleByID(dCti.RuleID)
mh.mtx.Unlock()
if rule != nil {
servName = rule.name
Expand Down
20 changes: 10 additions & 10 deletions pkg/loxinet/dpebpf_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,8 +947,8 @@ func (e *DpEbpfH) DpRouteDel(w *RouteDpWorkQ) int {
return DpRouteMod(w)
}

// DpNatLbRuleMod - routine to work on a ebpf nat-lb change request
func DpNatLbRuleMod(w *NatDpWorkQ) int {
// DpLBRuleMod - routine to work on a ebpf lb change request
func DpLBRuleMod(w *LBDpWorkQ) int {

key := new(natKey)

Expand Down Expand Up @@ -1088,9 +1088,9 @@ func DpNatLbRuleMod(w *NatDpWorkQ) int {
return EbpfErrWqUnk
}

// DpNatLbRuleAdd - routine to work on a ebpf nat-lb add request
func (e *DpEbpfH) DpNatLbRuleAdd(w *NatDpWorkQ) int {
ec := DpNatLbRuleMod(w)
// DpLBRuleAdd - routine to work on a ebpf lb add request
func (e *DpEbpfH) DpLBRuleAdd(w *LBDpWorkQ) int {
ec := DpLBRuleMod(w)
if ec != 0 {
*w.Status = DpCreateErr
} else {
Expand All @@ -1099,9 +1099,9 @@ func (e *DpEbpfH) DpNatLbRuleAdd(w *NatDpWorkQ) int {
return ec
}

// DpNatLbRuleDel - routine to work on a ebpf nat-lb delete request
func (e *DpEbpfH) DpNatLbRuleDel(w *NatDpWorkQ) int {
return DpNatLbRuleMod(w)
// DpLBRuleDel - routine to work on a ebpf lb delete request
func (e *DpEbpfH) DpLBRuleDel(w *LBDpWorkQ) int {
return DpLBRuleMod(w)
}

// DpStat - routine to work on a ebpf map statistics request
Expand Down Expand Up @@ -1956,7 +1956,7 @@ func dpCTMapNotifierWorker(cti *DpCtInfo) {
if addOp {
// Need to completely initialize the cti
mh.mtx.Lock()
r := mh.zr.Rules.GetNatLbRuleByID(uint32(act.rid))
r := mh.zr.Rules.GetLBRuleByID(uint32(act.rid))
mh.mtx.Unlock()
if r == nil {
return
Expand Down Expand Up @@ -2213,7 +2213,7 @@ func (e *DpEbpfH) DpCtAdd(w *DpCtInfo) int {
serv.BlockNum = w.BlockNum

mh.mtx.Lock()
r := mh.zr.Rules.GetNatLbRuleByServArgs(serv)
r := mh.zr.Rules.GetLBRuleByServArgs(serv)
mh.mtx.Unlock()

if r == nil || len(w.PVal) == 0 || len(w.PKey) == 0 || w.CState != "est" {
Expand Down
4 changes: 2 additions & 2 deletions pkg/loxinet/loxinettest.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,12 @@ func TestLoxinet(t *testing.T) {
Weight: 2,
},
}
_, err = mh.zr.Rules.AddNatLbRule(lbServ, nil, lbEps[:])
_, err = mh.zr.Rules.AddLbRule(lbServ, nil, lbEps[:])
if err != nil {
t.Errorf("failed to add nat lb rule for 10.10.10.1\n")
}

_, err = mh.zr.Rules.DeleteNatLbRule(lbServ)
_, err = mh.zr.Rules.DeleteLbRule(lbServ)
if err != nil {
t.Errorf("failed to delete nat lb rule for 10.10.10.1\n")
}
Expand Down
Loading

0 comments on commit a3cdc82

Please sign in to comment.