diff --git a/pkg/sensors/base/base.go b/pkg/sensors/base/base.go index b09952adaf2..ec2798bb161 100644 --- a/pkg/sensors/base/base.go +++ b/pkg/sensors/base/base.go @@ -166,7 +166,6 @@ func GetInitialSensor() *sensors.Sensor { sensorInit.Do(func() { setupPrograms() sensor.Progs = GetDefaultPrograms(option.CgroupRateEnabled()) - sensor.Maps = GetDefaultMaps(option.CgroupRateEnabled()) }) return &sensor } @@ -175,7 +174,6 @@ func GetInitialSensorTest() *sensors.Sensor { sensorTestInit.Do(func() { setupPrograms() sensorTest.Progs = GetDefaultPrograms(true) - sensorTest.Maps = GetDefaultMaps(true) }) return &sensorTest } diff --git a/pkg/sensors/load.go b/pkg/sensors/load.go index 800d7f62cc6..b57886598e0 100644 --- a/pkg/sensors/load.go +++ b/pkg/sensors/load.go @@ -107,7 +107,6 @@ func (s *Sensor) Load(bpfDir string) error { // Add the *loaded* programs and maps, so they can be unloaded later progsAdd(s.Progs) - AllMaps = append(AllMaps, s.Maps...) l.WithField("sensor", s.Name).Infof("Loaded BPF maps and events for sensor successfully") s.Loaded = true @@ -196,10 +195,10 @@ func (s *Sensor) FindPrograms() error { if err := s.findProgram(p); err != nil { return err } - } - for _, m := range s.Maps { - if err := s.findProgram(m.Prog); err != nil { - return err + for _, m := range p.PinMap { + if err := s.findProgram(m.Prog); err != nil { + return err + } } } return nil @@ -207,16 +206,13 @@ func (s *Sensor) FindPrograms() error { func mergeSensors(sensors []*Sensor) *Sensor { var progs []*program.Program - var maps []*program.Map for _, s := range sensors { progs = append(progs, s.Progs...) - maps = append(maps, s.Maps...) } return &Sensor{ Name: "__main__", Progs: progs, - Maps: maps, } } diff --git a/pkg/sensors/sensors.go b/pkg/sensors/sensors.go index 4222ae5a691..15c6b82d91a 100644 --- a/pkg/sensors/sensors.go +++ b/pkg/sensors/sensors.go @@ -41,8 +41,6 @@ type Sensor struct { Name string // Progs are all the BPF programs that exist on the filesystem. Progs []*program.Program - // Maps are all the BPF Maps that the progs use. - Maps []*program.Map // Loaded indicates whether the sensor has been Loaded. Loaded bool // Destroyed indicates whether the sensor had been destroyed. @@ -84,19 +82,16 @@ type SensorHook func() error func SensorCombine(name string, sensors ...*Sensor) *Sensor { progs := []*program.Program{} - maps := []*program.Map{} for _, s := range sensors { progs = append(progs, s.Progs...) - maps = append(maps, s.Maps...) } - return SensorBuilder(name, progs, maps) + return SensorBuilder(name, progs) } -func SensorBuilder(name string, p []*program.Program, m []*program.Map) *Sensor { +func SensorBuilder(name string, p []*program.Program) *Sensor { return &Sensor{ Name: name, Progs: p, - Maps: m, } } diff --git a/pkg/sensors/test/cgroups.go b/pkg/sensors/test/cgroups.go index 7c98bb2a40e..b6ac19409de 100644 --- a/pkg/sensors/test/cgroups.go +++ b/pkg/sensors/test/cgroups.go @@ -50,18 +50,10 @@ func getCgroupPrograms() []*program.Program { return progs } -func getCgroupMaps() []*program.Map { - maps := []*program.Map{ - GetCgroupsTrackingMap(), - } - return maps -} - // GetCgroupSensor returns the Cgroups base sensor func GetCgroupSensor() *sensors.Sensor { return &sensors.Sensor{ Name: "test-sensor-cgroups", Progs: getCgroupPrograms(), - Maps: getCgroupMaps(), } } diff --git a/pkg/sensors/test/test.go b/pkg/sensors/test/test.go index 38051b36200..4d4d8f6100c 100644 --- a/pkg/sensors/test/test.go +++ b/pkg/sensors/test/test.go @@ -66,7 +66,6 @@ func GetTestSensor() *sensors.Sensor { sensors.PathJoin(sensorName, "test_lseek_prog"), "tracepoint", )} - maps := []*program.Map{} - sensor := &sensors.Sensor{Name: sensorName, Progs: progs, Maps: maps} + sensor := &sensors.Sensor{Name: sensorName, Progs: progs} return sensor } diff --git a/pkg/sensors/tracing/enforcer.go b/pkg/sensors/tracing/enforcer.go index 1266376dc98..e1302ed4b38 100644 --- a/pkg/sensors/tracing/enforcer.go +++ b/pkg/sensors/tracing/enforcer.go @@ -326,10 +326,11 @@ func (kp *enforcerPolicy) createEnforcerSensor( logger.GetLogger().Infof("Added enforcer sensor '%s'", name) + fmt.Printf("KRAVA maps %d\n", len(maps)) + return &sensors.Sensor{ Name: "__enforcer__", Progs: progs, - Maps: maps, PostUnloadHook: func() error { if ok := kp.enforcerDel(name); !ok { logger.GetLogger().Infof("Failed to clean up enforcer sensor '%s'", name) diff --git a/pkg/sensors/tracing/generickprobe.go b/pkg/sensors/tracing/generickprobe.go index a4c4fbff7b8..272f11be975 100644 --- a/pkg/sensors/tracing/generickprobe.go +++ b/pkg/sensors/tracing/generickprobe.go @@ -658,10 +658,11 @@ func createGenericKprobeSensor( return nil, err } + fmt.Printf("KRAVA maps %d\n", len(maps)) + return &sensors.Sensor{ Name: name, Progs: progs, - Maps: maps, DestroyHook: func() error { var errs error for _, id := range ids { diff --git a/pkg/sensors/tracing/genericlsm.go b/pkg/sensors/tracing/genericlsm.go index fff5316cd92..d652cc0f999 100644 --- a/pkg/sensors/tracing/genericlsm.go +++ b/pkg/sensors/tracing/genericlsm.go @@ -327,10 +327,11 @@ func createGenericLsmSensor( return nil, err } + fmt.Printf("KRAVA maps %d\n", len(maps)) + return &sensors.Sensor{ Name: name, Progs: progs, - Maps: maps, DestroyHook: func() error { var errs error for _, id := range ids { diff --git a/pkg/sensors/tracing/generictracepoint.go b/pkg/sensors/tracing/generictracepoint.go index a81ec1541fd..b2dcc08eb01 100644 --- a/pkg/sensors/tracing/generictracepoint.go +++ b/pkg/sensors/tracing/generictracepoint.go @@ -509,10 +509,11 @@ func createGenericTracepointSensor( maps = append(maps, selMatchBinariesMap) } + fmt.Printf("KRAVA maps %d\n", len(maps)) + return &sensors.Sensor{ Name: name, Progs: progs, - Maps: maps, }, nil } diff --git a/pkg/sensors/tracing/genericuprobe.go b/pkg/sensors/tracing/genericuprobe.go index e7eca3e7c1e..2155d947d36 100644 --- a/pkg/sensors/tracing/genericuprobe.go +++ b/pkg/sensors/tracing/genericuprobe.go @@ -287,10 +287,11 @@ func createGenericUprobeSensor( return nil, err } + fmt.Printf("KRAVA maps %d\n", len(maps)) + return &sensors.Sensor{ Name: name, Progs: progs, - Maps: maps, }, nil } diff --git a/pkg/sensors/tracing/loader.go b/pkg/sensors/tracing/loader.go index 43fe98d0df6..75d7bc592e8 100644 --- a/pkg/sensors/tracing/loader.go +++ b/pkg/sensors/tracing/loader.go @@ -104,7 +104,6 @@ func GetLoaderSensor() *sensors.Sensor { return &sensors.Sensor{ Name: "__loader__", Progs: []*program.Program{loader}, - Maps: []*program.Map{idsMap}, } }