Skip to content

Commit

Permalink
tetragon: Remove id from tracing sensors name
Browse files Browse the repository at this point in the history
It's no longer needed, because all sensors are now placed
in policy directory.

Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Sep 14, 2024
1 parent 79f43bb commit fcd79d5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 16 deletions.
5 changes: 1 addition & 4 deletions pkg/sensors/tracing/enforcer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"path"
"strings"
"sync"
"sync/atomic"

"github.com/cilium/tetragon/pkg/arch"
"github.com/cilium/tetragon/pkg/bpf"
Expand Down Expand Up @@ -95,8 +94,7 @@ func (kp *enforcerPolicy) PolicyHandler(
}
}
if len(spec.Enforcers) > 0 {
name := fmt.Sprintf("enforcer-sensor-%d", atomic.AddUint64(&sensorCounter, 1))
return kp.createEnforcerSensor(spec.Enforcers, spec.Lists, spec.Options, name, policy.TpName())
return kp.createEnforcerSensor(spec.Enforcers, spec.Lists, spec.Options, policy.TpName())
}

return nil, nil
Expand Down Expand Up @@ -185,7 +183,6 @@ func (kp *enforcerPolicy) createEnforcerSensor(
enforcers []v1alpha1.EnforcerSpec,
lists []v1alpha1.ListSpec,
opts []v1alpha1.OptionSpec,
name string,
policyName string,
) (*sensors.Sensor, error) {

Expand Down
2 changes: 0 additions & 2 deletions pkg/sensors/tracing/generictracepoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ var (
genericTracepointTable = tracepointTable{}

tracepointLog logrus.FieldLogger

sensorCounter uint64
)

type observerTracepointSensor struct {
Expand Down
5 changes: 1 addition & 4 deletions pkg/sensors/tracing/genericuprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"errors"
"fmt"
"path"
"sync/atomic"

"github.com/cilium/ebpf"
"github.com/cilium/tetragon/pkg/api/ops"
Expand Down Expand Up @@ -493,7 +492,5 @@ func (k *observerUprobeSensor) PolicyHandler(
return nil, fmt.Errorf("uprobe sensor does not implement policy filtering")
}

name := fmt.Sprintf("gup-sensor-%d", atomic.AddUint64(&sensorCounter, 1))
policyName := p.TpName()
return createGenericUprobeSensor(name, spec, policyName)
return createGenericUprobeSensor("generic_uprobe", spec, p.TpName())
}
9 changes: 3 additions & 6 deletions pkg/sensors/tracing/policyhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package tracing
import (
"errors"
"fmt"
"sync/atomic"

"github.com/cilium/tetragon/pkg/eventhandler"
"github.com/cilium/tetragon/pkg/policyfilter"
Expand Down Expand Up @@ -44,20 +43,18 @@ func (h policyHandler) PolicyHandler(

handler := eventhandler.GetCustomEventhandler(policy)
if len(spec.KProbes) > 0 {
name := fmt.Sprintf("gkp-sensor-%d", atomic.AddUint64(&sensorCounter, 1))
name := "generic_kprobe"
err := preValidateKprobes(name, spec.KProbes, spec.Lists)
if err != nil {
return nil, fmt.Errorf("validation failed: %w", err)
}
return createGenericKprobeSensor(spec, name, policyID, policyName, handler)
}
if len(spec.Tracepoints) > 0 {
name := fmt.Sprintf("gtp-sensor-%d", atomic.AddUint64(&sensorCounter, 1))
return createGenericTracepointSensor(spec, name, policyID, policyName, handler)
return createGenericTracepointSensor(spec, "generic_tracepoint", policyID, policyName, handler)
}
if len(spec.LsmHooks) > 0 {
name := fmt.Sprintf("glsm-sensor-%d", atomic.AddUint64(&sensorCounter, 1))
return createGenericLsmSensor(spec, name, policyID, policyName)
return createGenericLsmSensor(spec, "generic_lsm", policyID, policyName)
}
return nil, nil
}

0 comments on commit fcd79d5

Please sign in to comment.