diff --git a/pkg/generictypes/generictypes.go b/pkg/generictypes/generictypes.go index d2f5a151f7c..0c190db5661 100644 --- a/pkg/generictypes/generictypes.go +++ b/pkg/generictypes/generictypes.go @@ -3,6 +3,8 @@ package generictypes +import "fmt" + const ( GenericIntType = 1 GenericCharBuffer = 2 @@ -57,85 +59,108 @@ const ( GenericInvalidType = -2 ) +var GenericStringToType = map[string]int{ + "string": GenericStringType, + "int": GenericIntType, + "uint64": GenericU64Type, + "unsigned long": GenericU64Type, + "ulong": GenericU64Type, + "uint32": GenericU32Type, + "sint64": GenericS64Type, + "int64": GenericS64Type, + "long": GenericS64Type, + "sint32": GenericS32Type, + "int32": GenericS32Type, + "skb": GenericSkbType, + "sock": GenericSockType, + "size_t": GenericSizeType, + "char_buf": GenericCharBuffer, + "char_iovec": GenericCharIovec, + "filename": GenericFilenameType, + "file": GenericFileType, + "path": GenericPathType, + "fd": GenericFdType, + "cred": GenericCredType, + "const_buf": GenericConstBuffer, + "nop": GenericNopType, + "bpf_attr": GenericBpfAttr, + "perf_event": GenericPerfEvent, + "bpf_map": GenericBpfMap, + "user_namespace": GenericUserNamespace, + "capability": GenericCapability, + "kiocb": GenericKiocb, + "iov_iter": GenericIovIter, + "load_info": GenericLoadModule, + "module": GenericKernelModule, + "syscall64": GenericSyscall64, + "sint16": GenericS16Type, + "int16": GenericS16Type, + "uint16": GenericU16Type, + "sint8": GenericS8Type, + "int8": GenericS8Type, + "uint8": GenericU8Type, + "kernel_cap_t": GenericKernelCap, + "cap_inheritable": GenericCapInheritable, + "cap_permitted": GenericCapPermitted, + "cap_effective": GenericCapEffective, + "linux_binprm": GenericLinuxBinprmType, + "data_loc": GenericDataLoc, +} + +var GenericTypeToStringTable = map[int]string{ + GenericStringType: "string", + GenericIntType: "int", + GenericU64Type: "uint64", + GenericU32Type: "uint32", + GenericS64Type: "int64", + GenericS32Type: "int32", + GenericSkbType: "skb", + GenericSockType: "sock", + GenericSizeType: "size_t", + GenericCharBuffer: "char_buf", + GenericCharIovec: "char_iovec", + GenericFilenameType: "filename", + GenericFileType: "file", + GenericPathType: "path", + GenericFdType: "fd", + GenericCredType: "cred", + GenericConstBuffer: "const_buf", + GenericNopType: "nop", + GenericBpfAttr: "bpf_attr", + GenericPerfEvent: "perf_event", + GenericBpfMap: "bpf_map", + GenericUserNamespace: "user_namespace", + GenericCapability: "capability", + GenericKiocb: "kiocb", + GenericIovIter: "iov_iter", + GenericLoadModule: "load_info", + GenericKernelModule: "module", + GenericSyscall64: "syscall64", + GenericS16Type: "int16", + GenericU16Type: "uint16", + GenericS8Type: "int8", + GenericU8Type: "uint8", + GenericKernelCap: "kernel_cap_t", + GenericCapInheritable: "cap_inheritable", + GenericCapPermitted: "cap_permitted", + GenericCapEffective: "cap_effective", + GenericLinuxBinprmType: "linux_binprm", + GenericDataLoc: "data_loc", + GenericInvalidType: "", +} + func GenericTypeFromString(arg string) int { - switch arg { - case "string": - return GenericStringType - case "int": - return GenericIntType - case "uint64", "unsigned long", "ulong": - return GenericU64Type - case "uint32": - return GenericU32Type - case "sint64", "int64", "long": - return GenericS64Type - case "sint32", "int32": - return GenericS32Type - case "skb": - return GenericSkbType - case "sock": - return GenericSockType - case "size_t": - return GenericSizeType - case "char_buf": - return GenericCharBuffer - case "char_iovec": - return GenericCharIovec - case "filename": - return GenericFilenameType - case "file": - return GenericFileType - case "path": - return GenericPathType - case "fd": - return GenericFdType - case "cred": - return GenericCredType - case "const_buf": - return GenericConstBuffer - case "nop": - return GenericNopType - case "bpf_attr": - return GenericBpfAttr - case "perf_event": - return GenericPerfEvent - case "bpf_map": - return GenericBpfMap - case "user_namespace": - return GenericUserNamespace - case "capability": - return GenericCapability - case "kiocb": - return GenericKiocb - case "iov_iter": - return GenericIovIter - case "load_info": - return GenericLoadModule - case "module": - return GenericKernelModule - case "syscall64": - return GenericSyscall64 - case "sint16", "int16": - return GenericS16Type - case "uint16": - return GenericU16Type - case "sint8", "int8": - return GenericS8Type - case "uint8": - return GenericU8Type - case "kernel_cap_t": - return GenericKernelCap - case "cap_inheritable": - return GenericCapInheritable - case "cap_permitted": - return GenericCapPermitted - case "cap_effective": - return GenericCapEffective - case "linux_binprm": - return GenericLinuxBinprmType - case "data_loc": - return GenericDataLoc - default: - return GenericInvalidType + ty, ok := GenericStringToType[arg] + if !ok { + ty = GenericInvalidType + } + return ty +} + +func GenericTypeToString(ty int) (string, error) { + arg, ok := GenericTypeToStringTable[ty] + if !ok { + return "", fmt.Errorf("invalid argument type") } + return arg, nil } diff --git a/pkg/selectors/kernel.go b/pkg/selectors/kernel.go index 702b6eb9340..4762002d5c5 100644 --- a/pkg/selectors/kernel.go +++ b/pkg/selectors/kernel.go @@ -12,6 +12,7 @@ import ( "github.com/cilium/tetragon/api/v1/tetragon" "github.com/cilium/tetragon/pkg/api/processapi" + gt "github.com/cilium/tetragon/pkg/generictypes" "github.com/cilium/tetragon/pkg/idtable" "github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/v1alpha1" "github.com/cilium/tetragon/pkg/kernels" @@ -153,79 +154,6 @@ var capabilitiesTypeTable = map[string]uint32{ "permitted": capsPermitted, } -const ( - argTypeInt = 1 - argTypeCharBuf = 2 - argTypeCharIovec = 3 - argTypeSizet = 4 - argTypeSkb = 5 - argTypeString = 6 - argTypeSock = 7 - - argTypeS64 = 10 - argTypeU64 = 11 - argTypeS32 = 12 - argTypeU32 = 13 - - argTypePath = 15 - argTypeFile = 16 - argTypeFd = 17 - - argTypeUrl = 18 - argTypeFqdn = 19 - - // mirrors gt.GenericSyscall64 - argTypeSyscall64 = 28 - - argTypeLinuxBinprm = 29 - - argTypeDataLoc = 38 -) - -var argTypeTable = map[string]uint32{ - "int": argTypeInt, - "uint32": argTypeU32, - "int32": argTypeS32, - "uint64": argTypeU64, - "int64": argTypeS64, - "char_buf": argTypeCharBuf, - "char_iovec": argTypeCharIovec, - "sizet": argTypeSizet, - "skb": argTypeSkb, - "string": argTypeString, - "fd": argTypeFd, - "path": argTypePath, - "file": argTypeFile, - "sock": argTypeSock, - "url": argTypeUrl, - "fqdn": argTypeFqdn, - "syscall64": argTypeSyscall64, - "linux_binprm": argTypeLinuxBinprm, - "data_loc": argTypeDataLoc, -} - -var argTypeStringTable = map[uint32]string{ - argTypeInt: "int", - argTypeU32: "uint32", - argTypeS32: "int32", - argTypeU64: "uint64", - argTypeS64: "int64", - argTypeCharBuf: "char_buf", - argTypeCharIovec: "char_iovec", - argTypeSizet: "sizet", - argTypeSkb: "skb", - argTypeString: "string", - argTypeFd: "fd", - argTypeFile: "file", - argTypePath: "path", - argTypeSock: "sock", - argTypeUrl: "url", - argTypeFqdn: "fqdn", - argTypeSyscall64: "syscall64", - argTypeLinuxBinprm: "linux_binprm", - argTypeDataLoc: "data_loc", -} - const ( SelectorOpGT = 1 SelectorOpLT = 2 @@ -413,14 +341,6 @@ func ParseMatchPids(k *KernelSelectorState, matchPids []v1alpha1.PIDSelector) er return nil } -func kprobeArgType(t string) uint32 { - return argTypeTable[t] -} - -func ArgTypeToString(t uint32) string { - return argTypeStringTable[t] -} - func ActionTypeFromString(action string) int32 { act, ok := actionTypeTable[strings.ToLower(action)] if !ok { @@ -434,7 +354,7 @@ func argSelectorType(arg *v1alpha1.ArgSelector, sig []v1alpha1.KProbeArg) (uint3 if arg.Index == s.Index { // TBD: We shouldn't get this far with invalid KProbe args // KProbe args have already been validated - return kprobeArgType(s.Type), nil + return uint32(gt.GenericTypeFromString(s.Type)), nil } } return 0, fmt.Errorf("argFilter for unknown index") @@ -482,14 +402,14 @@ func writeRangeInMap(v string, ty uint32, op uint32, m *ValueMap) error { } for idx := 0; idx < 2; idx++ { switch ty { - case argTypeS64, argTypeInt: + case gt.GenericIntType, gt.GenericS64Type, gt.GenericS32Type, gt.GenericS16Type, gt.GenericS8Type, gt.GenericSyscall64, gt.GenericSizeType: i, err := strconv.ParseInt(rangeStr[idx], 10, 64) if err != nil { return fmt.Errorf("MatchArgs value %s invalid: %w", v, err) } sRangeVal[idx] = i - case argTypeU64: + case gt.GenericU64Type, gt.GenericU32Type, gt.GenericU16Type, gt.GenericU8Type: i, err := strconv.ParseUint(rangeStr[idx], 10, 64) if err != nil { return fmt.Errorf("MatchArgs value %s invalid: %w", v, err) @@ -500,7 +420,7 @@ func writeRangeInMap(v string, ty uint32, op uint32, m *ValueMap) error { } } switch ty { - case argTypeS64, argTypeInt: + case gt.GenericIntType, gt.GenericS64Type, gt.GenericS32Type, gt.GenericS16Type, gt.GenericS8Type, gt.GenericSyscall64, gt.GenericSizeType: if sRangeVal[0] > sRangeVal[1] { sRangeVal[0], sRangeVal[1] = sRangeVal[1], sRangeVal[0] } @@ -510,7 +430,7 @@ func writeRangeInMap(v string, ty uint32, op uint32, m *ValueMap) error { m.Data[valByte] = struct{}{} } - case argTypeU64: + case gt.GenericU64Type, gt.GenericU32Type, gt.GenericU16Type, gt.GenericU8Type: if uRangeVal[0] > uRangeVal[1] { uRangeVal[0], uRangeVal[1] = uRangeVal[1], uRangeVal[0] } @@ -548,9 +468,9 @@ func writeListValuesInMap(k *KernelSelectorState, v string, ty uint32, m *ValueM var val [8]byte switch ty { - case argTypeS64, argTypeInt, argTypeSyscall64: + case gt.GenericIntType, gt.GenericS64Type, gt.GenericS32Type, gt.GenericS16Type, gt.GenericS8Type, gt.GenericSyscall64, gt.GenericSizeType: binary.LittleEndian.PutUint64(val[:], uint64(values[idx])) - case argTypeU64: + case gt.GenericU64Type, gt.GenericU32Type, gt.GenericU16Type, gt.GenericU8Type: binary.LittleEndian.PutUint64(val[:], uint64(values[idx])) default: return fmt.Errorf("Unknown type: %d", ty) @@ -581,13 +501,13 @@ func writeMatchValuesInMap(k *KernelSelectorState, values []string, ty uint32, o continue } switch ty { - case argTypeS64, argTypeInt, argTypeSyscall64: + case gt.GenericIntType, gt.GenericS64Type, gt.GenericS32Type, gt.GenericS16Type, gt.GenericS8Type, gt.GenericSyscall64, gt.GenericSizeType: i, err := strconv.ParseInt(v, 10, 64) if err != nil { return fmt.Errorf("MatchArgs value %s invalid: %w", v, err) } binary.LittleEndian.PutUint64(val[:], uint64(i)) - case argTypeU64: + case gt.GenericU64Type, gt.GenericU32Type, gt.GenericU16Type, gt.GenericU8Type: i, err := strconv.ParseUint(v, 10, 64) if err != nil { return fmt.Errorf("MatchArgs value %s invalid: %w", v, err) @@ -694,33 +614,34 @@ func writeMatchValues(k *KernelSelectorState, values []string, ty, op uint32) er for _, v := range values { base := getBase(v) switch ty { - case argTypeS32, argTypeInt, argTypeSizet: + + case gt.GenericIntType, gt.GenericS32Type, gt.GenericSizeType: i, err := strconv.ParseInt(v, base, 32) if err != nil { return fmt.Errorf("MatchArgs value %s invalid: %w", v, err) } WriteSelectorInt32(&k.data, int32(i)) - case argTypeU32: + case gt.GenericU32Type: i, err := strconv.ParseUint(v, base, 32) if err != nil { return fmt.Errorf("MatchArgs value %s invalid: %w", v, err) } WriteSelectorUint32(&k.data, uint32(i)) - case argTypeS64: + case gt.GenericS64Type, gt.GenericSyscall64: i, err := strconv.ParseInt(v, base, 64) if err != nil { return fmt.Errorf("MatchArgs value %s invalid: %w", v, err) } WriteSelectorInt64(&k.data, int64(i)) - case argTypeU64: + case gt.GenericU64Type: i, err := strconv.ParseUint(v, base, 64) if err != nil { return fmt.Errorf("MatchArgs value %s invalid: %w", v, err) } WriteSelectorUint64(&k.data, uint64(i)) - case argTypeSock, argTypeSkb: + case gt.GenericSockType, gt.GenericSkbType: return fmt.Errorf("MatchArgs type sock and skb do not support operator %s", selectorOpStringTable[op]) - case argTypeCharIovec: + case gt.GenericCharIovec: return fmt.Errorf("MatchArgs values %s unsupported", v) } } @@ -731,7 +652,7 @@ func writeMatchStrings(k *KernelSelectorState, values []string, ty uint32) error maps := k.createStringMaps() for _, v := range values { - trimNulSuffix := ty == argTypeString + trimNulSuffix := ty == gt.GenericStringType value, size, err := ArgStringSelectorValue(v, trimNulSuffix) if err != nil { return fmt.Errorf("MatchArgs value %s invalid: %w", v, err) @@ -795,7 +716,7 @@ func writePostfixStrings(k *KernelSelectorState, values []string, ty uint32) err for _, v := range values { var value []byte var size uint32 - if ty == argTypeCharBuf { + if ty == gt.GenericCharBuffer { value, size = ArgPostfixSelectorValue(v, false) } else { value, size = ArgPostfixSelectorValue(v, true) @@ -853,7 +774,7 @@ func ParseMatchArg(k *KernelSelectorState, arg *v1alpha1.ArgSelector, sig []v1al } case SelectorOpEQ, SelectorOpNEQ: switch ty { - case argTypeFd, argTypeFile, argTypePath, argTypeString, argTypeCharBuf, argTypeLinuxBinprm, argTypeDataLoc: + case gt.GenericFdType, gt.GenericFileType, gt.GenericPathType, gt.GenericStringType, gt.GenericCharBuffer, gt.GenericLinuxBinprmType, gt.GenericDataLoc: err := writeMatchStrings(k, arg.Values, ty) if err != nil { return fmt.Errorf("writeMatchStrings error: %w", err) @@ -875,15 +796,15 @@ func ParseMatchArg(k *KernelSelectorState, arg *v1alpha1.ArgSelector, sig []v1al return fmt.Errorf("writePostfixStrings error: %w", err) } case SelectorOpSport, SelectorOpDport, SelectorOpNotSport, SelectorOpNotDport, SelectorOpProtocol, SelectorOpFamily, SelectorOpState: - if ty != argTypeSock && ty != argTypeSkb { + if ty != gt.GenericSockType && ty != gt.GenericSkbType { return fmt.Errorf("sock/skb operators specified for non-sock/skb type") } - err := writeMatchRangesInMap(k, arg.Values, argTypeU64, op) // force type for ports and protocols as ty is sock/skb + err := writeMatchRangesInMap(k, arg.Values, gt.GenericU64Type, op) // force type for ports and protocols as ty is sock/skb if err != nil { return fmt.Errorf("writeMatchRangesInMap error: %w", err) } case SelectorOpSaddr, SelectorOpDaddr, SelectorOpNotSaddr, SelectorOpNotDaddr: - if ty != argTypeSock && ty != argTypeSkb { + if ty != gt.GenericSockType && ty != gt.GenericSkbType { return fmt.Errorf("sock/skb operators specified for non-sock/skb type") } err := writeMatchAddrsInMap(k, arg.Values) @@ -892,7 +813,7 @@ func ParseMatchArg(k *KernelSelectorState, arg *v1alpha1.ArgSelector, sig []v1al } case SelectorOpSportPriv, SelectorOpDportPriv, SelectorOpNotSportPriv, SelectorOpNotDportPriv: // These selectors do not take any values, but we do check that they are only used for sock/skb. - if ty != argTypeSock && ty != argTypeSkb { + if ty != gt.GenericSockType && ty != gt.GenericSkbType { return fmt.Errorf("sock/skb operators specified for non-sock/skb type") } default: diff --git a/pkg/selectors/kernel_test.go b/pkg/selectors/kernel_test.go index 05824be58c9..73edf9182a4 100644 --- a/pkg/selectors/kernel_test.go +++ b/pkg/selectors/kernel_test.go @@ -12,6 +12,7 @@ import ( "strings" "testing" + gt "github.com/cilium/tetragon/pkg/generictypes" "github.com/cilium/tetragon/pkg/idtable" "github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/v1alpha1" "github.com/cilium/tetragon/pkg/kernels" @@ -556,34 +557,34 @@ func TestMultipleSelectorsExample(t *testing.T) { } // value absolute offset explanation - expU32Push(2) // off: 0 number of selectors - expU32Push(8) // off: 4 relative ofset of 1st selector (4 + 8 = 12) - expU32Push(100) // off: 8 relative ofset of 2nd selector (8 + 124 = 132) - expU32Push(96) // off: 12 selector1: length (76 + 12 = 96) - expU32Push(24) // off: 16 selector1: MatchPIDs: len - expU32Push(SelectorOpNotIn) // off: 20 selector1: MatchPIDs[0]: op - expU32Push(0) // off: 24 selector1: MatchPIDs[0]: flags - expU32Push(2) // off: 28 selector1: MatchPIDs[0]: number of values - expU32Push(33) // off: 32 selector1: MatchPIDs[0]: val1 - expU32Push(44) // off: 36 selector1: MatchPIDs[0]: val2 - expU32Push(4) // off: 40 selector1: MatchNamespaces: len - expU32Push(4) // off: 44 selector1: MatchCapabilities: len - expU32Push(4) // off: 48 selector1: MatchNamespaceChanges: len - expU32Push(4) // off: 52 selector1: MatchCapabilityChanges: len - expU32Push(48) // off: 80 selector1: matchArgs: len - expU32Push(24) // off: 84 selector1: matchArgs[0]: offset - expU32Push(0) // off: 88 selector1: matchArgs[1]: offset - expU32Push(0) // off: 92 selector1: matchArgs[2]: offset - expU32Push(0) // off: 96 selector1: matchArgs[3]: offset - expU32Push(0) // off: 100 selector1: matchArgs[4]: offset - expU32Push(1) // off: 104 selector1: matchArgs: arg0: index - expU32Push(SelectorOpEQ) // off: 108 selector1: matchArgs: arg0: operator - expU32Push(16) // off: 112 selector1: matchArgs: arg0: len of vals - expU32Push(argTypeInt) // off: 116 selector1: matchArgs: arg0: type - expU32Push(10) // off: 120 selector1: matchArgs: arg0: val0: 10 - expU32Push(20) // off: 124 selector1: matchArgs: arg0: val1: 20 - expU32Push(4) // off: 128 selector1: matchActions: length - expU32Push(96) // off: 132 selector2: length + expU32Push(2) // off: 0 number of selectors + expU32Push(8) // off: 4 relative ofset of 1st selector (4 + 8 = 12) + expU32Push(100) // off: 8 relative ofset of 2nd selector (8 + 124 = 132) + expU32Push(96) // off: 12 selector1: length (76 + 12 = 96) + expU32Push(24) // off: 16 selector1: MatchPIDs: len + expU32Push(SelectorOpNotIn) // off: 20 selector1: MatchPIDs[0]: op + expU32Push(0) // off: 24 selector1: MatchPIDs[0]: flags + expU32Push(2) // off: 28 selector1: MatchPIDs[0]: number of values + expU32Push(33) // off: 32 selector1: MatchPIDs[0]: val1 + expU32Push(44) // off: 36 selector1: MatchPIDs[0]: val2 + expU32Push(4) // off: 40 selector1: MatchNamespaces: len + expU32Push(4) // off: 44 selector1: MatchCapabilities: len + expU32Push(4) // off: 48 selector1: MatchNamespaceChanges: len + expU32Push(4) // off: 52 selector1: MatchCapabilityChanges: len + expU32Push(48) // off: 80 selector1: matchArgs: len + expU32Push(24) // off: 84 selector1: matchArgs[0]: offset + expU32Push(0) // off: 88 selector1: matchArgs[1]: offset + expU32Push(0) // off: 92 selector1: matchArgs[2]: offset + expU32Push(0) // off: 96 selector1: matchArgs[3]: offset + expU32Push(0) // off: 100 selector1: matchArgs[4]: offset + expU32Push(1) // off: 104 selector1: matchArgs: arg0: index + expU32Push(SelectorOpEQ) // off: 108 selector1: matchArgs: arg0: operator + expU32Push(16) // off: 112 selector1: matchArgs: arg0: len of vals + expU32Push(gt.GenericIntType) // off: 116 selector1: matchArgs: arg0: type + expU32Push(10) // off: 120 selector1: matchArgs: arg0: val0: 10 + expU32Push(20) // off: 124 selector1: matchArgs: arg0: val1: 20 + expU32Push(4) // off: 128 selector1: matchActions: length + expU32Push(96) // off: 132 selector2: length // ... everything else should be the same as selector1 ... if bytes.Equal(expected[:expectedLen], b[:expectedLen]) == false { @@ -892,22 +893,22 @@ func TestReturnSelectorArgInt(t *testing.T) { expectedLen += 4 } - expU32Push(1) // off: 0 number of selectors - expU32Push(4) // off: 4 relative ofset of selector (4 + 4 = 8) - expU32Push(56) // off: 8 selector: length - expU32Push(48) // off: 12 selector: matchReturnArgs length - expU32Push(24) // off: 16 selector: matchReturnArgs arg offset[0] - expU32Push(0) // off: 20 selector: matchReturnArgs arg offset[1] - expU32Push(0) // off: 24 selector: matchReturnArgs arg offset[2] - expU32Push(0) // off: 28 selector: matchReturnArgs arg offset[3] - expU32Push(0) // off: 32 selector: matchReturnArgs arg offset[4] - expU32Push(0) // off: 36 selector: matchReturnArgs[0].Index - expU32Push(SelectorOpEQ) // off: 40 selector: matchReturnArgs[0].Operator - expU32Push(16) // off: 44 selector: length (4 + 3*4) = 16 - expU32Push(argTypeInt) // off: 48 selector: matchReturnArgs[0].Type - expU32Push(10) // off: 52 selector: matchReturnArgs[0].Values[0] - expU32Push(20) // off: 56 selector: matchReturnArgs[0].Values[1] - expU32Push(4) // off: 60 selector: MatchActions length + expU32Push(1) // off: 0 number of selectors + expU32Push(4) // off: 4 relative ofset of selector (4 + 4 = 8) + expU32Push(56) // off: 8 selector: length + expU32Push(48) // off: 12 selector: matchReturnArgs length + expU32Push(24) // off: 16 selector: matchReturnArgs arg offset[0] + expU32Push(0) // off: 20 selector: matchReturnArgs arg offset[1] + expU32Push(0) // off: 24 selector: matchReturnArgs arg offset[2] + expU32Push(0) // off: 28 selector: matchReturnArgs arg offset[3] + expU32Push(0) // off: 32 selector: matchReturnArgs arg offset[4] + expU32Push(0) // off: 36 selector: matchReturnArgs[0].Index + expU32Push(SelectorOpEQ) // off: 40 selector: matchReturnArgs[0].Operator + expU32Push(16) // off: 44 selector: length (4 + 3*4) = 16 + expU32Push(gt.GenericIntType) // off: 48 selector: matchReturnArgs[0].Type + expU32Push(10) // off: 52 selector: matchReturnArgs[0].Values[0] + expU32Push(20) // off: 56 selector: matchReturnArgs[0].Values[1] + expU32Push(4) // off: 60 selector: MatchActions length if bytes.Equal(expected[:expectedLen], b[:expectedLen]) == false { t.Errorf("\ngot: %v\nexp: %v\n", b[:expectedLen], expected[:expectedLen]) diff --git a/pkg/sensors/tracing/generictracepoint.go b/pkg/sensors/tracing/generictracepoint.go index df0d742da8a..1c4f3afdae5 100644 --- a/pkg/sensors/tracing/generictracepoint.go +++ b/pkg/sensors/tracing/generictracepoint.go @@ -505,7 +505,10 @@ func (tp *genericTracepoint) InitKernelSelectors(lists []v1alpha1.ListSpec) erro if err != nil { return fmt.Errorf("output argument %v unsupported: %w", tpArg, err) } - selType := selectors.ArgTypeToString(uint32(ty)) + selType, err := gt.GenericTypeToString(ty) + if err != nil { + return fmt.Errorf("output argument %v type not found: %w", tpArg, err) + } // NB: this a selector argument, meant to be passed to InitKernelSelectors. // The only fields needed for the latter are Index and Type