From 1a1919d40c79728e653a701b5a73e9e463da33aa Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Mon, 4 Mar 2024 15:37:43 +0900 Subject: [PATCH] gh-481 Support for selection of LB end-points based on least-connections --- common/common.go | 2 ++ loxilb-ebpf | 2 +- loxinet/dpbroker.go | 1 + loxinet/dpebpf_linux.go | 2 ++ loxinet/rules.go | 2 ++ 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/common/common.go b/common/common.go index de669f6a7..687fcf9a6 100644 --- a/common/common.go +++ b/common/common.go @@ -471,6 +471,8 @@ const ( LbSelPrio // LbSelRrPersist - persist connectons from same client LbSelRrPersist + // LbSelLeastConnections - select client based on least connections + LbSelLeastConnections ) // LBMode - Variable to define LB mode diff --git a/loxilb-ebpf b/loxilb-ebpf index b79d22ecd..8eeb767fc 160000 --- a/loxilb-ebpf +++ b/loxilb-ebpf @@ -1 +1 @@ -Subproject commit b79d22ecd52e2a0fd77f6dfb298cd3f166f4d41b +Subproject commit 8eeb767fcf206f480f829ee7b4d7b462ab3f801d diff --git a/loxinet/dpbroker.go b/loxinet/dpbroker.go index 7383e917f..32e60703b 100644 --- a/loxinet/dpbroker.go +++ b/loxinet/dpbroker.go @@ -261,6 +261,7 @@ const ( EpHash EpPrio EpRRPersist + EpLeastConn ) // NatEP - a nat end-point diff --git a/loxinet/dpebpf_linux.go b/loxinet/dpebpf_linux.go index 9382641b4..3c01ef677 100644 --- a/loxinet/dpebpf_linux.go +++ b/loxinet/dpebpf_linux.go @@ -942,6 +942,8 @@ func DpNatLbRuleMod(w *NatDpWorkQ) int { dat.sel_type = C.NAT_LB_SEL_HASH case w.EpSel == EpRRPersist: dat.sel_type = C.NAT_LB_SEL_RR_PERSIST + case w.EpSel == EpLeastConn: + dat.sel_type = C.NAT_LB_SEL_LC /* Currently not implemented in DP */ /*case w.EpSel == EP_PRIO: dat.sel_type = C.NAT_LB_SEL_PRIO*/ diff --git a/loxinet/rules.go b/loxinet/rules.go index a9cc0ea25..d88345fbe 100644 --- a/loxinet/rules.go +++ b/loxinet/rules.go @@ -2306,6 +2306,8 @@ func (r *ruleEnt) Nat2DP(work DpWorkT) int { nWork.EpSel = EpRR case at.sel == cmn.LbSelRrPersist: nWork.EpSel = EpRRPersist + case at.sel == cmn.LbSelLeastConnections: + nWork.EpSel = EpLeastConn default: nWork.EpSel = EpRR }