Skip to content

Commit

Permalink
tetragon: Add sensor PostLoadHook hook
Browse files Browse the repository at this point in the history
Adding sensor PostLoadHook hook, it will be used in following
changes in kprobe sensor to kill the stats timer.

Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Apr 9, 2024
1 parent d4ce92a commit b9b9488
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/sensors/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkg/sensors/sensors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b9b9488

Please sign in to comment.