Skip to content

Commit

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

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
  • Loading branch information
olsajiri committed Sep 24, 2024
1 parent 66374e4 commit 1893ee5
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pkg/sensors/program/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@
// - 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. It can be either:
//
// MapOwnerMe - Map object owns the pinned map and when loading it sets
// (and potentially overwrite) the map's spec and its max
// entries value
// MapOwnerOther - Map object is just the user of 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 @@ -141,6 +150,26 @@ func MapBuilderType(name string, ty MapType, lds ...*Program) *Map {
return mapBuilder(name, ty, MapOwnerMe, lds...)
}

func MapBuilderOpts(name string, opts MapOpts, lds ...*Program) *Map {
return mapBuilder(name, opts.Type, opts.Owner, lds...)
}

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

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

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

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

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

0 comments on commit 1893ee5

Please sign in to comment.