diff --git a/pkg/sensors/load.go b/pkg/sensors/load.go index ee931ae76d4..d61b6834892 100644 --- a/pkg/sensors/load.go +++ b/pkg/sensors/load.go @@ -114,6 +114,11 @@ func (s *Sensor) Load(bpfDir string) error { p.LoadState.RefInc() l.WithField("prog", p.Name).WithField("label", p.Label).Debugf("BPF prog was loaded") } + if s.PostLoadHook != nil { + if err := s.PostLoadHook(); err != nil { + logger.GetLogger().WithError(err).WithField("sensor", s.Name).Warn("Post load hook failed") + } + } l.WithField("sensor", s.Name).Infof("Loaded BPF maps and events for sensor successfully") s.Loaded = true return nil diff --git a/pkg/sensors/sensors.go b/pkg/sensors/sensors.go index ba6dd352f7b..38ce74f7aa0 100644 --- a/pkg/sensors/sensors.go +++ b/pkg/sensors/sensors.go @@ -44,6 +44,8 @@ type Sensor struct { Loaded bool // Destroyed indicates whether the sensor had been destroyed. Destroyed bool + // PostLoadHook hook + PostLoadHook SensorHook // PreUnloadHook can optionally contain a pointer to a function to be // called during sensor unloading, prior to the programs and maps being // unloaded.