Skip to content

Commit

Permalink
Merge pull request #496 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
PR - gh-483 and gh-495 related changes
  • Loading branch information
UltraInstinct14 authored Jan 18, 2024
2 parents b7ba0bb + 687ec1b commit 412c4e0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
11 changes: 7 additions & 4 deletions api/loxinlp/nlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,8 @@ func RUWorker(ch chan nlp.RouteUpdate, f chan struct{}) {
}
}

func NLWorker(nNl *NlH, bgpPeerMode bool) {
func NLWorker(nNl *NlH, bgpPeerMode bool, ch chan bool) {
ch <- true
if bgpPeerMode {
for { /* Single thread for reading route NL msgs in below order */
RUWorker(nNl.FromRUCh, nNl.FromRUDone)
Expand Down Expand Up @@ -1549,6 +1550,7 @@ func NlpInit(bgpPeerMode bool, blackList string, ipvsCompat bool) *NlH {

nNl.BlackList = blackList
nNl.BLRgx = regexp.MustCompile(blackList)
checkInit := make(chan bool)

if bgpPeerMode {
nNl.FromRUCh = make(chan nlp.RouteUpdate, cmn.RuWorkQLen)
Expand All @@ -1559,7 +1561,8 @@ func NlpInit(bgpPeerMode bool, blackList string, ipvsCompat bool) *NlH {
tk.LogIt(tk.LogInfo, "[NLP] Route msgs subscribed\n")
}

go NLWorker(nNl, bgpPeerMode)
go NLWorker(nNl, bgpPeerMode, checkInit)
<-checkInit
return nNl
}

Expand All @@ -1573,7 +1576,8 @@ func NlpInit(bgpPeerMode bool, blackList string, ipvsCompat bool) *NlH {
nNl.FromRUCh = make(chan nlp.RouteUpdate, cmn.RuWorkQLen)
nNl.IMap = make(map[string]Intf)

checkInit := make(chan bool)
go NLWorker(nNl, bgpPeerMode, checkInit)
<-checkInit

err := nlp.LinkSubscribe(nNl.FromLUCh, nNl.FromLUDone)
if err != nil {
Expand All @@ -1600,7 +1604,6 @@ func NlpInit(bgpPeerMode bool, blackList string, ipvsCompat bool) *NlH {
tk.LogIt(tk.LogInfo, "[NLP] Route msgs subscribed\n")
}

go NLWorker(nNl, bgpPeerMode)
tk.LogIt(tk.LogInfo, "[NLP] NLP Subscription done\n")

go NlpGet(checkInit)
Expand Down
4 changes: 2 additions & 2 deletions cicd/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,10 @@ create_docker_host_vxlan() {
#echo "$h1:$link1->$h2:$link2"

if [[ "$uifType" == "phy" ]]; then
sudo ip -n $h1 link add vxlan$vxid type vxlan id $vxid local $lip dev $link1 dstport 4789
sudo ip -n $h1 link add vxlan$vxid type vxlan id $vxid local $lip dev $link1 dstport 0
sudo ip -n $h1 link set vxlan$vxid up
elif [[ "$uifType" == "vlan" ]]; then
sudo ip -n $h1 link add vxlan$vxid type vxlan id $vxid local $lip dev vlan$vid dstport 4789
sudo ip -n $h1 link add vxlan$vxid type vxlan id $vxid local $lip dev vlan$vid dstport 0
sudo ip -n $h1 link set vxlan$vxid up
fi

Expand Down
2 changes: 1 addition & 1 deletion loxilb-ebpf
20 changes: 12 additions & 8 deletions loxinet/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -1431,10 +1431,12 @@ func (R *RuleH) AddNatLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIPArg,
if r.ruleNum < RtMaximumLbs {
R.tables[RtLB].rArr[r.ruleNum] = r
}
R.vipMap[sNetAddr.IP.String()]++
if !strings.Contains(r.name, "ipvs") {
R.vipMap[sNetAddr.IP.String()]++

if R.vipMap[sNetAddr.IP.String()] == 1 && !strings.Contains(r.name, "ipvs") {
R.AdvRuleVIPIfL2(sNetAddr.IP)
if R.vipMap[sNetAddr.IP.String()] == 1 {
R.AdvRuleVIPIfL2(sNetAddr.IP)
}
}

r.DP(DpCreate)
Expand Down Expand Up @@ -1496,13 +1498,15 @@ func (R *RuleH) DeleteNatLbRule(serv cmn.LbServiceArg) (int, error) {
R.tables[RtLB].rArr[rule.ruleNum] = nil
}

R.vipMap[sNetAddr.IP.String()]--
if !strings.Contains(rule.name, "ipvs") {
R.vipMap[sNetAddr.IP.String()]--

if R.vipMap[sNetAddr.IP.String()] == 0 {
if IsIPHostAddr(sNetAddr.IP.String()) && !strings.Contains(rule.name, "ipvs") {
loxinlp.DelAddrNoHook(sNetAddr.IP.String()+"/32", "lo")
if R.vipMap[sNetAddr.IP.String()] == 0 {
if IsIPHostAddr(sNetAddr.IP.String()) {
loxinlp.DelAddrNoHook(sNetAddr.IP.String()+"/32", "lo")
}
delete(R.vipMap, sNetAddr.IP.String())
}
delete(R.vipMap, sNetAddr.IP.String())
}

tk.LogIt(tk.LogDebug, "nat lb-rule deleted %s-%s\n", rule.tuples.String(), rule.act.String())
Expand Down

0 comments on commit 412c4e0

Please sign in to comment.