Skip to content

Commit

Permalink
Merge pull request #508 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
PR - Support for ep persistence based on client
  • Loading branch information
UltraInstinct14 authored Jan 26, 2024
2 parents ea99454 + 8508142 commit a2d2e04
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
12 changes: 11 additions & 1 deletion api/loxinlp/ipvs.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ func (ctx *IpVSH) BuildIpVSDB() []*ipVSEntry {
continue
}

if svc.Flags&0x1 == 0x1 {
newEntry.Type = "rrp"
}

proto := ""
if svc.Protocol == 1 {
proto = "icmp"
Expand Down Expand Up @@ -137,8 +141,14 @@ func IpVSSync() {
}

for _, newEnt := range ipVSList {

sel := cmn.LbSelRr
if newEnt.Type == "rrp" {
sel = cmn.LbSelRrPersist
}
fmt.Printf("Selection %s\n", newEnt.Type)
name := fmt.Sprintf("ipvs_%s:%d-%s", newEnt.Key.Address, newEnt.Key.Port, newEnt.Key.Protocol)
lbrule := cmn.LbRuleMod{Serv: cmn.LbServiceArg{ServIP: newEnt.Key.Address, ServPort: newEnt.Key.Port, Proto: newEnt.Key.Protocol, Sel: cmn.LbSelRr, Name: name}}
lbrule := cmn.LbRuleMod{Serv: cmn.LbServiceArg{ServIP: newEnt.Key.Address, ServPort: newEnt.Key.Port, Proto: newEnt.Key.Protocol, Sel: sel, Name: name}}
for _, ep := range newEnt.EndPoints {
lbrule.Eps = append(lbrule.Eps, cmn.LbEndPointArg{EpIP: ep.EpIP, EpPort: ep.EpPort, Weight: 1})
}
Expand Down
2 changes: 2 additions & 0 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ const (
LbSelHash
// LbSelPrio - select the lb based on weighted round-robin
LbSelPrio
// LbSelRrPersist - persist connectons from same client
LbSelRrPersist
)

// LBMode - Variable to define LB mode
Expand Down
2 changes: 1 addition & 1 deletion loxilb-ebpf
1 change: 1 addition & 0 deletions loxinet/dpbroker.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ const (
EpRR NatSel = iota + 1
EpHash
EpPrio
EpRRPersist
)

// NatEP - a nat end-point
Expand Down
2 changes: 2 additions & 0 deletions loxinet/dpebpf_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,8 @@ func DpNatLbRuleMod(w *NatDpWorkQ) int {
dat.sel_type = C.NAT_LB_SEL_RR
case w.EpSel == EpHash:
dat.sel_type = C.NAT_LB_SEL_HASH
case w.EpSel == EpRRPersist:
dat.sel_type = C.NAT_LB_SEL_RR_PERSIST
/* Currently not implemented in DP */
/*case w.EpSel == EP_PRIO:
dat.sel_type = C.NAT_LB_SEL_PRIO*/
Expand Down
2 changes: 2 additions & 0 deletions loxinet/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -2280,6 +2280,8 @@ func (r *ruleEnt) Nat2DP(work DpWorkT) int {
case at.sel == cmn.LbSelPrio:
// Note that internally we use RR to achieve wRR
nWork.EpSel = EpRR
case at.sel == cmn.LbSelRrPersist:
nWork.EpSel = EpRRPersist
default:
nWork.EpSel = EpRR
}
Expand Down

0 comments on commit a2d2e04

Please sign in to comment.