Skip to content

Commit

Permalink
tetragon: Remove MapBuilderPin function
Browse files Browse the repository at this point in the history
It's no longer needed.

Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Feb 25, 2024
1 parent 544ca3c commit bbf0298
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
8 changes: 4 additions & 4 deletions pkg/sensors/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,13 @@ func (s *Sensor) FindPrograms() error {
func (s *Sensor) SetMapPinPath(m *program.Map) {
switch m.Type {
case program.MapTypeGlobal:
m.PinPath = filepath.Join(m.PinName)
m.PinPath = filepath.Join(m.Name)
case program.MapTypePolicy:
m.PinPath = filepath.Join(s.Policy, m.PinName)
m.PinPath = filepath.Join(s.Policy, m.Name)
case program.MapTypeSensor:
m.PinPath = filepath.Join(s.Policy, s.Name, m.PinName)
m.PinPath = filepath.Join(s.Policy, s.Name, m.Name)
case program.MapTypeProgram:
m.PinPath = filepath.Join(s.Policy, s.Name, m.Prog.PinName, m.PinName)
m.PinPath = filepath.Join(s.Policy, s.Name, m.Prog.PinName, m.Name)
}
}

Expand Down
15 changes: 5 additions & 10 deletions pkg/sensors/program/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,29 @@ const (
// Map represents BPF maps.
type Map struct {
Name string
PinName string
PinPath string
Prog *Program
PinState State
MapHandle *ebpf.Map
Type MapType
}

func mapBuilder(name, pin string, ld *Program, ty MapType) *Map {
m := &Map{name, pin, "", ld, Idle(), nil, ty}
func mapBuilder(name string, ld *Program, ty MapType) *Map {
m := &Map{name, "", ld, Idle(), nil, ty}
ld.PinMap[name] = m
return m
}

func MapBuilder(name string, ld *Program) *Map {
return mapBuilder(name, name, ld, MapTypeGlobal)
return mapBuilder(name, ld, MapTypeGlobal)
}

func MapBuilderType(name string, ld *Program, ty MapType) *Map {
return mapBuilder(name, name, ld, ty)
}

func MapBuilderPin(name, pin string, ld *Program) *Map {
return mapBuilder(name, pin, ld, MapTypeGlobal)
return mapBuilder(name, ld, ty)
}

func (m *Map) Unload() error {
log := logger.GetLogger().WithField("map", m.Name).WithField("pin", m.PinName)
log := logger.GetLogger().WithField("map", m.Name).WithField("pin", m.Name)
if !m.PinState.IsLoaded() {
log.WithField("count", m.PinState.count).Debug("Refusing to unload map as it is not loaded")
return nil
Expand Down

0 comments on commit bbf0298

Please sign in to comment.