From 03fd2c0f7ad7ce7ddcd0e0f0cc8d656d381881fd Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Tue, 7 Jan 2025 01:17:15 +0900 Subject: [PATCH 01/16] loxilb-io/loxilb#877 egress support - updated to latest submodule --- loxilb-ebpf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loxilb-ebpf b/loxilb-ebpf index 6bc09425..8e51986f 160000 --- a/loxilb-ebpf +++ b/loxilb-ebpf @@ -1 +1 @@ -Subproject commit 6bc09425bcb64e2fc7956d1250b2f7308da8deae +Subproject commit 8e51986fd2a6419bd3f2f0cafb12b6a8eb22889e From d0993c65061cf887f6faff6f7c4b0c51823a63ec Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Thu, 9 Jan 2025 13:53:28 +0900 Subject: [PATCH 02/16] chore: updated to latest submodule --- loxilb-ebpf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loxilb-ebpf b/loxilb-ebpf index 8e51986f..5d30e270 160000 --- a/loxilb-ebpf +++ b/loxilb-ebpf @@ -1 +1 @@ -Subproject commit 8e51986fd2a6419bd3f2f0cafb12b6a8eb22889e +Subproject commit 5d30e27062294424bf2505d92debdefde924748b From 54726bdca29bb19eedf57f5e225992a41c35994f Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Thu, 9 Jan 2025 14:11:01 +0900 Subject: [PATCH 03/16] chore: updated to latest submodule --- loxilb-ebpf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loxilb-ebpf b/loxilb-ebpf index 5d30e270..d8c6af79 160000 --- a/loxilb-ebpf +++ b/loxilb-ebpf @@ -1 +1 @@ -Subproject commit 5d30e27062294424bf2505d92debdefde924748b +Subproject commit d8c6af79ec70baa8e80fa8be0d4bad5aff35ea59 From f145caa212abc50800cf6018e1051e5e135ab32f Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Thu, 9 Jan 2025 17:53:58 +0900 Subject: [PATCH 04/16] chore: updated to latest submodule --- loxilb-ebpf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loxilb-ebpf b/loxilb-ebpf index d8c6af79..0891900b 160000 --- a/loxilb-ebpf +++ b/loxilb-ebpf @@ -1 +1 @@ -Subproject commit d8c6af79ec70baa8e80fa8be0d4bad5aff35ea59 +Subproject commit 0891900bc589555239c6020b9d26e886c4e8b80c From 0f9ca57fad2adf06223c710bcb2c3330b3a7abe2 Mon Sep 17 00:00:00 2001 From: Van Hau TRAN Date: Thu, 9 Jan 2025 20:54:53 +0100 Subject: [PATCH 05/16] IfaSelect return at least ip of same protocol of dest addr Signed-off-by: Van Hau TRAN --- pkg/loxinet/layer3.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/loxinet/layer3.go b/pkg/loxinet/layer3.go index 207e56bc..69df1539 100644 --- a/pkg/loxinet/layer3.go +++ b/pkg/loxinet/layer3.go @@ -281,6 +281,12 @@ func (l3 *L3H) IfaSelect(Obj string, addr net.IP, findAny bool) (int, net.IP, st continue } if len(ifa.Ifas) > 0 { + for _, ifaEnt := range ifa.Ifas { + if (tk.IsNetIPv4(addr.String()) && tk.IsNetIPv4(ifaEnt.IfaNet.IP.String())) || + (tk.IsNetIPv6(addr.String()) && tk.IsNetIPv6(ifaEnt.IfaNet.IP.String())) { + return 0, ifaEnt.IfaAddr, Obj + } + } return 0, ifa.Ifas[0].IfaAddr, Obj } } @@ -309,6 +315,12 @@ func (l3 *L3H) IfaSelect(Obj string, addr net.IP, findAny bool) (int, net.IP, st // Select first IP if len(ifa.Ifas) > 0 { + for _, ifaEnt := range ifa.Ifas { + if (tk.IsNetIPv4(addr.String()) && tk.IsNetIPv4(ifaEnt.IfaNet.IP.String())) || + (tk.IsNetIPv6(addr.String()) && tk.IsNetIPv6(ifaEnt.IfaNet.IP.String())) { + return 0, ifaEnt.IfaAddr, Obj + } + } return 0, ifa.Ifas[0].IfaAddr, Obj } From 9e1b459272c422d034d7bc13bad9aca477d3bf5c Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Fri, 10 Jan 2025 19:50:13 +0900 Subject: [PATCH 06/16] ct garbage handling fixes --- loxilb-ebpf | 2 +- pkg/loxinet/dpebpf_linux.go | 4 ++-- pkg/loxinet/rules.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/loxilb-ebpf b/loxilb-ebpf index 0891900b..bf245ce9 160000 --- a/loxilb-ebpf +++ b/loxilb-ebpf @@ -1 +1 @@ -Subproject commit 0891900bc589555239c6020b9d26e886c4e8b80c +Subproject commit bf245ce96e028e21ad95b10bd716b6c8e0c844f3 diff --git a/pkg/loxinet/dpebpf_linux.go b/pkg/loxinet/dpebpf_linux.go index 40e82308..618532ab 100644 --- a/pkg/loxinet/dpebpf_linux.go +++ b/pkg/loxinet/dpebpf_linux.go @@ -99,8 +99,8 @@ const ( // constants const ( - dpEbpfLinuxTiVal = 10 - ctGCTiValDefault = 25 + dpEbpfLinuxTiVal = 5 + ctGCTiValDefault = 15 ctiDeleteSyncRetries = 3 blkCtiMaxLen = 8192 mapNotifierChLen = 8096 diff --git a/pkg/loxinet/rules.go b/pkg/loxinet/rules.go index fe0c323f..c9f4304d 100644 --- a/pkg/loxinet/rules.go +++ b/pkg/loxinet/rules.go @@ -78,7 +78,7 @@ const ( // constants const ( - MaxLBEndPoints = 24 + MaxLBEndPoints = 32 DflLbaInactiveTries = 2 // Default number of inactive tries before LB arm is turned off MaxDflLbaInactiveTries = 100 // Max number of inactive tries before LB arm is turned off DflLbaCheckTimeout = 10 // Default timeout for checking LB arms From 13cc9f6eef1e9fb8e9f98f2ce13e190e8355f73f Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Fri, 10 Jan 2025 22:23:14 +0900 Subject: [PATCH 07/16] cicd: handle upto 32 eps --- cicd/wrrtcplb1/validation.sh | 9 ++++----- cicd/wrrtcplb2/validation.sh | 9 +++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cicd/wrrtcplb1/validation.sh b/cicd/wrrtcplb1/validation.sh index 367dde4b..92ad3908 100755 --- a/cicd/wrrtcplb1/validation.sh +++ b/cicd/wrrtcplb1/validation.sh @@ -39,14 +39,13 @@ respArr=( "server1" "server1" "server1" "server1" "server1" "server1" "server1" "server1" "server1" "server1" "server1" "server1" - "server1" "server2" "server2" - "server2" "server2" "server1" + "server1" "server1" "server1" + "server1" "server1" "server1" "server1" "server2" "server2" "server2" "server2" "server2" - "server2" "server1" - ) + "server2" "server1" ) -for i in {0..23} +for i in {0..31} do res=$($hexec l3h1 curl --max-time 10 -s 20.20.20.1:2020) echo $i:$res diff --git a/cicd/wrrtcplb2/validation.sh b/cicd/wrrtcplb2/validation.sh index f1c292f4..1e8383b0 100755 --- a/cicd/wrrtcplb2/validation.sh +++ b/cicd/wrrtcplb2/validation.sh @@ -36,16 +36,17 @@ done respArr=( "server1" "server1" "server1" "server1" "server1" "server1" "server1" "server1" "server1" + "server1" "server1" "server1" + "server2" "server2" "server2" "server2" "server2" "server2" "server2" "server2" "server2" "server2" "server2" "server2" "server3" "server3" "server3" - "server3" "server1" "server1" - "server1" "server3" "server3" + "server3" "server3" "server3" "server1" "server1" - ) + ) -for i in {0..23} +for i in {0..31} do res=$($hexec l3h1 curl --max-time 10 -s 20.20.20.1:2020) echo $i:$res From ccd7660a3c537d2a21775ccf770cbb3f48c585fc Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Sat, 11 Jan 2025 00:36:07 +0900 Subject: [PATCH 08/16] ct garbage handling fixes --- loxilb-ebpf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loxilb-ebpf b/loxilb-ebpf index bf245ce9..4fff6e4a 160000 --- a/loxilb-ebpf +++ b/loxilb-ebpf @@ -1 +1 @@ -Subproject commit bf245ce96e028e21ad95b10bd716b6c8e0c844f3 +Subproject commit 4fff6e4a696f8ffa16ceb45ccff9b292f2fe1585 From 7241f7225d54c20bc67dfcdf9073c5d27b5c0706 Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Sat, 11 Jan 2025 16:54:37 +0900 Subject: [PATCH 09/16] cicd: fixed typos in script --- .github/workflows/basic-sanity-ubuntu-22.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/basic-sanity-ubuntu-22.yml b/.github/workflows/basic-sanity-ubuntu-22.yml index 943adb4a..5d54485b 100644 --- a/.github/workflows/basic-sanity-ubuntu-22.yml +++ b/.github/workflows/basic-sanity-ubuntu-22.yml @@ -44,7 +44,7 @@ jobs: - run: sudo -E env "PATH=$PATH" make test - run: for iface in $(ls /sys/class/net); do sudo tc filter delete dev $iface ingress >> /dev/null 2>&1 | true; sudo tc filter delete dev $iface egress >> /dev/null 2>&1 | true; done - run: docker pull ghcr.io/loxilb-io/loxilb:latest - - run: docker run -u root --cap-add SYS_ADMIN --restart unless-stopped --privileged -dit -v /dev/log:/dev/log --name loxilb ghcr.io/loxilb-io/loxilb:latest-amd64 + - run: docker run -u root --cap-add SYS_ADMIN --restart unless-stopped --privileged -dit -v /dev/log:/dev/log --name loxilb ghcr.io/loxilb-io/loxilb:latest - run: pwd && ls && sudo -E env "PATH=$PATH" make docker-cp-ebpf - run: docker exec -dit loxilb mkllb_bpffs - run: id=`docker ps -f name=loxilb | cut -d " " -f 1 | grep -iv "CONTAINER"` && docker commit $id ghcr.io/loxilb-io/loxilb:latest From e19957ba4aab49d6c9e1ce27e3f675778a1b0e41 Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Sat, 11 Jan 2025 17:04:17 +0900 Subject: [PATCH 10/16] cicd: fixed typos in script --- .github/workflows/tcp-sanity-ubuntu-22.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tcp-sanity-ubuntu-22.yml b/.github/workflows/tcp-sanity-ubuntu-22.yml index 29720fd2..744c14e1 100644 --- a/.github/workflows/tcp-sanity-ubuntu-22.yml +++ b/.github/workflows/tcp-sanity-ubuntu-22.yml @@ -32,7 +32,7 @@ jobs: - run: loxilb-ebpf/utils/mkllb_bpffs.sh - run: sudo -E env "PATH=$PATH" make - run: docker pull ghcr.io/loxilb-io/loxilb:latest - - run: docker run -u root --cap-add SYS_ADMIN --restart unless-stopped --privileged -dit -v /dev/log:/dev/log --name loxilb ghcr.io/loxilb-io/loxilb:latestu22 + - run: docker run -u root --cap-add SYS_ADMIN --restart unless-stopped --privileged -dit -v /dev/log:/dev/log --name loxilb ghcr.io/loxilb-io/loxilb:latest - run: pwd && ls && sudo -E env "PATH=$PATH" make docker-cp-ebpf - run: docker exec -dit loxilb mkllb_bpffs - run: id=`docker ps -f name=loxilb | cut -d " " -f 1 | grep -iv "CONTAINER"` && docker commit $id ghcr.io/loxilb-io/loxilb:latest From 186274cf6569af3362093268bd5c4397507d1a73 Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Sun, 12 Jan 2025 01:55:00 +0900 Subject: [PATCH 11/16] Better signal handling for termination --- pkg/loxinet/loxinet.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/loxinet/loxinet.go b/pkg/loxinet/loxinet.go index 5421c30c..027e6970 100644 --- a/pkg/loxinet/loxinet.go +++ b/pkg/loxinet/loxinet.go @@ -167,6 +167,9 @@ func loxiNetTicker(bgpPeerMode bool) { pprof.StopCPUProfile() } else if sig == syscall.SIGINT || sig == syscall.SIGTERM { tk.LogIt(tk.LogCritical, "Shutdown on sig %v\n", sig) + if !bgpPeerMode { + mh.dpEbpf.DpEbpfUnInit() + } // TODO - More subsystem cleanup TBD mh.zr.Rules.RuleDestructAll() if mh.cloudHook != nil { @@ -188,9 +191,6 @@ func loxiNetTicker(bgpPeerMode bool) { } } } - if !bgpPeerMode { - mh.dpEbpf.DpEbpfUnInit() - } mh.has.CIDestroy() apiserver.ApiServerShutOk() } From 41a04bed56ab13975552b5c6ed98fc16ba1d651d Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Sun, 12 Jan 2025 01:55:35 +0900 Subject: [PATCH 12/16] chore:updated to latest submodule --- loxilb-ebpf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loxilb-ebpf b/loxilb-ebpf index 4fff6e4a..73f23493 160000 --- a/loxilb-ebpf +++ b/loxilb-ebpf @@ -1 +1 @@ -Subproject commit 4fff6e4a696f8ffa16ceb45ccff9b292f2fe1585 +Subproject commit 73f23493ab81f3ffe1c71b9650c186d5115a5e48 From 01f0338ea503a0f35b675e2e63f8dff1dd71317a Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Sun, 12 Jan 2025 16:05:35 +0900 Subject: [PATCH 13/16] zoning: allow any instance names --- pkg/loxinet/cluster.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/pkg/loxinet/cluster.go b/pkg/loxinet/cluster.go index a0d3bfcb..dec6c46c 100644 --- a/pkg/loxinet/cluster.go +++ b/pkg/loxinet/cluster.go @@ -21,6 +21,8 @@ import ( "fmt" "net" "os" + "regexp" + "strconv" "time" nlp "github.com/loxilb-io/loxilb/api/loxinlp" @@ -144,6 +146,23 @@ func (ci *CIStateH) CISpawn() { } } +func parseInstance(input string) (int, error) { + // Define a regex pattern to match "-inst" + re := regexp.MustCompile(`^[a-zA-Z0-9_-]+-inst(\d+)$`) + + matches := re.FindStringSubmatch(input) + if matches == nil || len(matches) < 2 { + return 0, fmt.Errorf("no match found in input: %s", input) + } + + number, err := strconv.Atoi(matches[1]) + if err != nil { + return 0, fmt.Errorf("failed to parse number: %v", err) + } + + return number, nil +} + // CIStateGetInst - routine to get HA state func (h *CIStateH) CIStateGetInst(inst string) (string, error) { @@ -151,6 +170,18 @@ func (h *CIStateH) CIStateGetInst(inst string) (string, error) { return ci.StateStr, nil } + if inst == cmn.CIDefault { + for ciStr, ci := range h.ClusterMap { + instNum, err := parseInstance(ciStr) + if err != nil { + continue + } + if instNum == 0 { + return ci.StateStr, nil + } + } + } + return "NOT_DEFINED", errors.New("not found") } From 5b774d9324bb7d95e6231813dc078bc4c26bddb0 Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Sun, 12 Jan 2025 21:44:48 +0900 Subject: [PATCH 14/16] zoning: allow any instance names --- common/common.go | 2 +- pkg/loxinet/cluster.go | 12 ------------ pkg/loxinet/gobgpclient.go | 14 ++++++++------ 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/common/common.go b/common/common.go index e95794d3..6e3e5b6b 100644 --- a/common/common.go +++ b/common/common.go @@ -37,7 +37,7 @@ const BFDPort = 3784 const BFDDefRetryCount = 3 const ( // CIDefault - Default CI Instance name - CIDefault = "default" + CIDefault = "llb-inst0" ) const ( diff --git a/pkg/loxinet/cluster.go b/pkg/loxinet/cluster.go index dec6c46c..f62b9697 100644 --- a/pkg/loxinet/cluster.go +++ b/pkg/loxinet/cluster.go @@ -170,18 +170,6 @@ func (h *CIStateH) CIStateGetInst(inst string) (string, error) { return ci.StateStr, nil } - if inst == cmn.CIDefault { - for ciStr, ci := range h.ClusterMap { - instNum, err := parseInstance(ciStr) - if err != nil { - continue - } - if instNum == 0 { - return ci.StateStr, nil - } - } - } - return "NOT_DEFINED", errors.New("not found") } diff --git a/pkg/loxinet/gobgpclient.go b/pkg/loxinet/gobgpclient.go index dd65f5a1..cd26fff4 100644 --- a/pkg/loxinet/gobgpclient.go +++ b/pkg/loxinet/gobgpclient.go @@ -776,10 +776,11 @@ func (gbh *GoBgpH) initBgpClient() { gbh.advertiseAllVIPs(ciname) } - if ciname == cmn.CIDefault { - if ci.hastate == cmn.CIStateBackup { + ciState, err := mh.has.CIStateGetInst(cmn.CIDefault) + if err == nil { + if ciState == "BACKUP" { gbh.resetBGPPolicy(true) - } else if ci.hastate == cmn.CIStateMaster { + } else if ciState == "MASTER" { gbh.resetBGPPolicy(false) } } @@ -850,10 +851,11 @@ func (gbh *GoBgpH) UpdateCIState(instance string, state int, vip net.IP) { gbh.advertiseAllVIPs(instance) if update { - if instance == cmn.CIDefault { - if ci.hastate == cmn.CIStateBackup { + ciState, err := mh.has.CIStateGetInst(cmn.CIDefault) + if err == nil { + if ciState == "BACKUP" { gbh.resetBGPPolicy(true) - } else if ci.hastate == cmn.CIStateMaster { + } else if ciState == "MASTER" { gbh.resetBGPPolicy(false) } } From 54839a050ce07daae8279d9a5655009b5f3803fd Mon Sep 17 00:00:00 2001 From: Trekkie <111065900+TrekkieCoder@users.noreply.github.com> Date: Mon, 13 Jan 2025 09:34:50 +0900 Subject: [PATCH 15/16] chore: Update README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 61c4bfb6..a8053f7d 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Additionally, loxilb also supports: - [x] kube-proxy replacement with eBPF(full cluster-mesh implementation for Kubernetes) - [x] Ingress Support - [x] Kubernetes Gateway API +- [x] HA capable Egress for Kubernetes - [ ] Kubernetes Network Policies ## Telco-Cloud with loxilb From 8c042e3050cf03da9557c3efe6fb4b3c3ff5a64d Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Mon, 13 Jan 2025 12:01:51 +0900 Subject: [PATCH 16/16] changed hardcoded zone instance name to contant --- pkg/loxinet/apiclient.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/loxinet/apiclient.go b/pkg/loxinet/apiclient.go index d168092a..51482ae3 100644 --- a/pkg/loxinet/apiclient.go +++ b/pkg/loxinet/apiclient.go @@ -338,7 +338,7 @@ func (na *NetAPIStruct) NetLbRuleAdd(lm *cmn.LbRuleMod) (int, error) { for _, ip := range lm.SecIPs { ips = append(ips, ip.SecIP) } - mh.bgp.AddBGPRule("default", ips) + mh.bgp.AddBGPRule(cmn.CIDefault, ips) } else { tk.LogIt(tk.LogDebug, "loxilb BGP mode is disabled \n") } @@ -359,7 +359,7 @@ func (na *NetAPIStruct) NetLbRuleDel(lm *cmn.LbRuleMod) (int, error) { if lm.Serv.Bgp { if mh.bgp != nil { ips = append(ips, lm.Serv.ServIP) - mh.bgp.DelBGPRule("default", ips) + mh.bgp.DelBGPRule(cmn.CIDefault, ips) } else { tk.LogIt(tk.LogDebug, "loxilb BGP mode is disabled \n") }