Skip to content

Commit

Permalink
add matchBinary NotPrefix operator
Browse files Browse the repository at this point in the history
Add it in BPF, in the CRD validation and in the selector parser.

Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com>
  • Loading branch information
mtardy committed Nov 3, 2023
1 parent 5181329 commit e2cf3d1
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions bpf/process/types/basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,7 @@ static inline __attribute__((always_inline)) int match_binaries(__u32 selidx)
match = do_filter_char_buf_equal(selector_options->mapidx, execve->binary_path.path, execve->binary_path.path_length);
break;
case op_filter_str_prefix:
case op_filter_str_notprefix:
match = match_binaries_prefix(selidx, execve);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ spec:
- In
- NotIn
- Prefix
- NotPrefix
type: string
values:
description: Value to compare the argument against.
Expand Down Expand Up @@ -899,6 +900,7 @@ spec:
- In
- NotIn
- Prefix
- NotPrefix
type: string
values:
description: Value to compare the argument against.
Expand Down Expand Up @@ -1273,6 +1275,7 @@ spec:
- In
- NotIn
- Prefix
- NotPrefix
type: string
values:
description: Value to compare the argument against.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ spec:
- In
- NotIn
- Prefix
- NotPrefix
type: string
values:
description: Value to compare the argument against.
Expand Down Expand Up @@ -899,6 +900,7 @@ spec:
- In
- NotIn
- Prefix
- NotPrefix
type: string
values:
description: Value to compare the argument against.
Expand Down Expand Up @@ -1273,6 +1275,7 @@ spec:
- In
- NotIn
- Prefix
- NotPrefix
type: string
values:
description: Value to compare the argument against.
Expand Down
2 changes: 1 addition & 1 deletion pkg/k8s/apis/cilium.io/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type KProbeArg struct {
}

type BinarySelector struct {
// +kubebuilder:validation:Enum=In;NotIn;Prefix
// +kubebuilder:validation:Enum=In;NotIn;Prefix;NotPrefix
// Filter operation.
Operator string `json:"operator"`
// Value to compare the argument against.
Expand Down
4 changes: 2 additions & 2 deletions pkg/selectors/kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ func ParseMatchBinary(k *KernelSelectorState, b *v1alpha1.BinarySelector, selIdx
sel.Op = op

switch op {
case SelectorOpPrefix:
case SelectorOpPrefix, SelectorOpNotPrefix:
writePrefixBinaries(k, b.Values)
case SelectorOpIn, SelectorOpNotIn:
maps := NewStringMaps()
Expand All @@ -1194,7 +1194,7 @@ func ParseMatchBinary(k *KernelSelectorState, b *v1alpha1.BinarySelector, selIdx
mapDetails := k.insertStringMaps(maps)
copy(sel.Mapidx[:], mapDetails[:])
default:
return fmt.Errorf("matchBinary error: Only \"In\", \"NotIn\" and \"Prefix\" operators are supported")
return fmt.Errorf("matchBinary error: Only \"In\", \"NotIn\", \"Prefix\" and \"NotPrefix\" operators are supported")
}

k.AddMatchBinaries(selIdx, sel)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e2cf3d1

Please sign in to comment.