From 5ba556437183d65cff04c6449ca091e990a366d9 Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Thu, 1 Feb 2024 18:20:26 +0900 Subject: [PATCH 1/4] gh-483 For k8s node-port & clusterIP services, use ping probing for end-points --- api/loxinlp/ipvs.go | 7 +++++-- loxilb-ebpf | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/api/loxinlp/ipvs.go b/api/loxinlp/ipvs.go index 6176f4c73..493c448ea 100644 --- a/api/loxinlp/ipvs.go +++ b/api/loxinlp/ipvs.go @@ -48,6 +48,7 @@ type ipVSEntry struct { Key ipVSKey sel cmn.EpSelect mode cmn.LBMode + pType string InValid bool EndPoints []ipvsEndPoint } @@ -83,6 +84,7 @@ func (ctx *IpVSH) BuildIpVSDB() []*ipVSEntry { } newEntry.sel = cmn.LbSelRr + newEntry.pType = "" if svc.Flags&0x1 == 0x1 { newEntry.sel = cmn.LbSelRrPersist } @@ -103,6 +105,7 @@ func (ctx *IpVSH) BuildIpVSDB() []*ipVSEntry { newEntry.mode = cmn.LBModeDefault if svc.Port >= K8sNodePortMin && svc.Port <= K8sNodePortMax { newEntry.mode = cmn.LBModeFullNAT + newEntry.pType = "ping" } key := ipVSKey{Address: svc.Address.String(), Protocol: proto, Port: svc.Port} @@ -141,7 +144,7 @@ func IpVSSync() { for _, ent := range ipVSCtx.RMap { if ent.InValid { name := fmt.Sprintf("ipvs_%s:%d-%s", ent.Key.Address, ent.Key.Port, ent.Key.Protocol) - lbrule := cmn.LbRuleMod{Serv: cmn.LbServiceArg{ServIP: ent.Key.Address, ServPort: ent.Key.Port, Proto: ent.Key.Protocol, Sel: ent.sel, Mode: ent.mode, Name: name}} + lbrule := cmn.LbRuleMod{Serv: cmn.LbServiceArg{ServIP: ent.Key.Address, ServPort: ent.Key.Port, Proto: ent.Key.Protocol, Sel: ent.sel, Mode: ent.mode, Name: name, ProbeType: ent.pType}} _, err := hooks.NetLbRuleDel(&lbrule) if err != nil { tk.LogIt(tk.LogError, "IPVS LB %v delete failed\n", ent.Key) @@ -153,7 +156,7 @@ func IpVSSync() { for _, newEnt := range ipVSList { 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: newEnt.sel, Mode: newEnt.mode, Name: name}} + lbrule := cmn.LbRuleMod{Serv: cmn.LbServiceArg{ServIP: newEnt.Key.Address, ServPort: newEnt.Key.Port, Proto: newEnt.Key.Protocol, Sel: newEnt.sel, Mode: newEnt.mode, Name: name, ProbeType: newEnt.pType}} for _, ep := range newEnt.EndPoints { lbrule.Eps = append(lbrule.Eps, cmn.LbEndPointArg{EpIP: ep.EpIP, EpPort: ep.EpPort, Weight: 1}) } diff --git a/loxilb-ebpf b/loxilb-ebpf index afca7cb69..d102ada98 160000 --- a/loxilb-ebpf +++ b/loxilb-ebpf @@ -1 +1 @@ -Subproject commit afca7cb6985d9b2a2dd7b76c0e9a773057fb9a2e +Subproject commit d102ada98249a81bdee306f85462679f957cc946 From 3758093b7c47cfda33ce26c933e4e38097a28985 Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Thu, 1 Feb 2024 18:45:05 +0900 Subject: [PATCH 2/4] Updated to latest submodule - compilation fix --- loxilb-ebpf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loxilb-ebpf b/loxilb-ebpf index d102ada98..ffdf8b932 160000 --- a/loxilb-ebpf +++ b/loxilb-ebpf @@ -1 +1 @@ -Subproject commit d102ada98249a81bdee306f85462679f957cc946 +Subproject commit ffdf8b932d8ec5828da247d365a72248b1826244 From 53c993678efaab9fe5d2c0bf610a2e38f031278a Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Thu, 1 Feb 2024 22:31:47 +0900 Subject: [PATCH 3/4] Updated to latest submodule - ebpf verifier fix --- loxilb-ebpf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loxilb-ebpf b/loxilb-ebpf index ffdf8b932..9ff2c0178 160000 --- a/loxilb-ebpf +++ b/loxilb-ebpf @@ -1 +1 @@ -Subproject commit ffdf8b932d8ec5828da247d365a72248b1826244 +Subproject commit 9ff2c0178180b7877cd089ae81d7491a06598984 From 49ac0bc0e3ee77e3104596411ed9c556845b7945 Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Thu, 1 Feb 2024 23:28:54 +0900 Subject: [PATCH 4/4] Implementation of minimal fallback mode needed especially for masquerading --- loxilb-ebpf | 2 +- loxinet/route.go | 14 ++++++++++---- options/options.go | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/loxilb-ebpf b/loxilb-ebpf index 9ff2c0178..4f79bbe43 160000 --- a/loxilb-ebpf +++ b/loxilb-ebpf @@ -1 +1 @@ -Subproject commit 9ff2c0178180b7877cd089ae81d7491a06598984 +Subproject commit 4f79bbe43f973f7683ec7006bfe6c2881b3618ac diff --git a/loxinet/route.go b/loxinet/route.go index f9c69f238..0f7b66eb9 100644 --- a/loxinet/route.go +++ b/loxinet/route.go @@ -19,11 +19,10 @@ package loxinet import ( "errors" "fmt" - "net" - - tk "github.com/loxilb-io/loxilib" - cmn "github.com/loxilb-io/loxilb/common" + opts "github.com/loxilb-io/loxilb/options" + tk "github.com/loxilb-io/loxilib" + "net" ) // error codes @@ -471,6 +470,13 @@ func (rt *Rt) DP(work DpWorkT) int { return -1 } + if opts.Opts.FallBack { + if rtNet.IP.IsUnspecified() { + fmt.Printf("FALL BACK MODE\n\n\n\n") + return 0 + } + } + if work == DpStatsGet { nStat := new(StatDpWorkQ) nStat.Work = work diff --git a/options/options.go b/options/options.go index d20269c59..83594955a 100644 --- a/options/options.go +++ b/options/options.go @@ -30,4 +30,5 @@ var Opts struct { Rpc string `long:"rpc" description:"RPC mode for syncing - netrpc or grpc" default:"netrpc"` K8sApi string `long:"k8s-api" description:"Enable k8s watcher(experimental)" default:"none"` IPVSCompat bool `long:"ipvs-compat" description:"Enable ipvs-compat(experimental)"` + FallBack bool `long:"fallback" description:"Fallback to system default networking(experimental)"` }