Skip to content

Commit

Permalink
tetragon: Add support to disable uprobe multi through spec options
Browse files Browse the repository at this point in the history
Adding support to process options passed in spec for uprobe sensor.

At the moment the only supported option is to disable uprobe multi.

Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Mar 30, 2024
1 parent dce0075 commit f39de5f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions pkg/option/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const (
KeyNetnsDir = "netns-dir"

KeyDisableKprobeMulti = "disable-kprobe-multi"
KeyDisableUprobeMulti = "disable-uprobe-multi"

KeyRBSize = "rb-size"
KeyRBSizeTotal = "rb-size-total"
Expand Down
19 changes: 14 additions & 5 deletions pkg/sensors/tracing/genericuprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,22 +251,31 @@ type addUprobeIn struct {

func createGenericUprobeSensor(
name string,
uprobes []v1alpha1.UProbeSpec,
spec *v1alpha1.TracingPolicySpec,
policyName string,
) (*sensors.Sensor, error) {
var progs []*program.Program
var maps []*program.Map
var ids []idtable.EntryID
var err error

options, err := getSpecOptions(spec.Options)
if err != nil {
return nil, fmt.Errorf("failed to set options: %s", err)
}

in := addUprobeIn{
sensorPath: name,
policyName: policyName,
useMulti: bpf.HasUprobeMulti(),

// use multi kprobe only if:
// - it's not disabled by spec option
// - there's support detected
useMulti: !options.DisableUprobeMulti && bpf.HasUprobeMulti(),
}

for _, spec := range uprobes {
ids, err = addUprobe(&spec, ids, &in)
for _, uprobe := range spec.UProbes {
ids, err = addUprobe(&uprobe, ids, &in)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -489,5 +498,5 @@ func (k *observerUprobeSensor) PolicyHandler(

name := fmt.Sprintf("gup-sensor-%d", atomic.AddUint64(&sensorCounter, 1))
policyName := p.TpName()
return createGenericUprobeSensor(name, spec.UProbes, policyName)
return createGenericUprobeSensor(name, spec, policyName)
}
7 changes: 7 additions & 0 deletions pkg/sensors/tracing/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func overrideMethodParse(s string) OverrideMethod {

type specOptions struct {
DisableKprobeMulti bool
DisableUprobeMulti bool
OverrideMethod OverrideMethod
}

Expand All @@ -62,6 +63,12 @@ var opts = map[string]opt{
return err
},
},
option.KeyDisableUprobeMulti: opt{
set: func(str string, options *specOptions) (err error) {
options.DisableUprobeMulti, err = strconv.ParseBool(str)
return err
},
},
keyOverrideMethod: opt{
set: func(str string, options *specOptions) (err error) {
m := overrideMethodParse(str)
Expand Down

0 comments on commit f39de5f

Please sign in to comment.