From ac89f80073c8652275c2dfb6d1856b52be6218ed Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 2 Jun 2024 19:43:29 +0000 Subject: [PATCH] tetragon: Remove id from tracing sensors name It' no longer needed, because all sensors are now placed in policy directory. Signed-off-by: Jiri Olsa --- pkg/sensors/tracing/enforcer.go | 5 +---- pkg/sensors/tracing/generictracepoint.go | 2 -- pkg/sensors/tracing/genericuprobe.go | 5 +---- pkg/sensors/tracing/policyhandler.go | 7 +++---- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/pkg/sensors/tracing/enforcer.go b/pkg/sensors/tracing/enforcer.go index 96f24d70cd8..3fc5114c5d5 100644 --- a/pkg/sensors/tracing/enforcer.go +++ b/pkg/sensors/tracing/enforcer.go @@ -8,7 +8,6 @@ import ( "path" "strings" "sync" - "sync/atomic" "github.com/cilium/tetragon/pkg/arch" "github.com/cilium/tetragon/pkg/bpf" @@ -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 @@ -185,7 +183,6 @@ func (kp *enforcerPolicy) createEnforcerSensor( enforcers []v1alpha1.EnforcerSpec, lists []v1alpha1.ListSpec, opts []v1alpha1.OptionSpec, - name string, policyName string, ) (*sensors.Sensor, error) { diff --git a/pkg/sensors/tracing/generictracepoint.go b/pkg/sensors/tracing/generictracepoint.go index 1e6df4f8027..2d8aa4bcc47 100644 --- a/pkg/sensors/tracing/generictracepoint.go +++ b/pkg/sensors/tracing/generictracepoint.go @@ -47,8 +47,6 @@ var ( genericTracepointTable = tracepointTable{} tracepointLog logrus.FieldLogger - - sensorCounter uint64 ) type observerTracepointSensor struct { diff --git a/pkg/sensors/tracing/genericuprobe.go b/pkg/sensors/tracing/genericuprobe.go index fc73fdb0c82..b3a6b7d5788 100644 --- a/pkg/sensors/tracing/genericuprobe.go +++ b/pkg/sensors/tracing/genericuprobe.go @@ -9,7 +9,6 @@ import ( "errors" "fmt" "path" - "sync/atomic" "github.com/cilium/ebpf" "github.com/cilium/tetragon/pkg/api/ops" @@ -490,7 +489,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()) } diff --git a/pkg/sensors/tracing/policyhandler.go b/pkg/sensors/tracing/policyhandler.go index 7ddb30d3df0..b016bfc96db 100644 --- a/pkg/sensors/tracing/policyhandler.go +++ b/pkg/sensors/tracing/policyhandler.go @@ -6,7 +6,6 @@ package tracing import ( "errors" "fmt" - "sync/atomic" "github.com/cilium/tetragon/pkg/eventhandler" "github.com/cilium/tetragon/pkg/policyfilter" @@ -33,7 +32,7 @@ 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) @@ -41,8 +40,8 @@ func (h policyHandler) PolicyHandler( return createGenericKprobeSensor(spec, name, policyID, policyName, handler) } if len(spec.Tracepoints) > 0 { - name := fmt.Sprintf("gtp-sensor-%d", atomic.AddUint64(&sensorCounter, 1)) - return createGenericTracepointSensor(name, spec.Tracepoints, policyID, policyName, spec.Lists, handler) + return createGenericTracepointSensor("generic_tracepoint", spec.Tracepoints, policyID, + policyName, spec.Lists, handler) } return nil, nil }