Skip to content

Commit 4bcc743

Browse files
Merge pull request #514 from TrekkieCoder/main
PR - gh-483 Minimal provisioning for masquerade from pods
2 parents 2d1da38 + 49ac0bc commit 4bcc743

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

api/loxinlp/ipvs.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type ipVSEntry struct {
4848
Key ipVSKey
4949
sel cmn.EpSelect
5050
mode cmn.LBMode
51+
pType string
5152
InValid bool
5253
EndPoints []ipvsEndPoint
5354
}
@@ -83,6 +84,7 @@ func (ctx *IpVSH) BuildIpVSDB() []*ipVSEntry {
8384
}
8485

8586
newEntry.sel = cmn.LbSelRr
87+
newEntry.pType = ""
8688
if svc.Flags&0x1 == 0x1 {
8789
newEntry.sel = cmn.LbSelRrPersist
8890
}
@@ -103,6 +105,7 @@ func (ctx *IpVSH) BuildIpVSDB() []*ipVSEntry {
103105
newEntry.mode = cmn.LBModeDefault
104106
if svc.Port >= K8sNodePortMin && svc.Port <= K8sNodePortMax {
105107
newEntry.mode = cmn.LBModeFullNAT
108+
newEntry.pType = "ping"
106109
}
107110

108111
key := ipVSKey{Address: svc.Address.String(), Protocol: proto, Port: svc.Port}
@@ -141,7 +144,7 @@ func IpVSSync() {
141144
for _, ent := range ipVSCtx.RMap {
142145
if ent.InValid {
143146
name := fmt.Sprintf("ipvs_%s:%d-%s", ent.Key.Address, ent.Key.Port, ent.Key.Protocol)
144-
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}}
147+
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}}
145148
_, err := hooks.NetLbRuleDel(&lbrule)
146149
if err != nil {
147150
tk.LogIt(tk.LogError, "IPVS LB %v delete failed\n", ent.Key)
@@ -153,7 +156,7 @@ func IpVSSync() {
153156

154157
for _, newEnt := range ipVSList {
155158
name := fmt.Sprintf("ipvs_%s:%d-%s", newEnt.Key.Address, newEnt.Key.Port, newEnt.Key.Protocol)
156-
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}}
159+
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}}
157160
for _, ep := range newEnt.EndPoints {
158161
lbrule.Eps = append(lbrule.Eps, cmn.LbEndPointArg{EpIP: ep.EpIP, EpPort: ep.EpPort, Weight: 1})
159162
}

loxinet/route.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ package loxinet
1919
import (
2020
"errors"
2121
"fmt"
22-
"net"
23-
24-
tk "github.com/loxilb-io/loxilib"
25-
2622
cmn "github.com/loxilb-io/loxilb/common"
23+
opts "github.com/loxilb-io/loxilb/options"
24+
tk "github.com/loxilb-io/loxilib"
25+
"net"
2726
)
2827

2928
// error codes
@@ -471,6 +470,13 @@ func (rt *Rt) DP(work DpWorkT) int {
471470
return -1
472471
}
473472

473+
if opts.Opts.FallBack {
474+
if rtNet.IP.IsUnspecified() {
475+
fmt.Printf("FALL BACK MODE\n\n\n\n")
476+
return 0
477+
}
478+
}
479+
474480
if work == DpStatsGet {
475481
nStat := new(StatDpWorkQ)
476482
nStat.Work = work

options/options.go

+1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ var Opts struct {
3030
Rpc string `long:"rpc" description:"RPC mode for syncing - netrpc or grpc" default:"netrpc"`
3131
K8sApi string `long:"k8s-api" description:"Enable k8s watcher(experimental)" default:"none"`
3232
IPVSCompat bool `long:"ipvs-compat" description:"Enable ipvs-compat(experimental)"`
33+
FallBack bool `long:"fallback" description:"Fallback to system default networking(experimental)"`
3334
}

0 commit comments

Comments
 (0)