From 16346c99a674d95970cfc59b0aa5d00e91cc4e0f Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Tue, 16 May 2023 18:05:46 +0200 Subject: filter: refactoring filter Attempt to simplify the filter build: - storing all the bpf_args in a common array and saving the index of each entry in filter_input - added new flag to filter_add_arg for append an argument to an entry - split large loop in filter_build in multiple functions - adjust and refactor tests/units/test_filter The tests in test_filter_build.c still need to be fixed --- cooker/filter.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'cooker/filter.h') diff --git a/cooker/filter.h b/cooker/filter.h index 7059a7c..0ec1204 100644 --- a/cooker/filter.h +++ b/cooker/filter.h @@ -44,6 +44,10 @@ #define MAX_JUMPS 128 #define EMPTY -1 +#define N_SYSCALL 512 +#define MAX_ENTRIES_SYSCALL 16 +#define MAX_ENTRIES N_SYSCALL * MAX_ENTRIES_SYSCALL + enum bpf_type { BPF_U32, BPF_U64 }; union bpf_value { @@ -60,12 +64,13 @@ struct bpf_arg { union bpf_value op2; }; +struct bpf_entry { + struct bpf_arg args[6]; +}; + void filter_notify(long nr); void filter_needs_deref(void); -void filter_add_arg(int index, struct bpf_arg arg); +void filter_add_arg(int index, struct bpf_arg arg, bool append); void filter_write(const char *path); -void create_lookup_nodes(int jumps[], unsigned int n); -unsigned int left_child(unsigned int parent_index); -unsigned int right_child(unsigned int parent_index); #endif -- cgit v1.2.3