Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR - gh-483 Minimal provisioning for masquerade from pods #514

Merged
merged 6 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)"`
}
Loading