Skip to content

Commit

Permalink
tetragon: Add MapUser* interface
Browse files Browse the repository at this point in the history
Adding MapUser* interface to create map that you don't own.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
  • Loading branch information
olsajiri committed Sep 26, 2024
1 parent ec44a0e commit f6b00f8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pkg/sensors/program/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@
// - map is local for program, not shared at all
//
// NOTE Please do not share MapTypeProgram maps, it brings confusion.
//
// Each map declares the ownership of the map. The map can be either
// owner of the map (via MapBuilder* helpers) or as an user (MapUser*
// helpers.
//
// Map owner object owns the pinned map and when loading it sets (and
// potentially overwrite) the map's spec and its max entries value.
//
// Map user object object is just using the pinned map and follows its
// setup and will fail if the pinned map differs in spec or configured
// max entries value.

package program

Expand Down Expand Up @@ -138,6 +149,22 @@ func MapBuilderOpts(name string, opts MapOpts, lds ...*Program) *Map {
return mapBuilder(name, opts.Type, opts.Owner, lds...)
}

func MapUser(name string, lds ...*Program) *Map {
return mapBuilder(name, MapTypeGlobal, false, lds...)
}

func MapUserProgram(name string, lds ...*Program) *Map {
return mapBuilder(name, MapTypeProgram, false, lds...)
}

func MapUserSensor(name string, lds ...*Program) *Map {
return mapBuilder(name, MapTypeSensor, false, lds...)
}

func MapUserPolicy(name string, lds ...*Program) *Map {
return mapBuilder(name, MapTypePolicy, false, lds...)
}

func PolicyMapPath(mapDir, policy, name string) string {
return filepath.Join(mapDir, policy, name)
}
Expand Down

0 comments on commit f6b00f8

Please sign in to comment.