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 - Modifications to egress hook handling #505

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Modifications to egress hook handling
  • Loading branch information
TrekkieCoder committed Jan 24, 2024
commit acd704bed4ef65f08a77cf99129aec068c60b520
36 changes: 29 additions & 7 deletions api/loxinlp/nlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -924,8 +924,12 @@ func AddAddrNoHook(address, ifName string) int {
var ret int
IfName, err := nlp.LinkByName(ifName)
if err != nil {
tk.LogIt(tk.LogWarning, "[NLP] Port %s find Fail\n", ifName)
return -1
_, err := hooks.NetAddrAdd(&cmn.IPAddrMod{Dev: ifName, IP: address})
if err != nil {
tk.LogIt(tk.LogWarning, "[NLP] Hook IPv4 Address %v Port %v Add Fail\n", address, ifName)
return -1
}
return 0
}
Address, err := nlp.ParseAddr(address)
if err != nil {
Expand All @@ -944,8 +948,12 @@ func DelAddrNoHook(address, ifName string) int {
var ret int
IfName, err := nlp.LinkByName(ifName)
if err != nil {
tk.LogIt(tk.LogWarning, "[NLP] Port %s find Fail\n", ifName)
return -1
_, err := hooks.NetAddrDel(&cmn.IPAddrMod{Dev: ifName, IP: address})
if err != nil {
tk.LogIt(tk.LogWarning, "[NLP] Hook IPv4 Address %v Port %v delete Fail\n", address, ifName)
return -1
}
return 0
}
Address, err := nlp.ParseAddr(address)
if err != nil {
Expand Down Expand Up @@ -1247,9 +1255,9 @@ func AUWorkSingle(m nlp.AddrUpdate) int {
return -1
}

if iSBlackListedIntf(link.Attrs().Name, link.Attrs().MasterIndex) {
return -1
}
//if iSBlackListedIntf(link.Attrs().Name, link.Attrs().MasterIndex) {
// return -1
//}

attrs := link.Attrs()
name := attrs.Name
Expand Down Expand Up @@ -1421,6 +1429,20 @@ func NlpGet(ch chan bool) int {
for _, link := range links {

if iSBlackListedIntf(link.Attrs().Name, link.Attrs().MasterIndex) {
// Need addresss to work with
addrs, err := nlp.AddrList(link, nlp.FAMILY_ALL)
if err != nil {
tk.LogIt(tk.LogError, "[NLP] Error getting address list %v for intf %s\n",
err, link.Attrs().Name)
}

if len(addrs) == 0 {
tk.LogIt(tk.LogDebug, "[NLP] No addresses found for intf %s\n", link.Attrs().Name)
} else {
for _, addr := range addrs {
AddAddr(addr, link)
}
}
continue
}

Expand Down
2 changes: 1 addition & 1 deletion loxilb-ebpf
14 changes: 14 additions & 0 deletions loxinet/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,11 @@ func (R *RuleH) DeleteNatLbRule(serv cmn.LbServiceArg) (int, error) {
if IsIPHostAddr(sNetAddr.IP.String()) {
loxinlp.DelAddrNoHook(sNetAddr.IP.String()+"/32", "lo")
}
dev := fmt.Sprintf("llb-rule-%s", sNetAddr.IP.String())
ret, _ := mh.zr.L3.IfaFind(dev, sNetAddr.IP)
if ret != 0 {
mh.zr.L3.IfaDelete(dev, sNetAddr.IP.String()+"/32")
}
delete(R.vipMap, sNetAddr.IP.String())
}
}
Expand Down Expand Up @@ -2562,6 +2567,15 @@ func (R *RuleH) AdvRuleVIPIfL2(IP net.IP) error {
tk.LogIt(tk.LogInfo, "nat lb-rule vip %s:%s deleted\n", IP.String(), "lo")
}
}
} else {
dev := fmt.Sprintf("llb-rule-%s", IP.String())
ret, _ := mh.zr.L3.IfaFind(dev, IP)
if ret != 0 {
_, err := mh.zr.L3.IfaAdd(dev, IP.String()+"/32")
if err != nil {
fmt.Printf("Failed to add IP : %s:%s\n", dev, err)
}
}
}

return nil
Expand Down