Skip to content

Commit

Permalink
variable: add VariableSpec.MapName() and .Offset() methods
Browse files Browse the repository at this point in the history
Cilium's variable inliner needs this information to look up variable contents
based on the offset specified in the instruction stream, and wants to validate
that it's pulling data from the right data section.

It makes for a slightly leaky abstraction, but at least something meaningful
can be accomplished by combining the two, e.g. by accessing the given offset
in the map.

Signed-off-by: Timo Beckers <[email protected]>
  • Loading branch information
ti-mo committed Nov 14, 2024
1 parent 2ce8a41 commit ec48f59
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ func (s *VariableSpec) Size() uint64 {
return s.size
}

// MapName returns the name of the underlying MapSpec.
func (s *VariableSpec) MapName() string {
return s.m.Name
}

// Offset returns the offset of the variable in the underlying MapSpec.
func (s *VariableSpec) Offset() uint64 {
return s.offset
}

// Constant returns true if the VariableSpec represents a variable that is
// read-only from the perspective of the BPF program.
func (s *VariableSpec) Constant() bool {
Expand Down

0 comments on commit ec48f59

Please sign in to comment.