diff --git a/pkg/ebpf/tracee.go b/pkg/ebpf/tracee.go index 1e29f7f34193..a0b9af2935fe 100644 --- a/pkg/ebpf/tracee.go +++ b/pkg/ebpf/tracee.go @@ -1494,7 +1494,7 @@ func (t *Tracee) getSelfLoadedPrograms(kprobesOnly bool) map[string]int { // userland process itself, and not from the kernel. These events usually serve as informational // events for the signatures engine/logic. func (t *Tracee) invokeInitEvents(out chan *trace.Event) { - var emit uint64 + var submit uint64 setMatchedPolicies := func(event *trace.Event, matchedPolicies uint64, pols *policy.Policies) { event.PoliciesVersion = pols.Version() @@ -1505,33 +1505,31 @@ func (t *Tracee) invokeInitEvents(out chan *trace.Event) { // Initial namespace events - emit = t.eventsState[events.InitNamespaces].Emit - if emit > 0 { + submit = t.eventsState[events.InitNamespaces].Submit + if submit > 0 { systemInfoEvent := events.InitNamespacesEvent() - setMatchedPolicies(&systemInfoEvent, emit, t.config.Policies) + setMatchedPolicies(&systemInfoEvent, submit, t.config.Policies) out <- &systemInfoEvent - _ = t.stats.EventCount.Increment() } // Initial existing containers events (1 event per container) - emit = t.eventsState[events.ExistingContainer].Emit - if emit > 0 { + submit = t.eventsState[events.ExistingContainer].Submit + if submit > 0 { existingContainerEvents := events.ExistingContainersEvents(t.containers, t.config.NoContainersEnrich) for i := range existingContainerEvents { event := &(existingContainerEvents[i]) - setMatchedPolicies(event, emit, t.config.Policies) + setMatchedPolicies(event, submit, t.config.Policies) out <- event - _ = t.stats.EventCount.Increment() } } // Ftrace hook event - emit = t.eventsState[events.FtraceHook].Emit - if emit > 0 { + submit = t.eventsState[events.FtraceHook].Submit + if submit > 0 { ftraceBaseEvent := events.GetFtraceBaseEvent() - setMatchedPolicies(ftraceBaseEvent, emit, t.config.Policies) + setMatchedPolicies(ftraceBaseEvent, submit, t.config.Policies) logger.Debugw("started ftraceHook goroutine") // TODO: Ideally, this should be inside the goroutine and be computed before each run,