Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR - Support for ep persistence based on client #508

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading