Skip to content

Commit

Permalink
Merge pull request loxilb-io#514 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
PR - loxilb-iogh-483 Minimal provisioning for masquerade from pods
  • Loading branch information
UltraInstinct14 authored Feb 1, 2024
2 parents 2d1da38 + 49ac0bc commit 4bcc743
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
7 changes: 5 additions & 2 deletions api/loxinlp/ipvs.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type ipVSEntry struct {
Key ipVSKey
sel cmn.EpSelect
mode cmn.LBMode
pType string
InValid bool
EndPoints []ipvsEndPoint
}
Expand Down Expand Up @@ -83,6 +84,7 @@ func (ctx *IpVSH) BuildIpVSDB() []*ipVSEntry {
}

newEntry.sel = cmn.LbSelRr
newEntry.pType = ""
if svc.Flags&0x1 == 0x1 {
newEntry.sel = cmn.LbSelRrPersist
}
Expand All @@ -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}
Expand Down Expand Up @@ -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)
Expand All @@ -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})
}
Expand Down
2 changes: 1 addition & 1 deletion loxilb-ebpf
14 changes: 10 additions & 4 deletions loxinet/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)"`
}

0 comments on commit 4bcc743

Please sign in to comment.