Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tetragon: Fix map PinPath setup in case the map is shared #2944

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pkg/sensors/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ func (s *Sensor) setMapPinPath(m *program.Map) {
func (s *Sensor) loadMaps(bpfDir string) error {
l := logger.GetLogger()
for _, m := range s.Maps {
// Even if the map already exists we need to setup proper PinPath
// so the loader can have access to the map location.
s.setMapPinPath(m)

if m.PinState.IsLoaded() {
l.WithFields(logrus.Fields{
"sensor": s.Name,
Expand All @@ -245,9 +249,6 @@ func (s *Sensor) loadMaps(bpfDir string) error {
continue
}

s.setMapPinPath(m)
pinPath := filepath.Join(bpfDir, m.PinPath)

spec, err := ebpf.LoadCollectionSpec(m.Prog.Name)
if err != nil {
return fmt.Errorf("failed to open collection '%s': %w", m.Prog.Name, err)
Expand All @@ -267,6 +268,8 @@ func (s *Sensor) loadMaps(bpfDir string) error {
}
}

pinPath := filepath.Join(bpfDir, m.PinPath)

if err := m.LoadOrCreatePinnedMap(pinPath, mapSpec); err != nil {
return fmt.Errorf("failed to load map '%s' for sensor '%s': %w", m.Name, s.Name, err)
}
Expand Down
Loading