Skip to content

Commit

Permalink
tetragon: Add sensor PostLoadHook hook
Browse files Browse the repository at this point in the history
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
  • Loading branch information
olsajiri committed Jan 22, 2024
1 parent d3d0be5 commit eb71638
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 @@ -115,6 +115,11 @@ func (s *Sensor) Load(bpfDir, mapDir 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 @@ -43,6 +43,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 eb71638

Please sign in to comment.