Skip to content

Commit

Permalink
[generickprobe.go] Add ExtractParam/OverwriteType usage for kprobes
Browse files Browse the repository at this point in the history
Add very similar code as in `genericlsm.go` file to handle those params.
In a future commit, a refactoring should be acheived to avoid code
redundant code with `genericlsm.go`

Signed-off-by: Tristan d'Audibert <[email protected]>
  • Loading branch information
ScriptSathi committed Nov 23, 2024
1 parent 59974f0 commit 1fb7dbc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/sensors/tracing/generickprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ func addKprobe(funcName string, instance int, f *v1alpha1.KProbeSpec, in *addKpr
var setRetprobe bool
var argRetprobe *v1alpha1.KProbeArg
var argsBTFSet [api.MaxArgsSupported]bool
var allBtfArgs [api.EventConfigMaxArgs][api.MaxBtfArgDepth]api.ConfigBtfArg

errFn := func(err error) (idtable.EntryID, error) {
return idtable.UninitializedEntryID, err
Expand Down Expand Up @@ -754,6 +755,15 @@ func addKprobe(funcName string, instance int, f *v1alpha1.KProbeSpec, in *addKpr
argType = gt.GenericTypeFromString(a.Type)
}

if a.ExtractParam != "" && j < api.EventConfigMaxArgs {
allBtfArgs[j] = [api.MaxBtfArgDepth]api.ConfigBtfArg{}
lastBtfType, err := buildBtfArg(a, &allBtfArgs[j])
if err != nil {
return errFn(err)
}
argType = findTypeFromBtfType(a, lastBtfType)
}

if argType == gt.GenericInvalidType {
return errFn(fmt.Errorf("Arg(%d) type '%s' unsupported", j, a.Type))
}
Expand All @@ -777,6 +787,7 @@ func addKprobe(funcName string, instance int, f *v1alpha1.KProbeSpec, in *addKpr
return errFn(fmt.Errorf("Error add arg: ArgType %s Index %d out of bounds",
a.Type, int(a.Index)))
}
config.BtfArg = allBtfArgs
config.Arg[a.Index] = int32(argType)
config.ArgM[a.Index] = uint32(argMValue)

Expand Down

0 comments on commit 1fb7dbc

Please sign in to comment.