Skip to content

Commit

Permalink
Merge pull request #379 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
PR - ct sync optimizations
  • Loading branch information
UltraInstinct14 authored Aug 22, 2023
2 parents 3b146d7 + a3352c3 commit 26d5cfa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion loxilb-ebpf
17 changes: 8 additions & 9 deletions loxinet/dpebpf_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ const (
DpEbpfLinuxTiVal = 10
ctiDeleteSyncRetries = 4
blkCtiMaxLen = 4096
mapNotifierChLen = 131072
mapNotifierWorkers = 5
mapNotifierChLen = 8096
mapNotifierWorkers = 2
)

// ebpf table related defines in go
Expand Down Expand Up @@ -1595,7 +1595,7 @@ func goMapNotiHandler(m *mapNoti) {
ctKey := (*C.struct_dp_ct_key)(unsafe.Pointer(m.key))

// Only connection oriented protocols
if mh.dpEbpf == nil || (ctKey.l4proto != 6 && ctKey.l4proto != 132) {
if m.addop == 0 || mh.dpEbpf == nil || (ctKey.l4proto != 6 && ctKey.l4proto != 132) {
return
}

Expand All @@ -1606,7 +1606,8 @@ func goMapNotiHandler(m *mapNoti) {
goCtEnt.PVal = C.GoBytes(unsafe.Pointer(m.val), m.val_len)
}

mh.dpEbpf.ToMapCh <- goCtEnt
dpCTMapNotifierWorker(goCtEnt)
//mh.dpEbpf.ToMapCh <- goCtEnt
}

func dpCTMapNotifierWorker(cti *DpCtInfo) {
Expand Down Expand Up @@ -1658,10 +1659,8 @@ func dpCTMapNotifierWorker(cti *DpCtInfo) {
mh.dpEbpf.mtx.Lock()
defer mh.dpEbpf.mtx.Unlock()

mapKey := cti.Key()

if addOp == false {
cti = mh.dpEbpf.ctMap[mapKey]
cti = mh.dpEbpf.ctMap[cti.Key()]
if cti == nil || cti.Deleted > 0 {
return
}
Expand Down Expand Up @@ -1786,7 +1785,7 @@ func dpCTMapChkUpdates() {
continue
}
if C.bpf_map_lookup_elem(C.int(fd), unsafe.Pointer(&cti.PKey[0]), unsafe.Pointer(&tact)) != 0 {
tk.LogIt(tk.LogInfo, "[CT] ent not found %s\n", cti.Key())
tk.LogIt(tk.LogDebug, "[CT] ent not found %s\n", cti.Key())
//delete(mh.dpEbpf.ctMap, cti.Key())
cti.Deleted++
cti.XSync = true
Expand Down Expand Up @@ -1825,7 +1824,7 @@ func dpCTMapChkUpdates() {
if cti.Deleted > 0 {
delete(mh.dpEbpf.ctMap, cti.Key())
// This is a strange fix - See comment above
C.llb_del_map_elem(C.LL_DP_CT_MAP, unsafe.Pointer(&cti.PKey[0]))
//C.llb_del_map_elem(C.LL_DP_CT_MAP, unsafe.Pointer(&cti.PKey[0]))
}
}
}
Expand Down

0 comments on commit 26d5cfa

Please sign in to comment.