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..4f79bbe43 160000 --- a/loxilb-ebpf +++ b/loxilb-ebpf @@ -1 +1 @@ -Subproject commit afca7cb6985d9b2a2dd7b76c0e9a773057fb9a2e +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)"` }