Skip to content

Commit a2d2e04

Browse files
Merge pull request #508 from TrekkieCoder/main
PR - Support for ep persistence based on client
2 parents ea99454 + 8508142 commit a2d2e04

File tree

6 files changed

+19
-2
lines changed

6 files changed

+19
-2
lines changed

api/loxinlp/ipvs.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ func (ctx *IpVSH) BuildIpVSDB() []*ipVSEntry {
7777
continue
7878
}
7979

80+
if svc.Flags&0x1 == 0x1 {
81+
newEntry.Type = "rrp"
82+
}
83+
8084
proto := ""
8185
if svc.Protocol == 1 {
8286
proto = "icmp"
@@ -137,8 +141,14 @@ func IpVSSync() {
137141
}
138142

139143
for _, newEnt := range ipVSList {
144+
145+
sel := cmn.LbSelRr
146+
if newEnt.Type == "rrp" {
147+
sel = cmn.LbSelRrPersist
148+
}
149+
fmt.Printf("Selection %s\n", newEnt.Type)
140150
name := fmt.Sprintf("ipvs_%s:%d-%s", newEnt.Key.Address, newEnt.Key.Port, newEnt.Key.Protocol)
141-
lbrule := cmn.LbRuleMod{Serv: cmn.LbServiceArg{ServIP: newEnt.Key.Address, ServPort: newEnt.Key.Port, Proto: newEnt.Key.Protocol, Sel: cmn.LbSelRr, Name: name}}
151+
lbrule := cmn.LbRuleMod{Serv: cmn.LbServiceArg{ServIP: newEnt.Key.Address, ServPort: newEnt.Key.Port, Proto: newEnt.Key.Protocol, Sel: sel, Name: name}}
142152
for _, ep := range newEnt.EndPoints {
143153
lbrule.Eps = append(lbrule.Eps, cmn.LbEndPointArg{EpIP: ep.EpIP, EpPort: ep.EpPort, Weight: 1})
144154
}

common/common.go

+2
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ const (
467467
LbSelHash
468468
// LbSelPrio - select the lb based on weighted round-robin
469469
LbSelPrio
470+
// LbSelRrPersist - persist connectons from same client
471+
LbSelRrPersist
470472
)
471473

472474
// LBMode - Variable to define LB mode

loxinet/dpbroker.go

+1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ const (
260260
EpRR NatSel = iota + 1
261261
EpHash
262262
EpPrio
263+
EpRRPersist
263264
)
264265

265266
// NatEP - a nat end-point

loxinet/dpebpf_linux.go

+2
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,8 @@ func DpNatLbRuleMod(w *NatDpWorkQ) int {
925925
dat.sel_type = C.NAT_LB_SEL_RR
926926
case w.EpSel == EpHash:
927927
dat.sel_type = C.NAT_LB_SEL_HASH
928+
case w.EpSel == EpRRPersist:
929+
dat.sel_type = C.NAT_LB_SEL_RR_PERSIST
928930
/* Currently not implemented in DP */
929931
/*case w.EpSel == EP_PRIO:
930932
dat.sel_type = C.NAT_LB_SEL_PRIO*/

loxinet/rules.go

+2
Original file line numberDiff line numberDiff line change
@@ -2280,6 +2280,8 @@ func (r *ruleEnt) Nat2DP(work DpWorkT) int {
22802280
case at.sel == cmn.LbSelPrio:
22812281
// Note that internally we use RR to achieve wRR
22822282
nWork.EpSel = EpRR
2283+
case at.sel == cmn.LbSelRrPersist:
2284+
nWork.EpSel = EpRRPersist
22832285
default:
22842286
nWork.EpSel = EpRR
22852287
}

0 commit comments

Comments
 (0)