Skip to content

Commit

Permalink
tetragon: Add entry selector data function
Browse files Browse the repository at this point in the history
Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Oct 10, 2023
1 parent e80e060 commit 0e7a578
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
29 changes: 19 additions & 10 deletions pkg/selectors/kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -1260,22 +1260,31 @@ func InitKernelSelectors(selectors []v1alpha1.KProbeSelector, args []v1alpha1.KP
return kernelSelectors.data.e, nil
}

func InitKernelSelectorState(selectors []v1alpha1.KProbeSelector, args []v1alpha1.KProbeArg,
actionArgTable *idtable.Table, listReader ValueReader) (*KernelSelectorState, error) {
kernelSelectors := NewKernelSelectorState(listReader)
func makeEntrySelector(k *KernelSelectorState, selectors []v1alpha1.KProbeSelector,
args []v1alpha1.KProbeArg, actionArgTable *idtable.Table) error {

WriteSelectorUint32(&kernelSelectors.data, uint32(len(selectors)))
WriteSelectorUint32(&k.data, uint32(len(selectors)))
soff := make([]uint32, len(selectors))
for i := range selectors {
soff[i] = AdvanceSelectorLength(&kernelSelectors.data)
soff[i] = AdvanceSelectorLength(&k.data)
}
for i, s := range selectors {
WriteSelectorLength(&kernelSelectors.data, soff[i])
loff := AdvanceSelectorLength(&kernelSelectors.data)
if err := parseSelector(kernelSelectors, &s, i, args, actionArgTable); err != nil {
return nil, err
WriteSelectorLength(&k.data, soff[i])
loff := AdvanceSelectorLength(&k.data)
if err := parseSelector(k, &s, i, args, actionArgTable); err != nil {
return err
}
WriteSelectorLength(&kernelSelectors.data, loff)
WriteSelectorLength(&k.data, loff)
}
return nil
}

func InitKernelSelectorState(selectors []v1alpha1.KProbeSelector, args []v1alpha1.KProbeArg,
actionArgTable *idtable.Table, listReader ValueReader) (*KernelSelectorState, error) {
kernelSelectors := NewKernelSelectorState(listReader)

if err := makeEntrySelector(kernelSelectors, selectors, args, actionArgTable); err != nil {
return nil, err
}
return kernelSelectors, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/selectors/selectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type KernelSelectorData struct {
}

type KernelSelectorState struct {
data KernelSelectorData
data KernelSelectorData // entry probe selector

// valueMaps are used to populate value maps for InMap and NotInMap operators
valueMaps []ValueMap
Expand Down

0 comments on commit 0e7a578

Please sign in to comment.