Skip to content

Commit

Permalink
usm: sowatcher: Determine which probes to enable
Browse files Browse the repository at this point in the history
Determine if we can and should use the more advanced fexit version of the probes
or if we should rely on the old versions via tracepoints
  • Loading branch information
guyarb committed Dec 21, 2024
1 parent 4c7a532 commit b1ff77a
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions pkg/network/usm/sharedlibraries/ebpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,30 +592,42 @@ func fexitSupported(funcName string) bool {

// initializedProbes initializes the probes that are enabled for the current system
func (e *EbpfProgram) initializeProbes() {
openat2Supported := sysOpenAt2Supported()
isFexitSupported := fexitSupported("do_sys_openat2")

advancedProbes := []manager.ProbeIdentificationPair{
{
EBPFFuncName: fmt.Sprintf("do_sys_%s_exit", openat2SysCall),
UID: probeUID,
},
}

openatProbes := []string{openatSysCall}
if openat2Supported {
openatProbes = append(openatProbes, openat2SysCall)
}
// amd64 has open(2), arm64 doesn't
if runtime.GOARCH == "amd64" {
openatProbes = append(openatProbes, openSysCall)
}

res := make([]manager.ProbeIdentificationPair, 0, len(traceTypes)*len(openatProbes))
oldProbes := make([]manager.ProbeIdentificationPair, 0, len(traceTypes)*len(openatProbes))
for _, probe := range openatProbes {
for _, traceType := range traceTypes {
res = append(res, manager.ProbeIdentificationPair{
oldProbes = append(oldProbes, manager.ProbeIdentificationPair{
EBPFFuncName: fmt.Sprintf("tracepoint__syscalls__sys_%s_%s", traceType, probe),
UID: probeUID,
})
}
}

if sysOpenAt2Supported() {
res = append(res, manager.ProbeIdentificationPair{
EBPFFuncName: fmt.Sprintf("do_sys_%s_exit", openat2SysCall),
UID: probeUID,
})
if isFexitSupported && openat2Supported {
e.enabledProbes = advancedProbes
e.disabledProbes = oldProbes
} else {
e.enabledProbes = oldProbes
e.disabledProbes = advancedProbes
}

e.enabledProbes = res
}

func getAssetName(module string, debug bool) string {
Expand Down

0 comments on commit b1ff77a

Please sign in to comment.