Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder authored Jan 14, 2025
2 parents edd5a54 + cdd14c4 commit 1647bc7
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/basic-sanity-ubuntu-22.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tcp-sanity-ubuntu-22.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions cicd/wrrtcplb1/validation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions cicd/wrrtcplb2/validation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const BFDPort = 3784
const BFDDefRetryCount = 3
const (
// CIDefault - Default CI Instance name
CIDefault = "default"
CIDefault = "llb-inst0"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion loxilb-ebpf
4 changes: 2 additions & 2 deletions pkg/loxinet/apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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")
}
Expand Down
19 changes: 19 additions & 0 deletions pkg/loxinet/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"fmt"
"net"
"os"
"regexp"
"strconv"
"time"

nlp "github.com/loxilb-io/loxilb/api/loxinlp"
Expand Down Expand Up @@ -144,6 +146,23 @@ func (ci *CIStateH) CISpawn() {
}
}

func parseInstance(input string) (int, error) {
// Define a regex pattern to match "<any-string>-inst<number>"
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) {

Expand Down
4 changes: 2 additions & 2 deletions pkg/loxinet/dpebpf_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ const (

// constants
const (
dpEbpfLinuxTiVal = 10
ctGCTiValDefault = 25
dpEbpfLinuxTiVal = 5
ctGCTiValDefault = 15
ctiDeleteSyncRetries = 3
blkCtiMaxLen = 8192
mapNotifierChLen = 8096
Expand Down
14 changes: 8 additions & 6 deletions pkg/loxinet/gobgpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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)
}
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/loxinet/layer3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/loxinet/loxinet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -188,9 +191,6 @@ func loxiNetTicker(bgpPeerMode bool) {
}
}
}
if !bgpPeerMode {
mh.dpEbpf.DpEbpfUnInit()
}
mh.has.CIDestroy()
apiserver.ApiServerShutOk()
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/loxinet/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1647bc7

Please sign in to comment.