From 1e78526693d22abe24c98291a782998573f6b01d Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Wed, 17 May 2023 13:20:13 +0200 Subject: Minor fixes for the filter and the eater Add: - ignore_args field for the filter. - use MAX_FILTER to define the filter size in the eater --- cooker/filter.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'cooker/filter.c') diff --git a/cooker/filter.c b/cooker/filter.c index dcd04bf..9ca696b 100644 --- a/cooker/filter.c +++ b/cooker/filter.c @@ -25,6 +25,7 @@ static unsigned int index_entries = 0; * @entries: Index for the arguments for every entry */ struct filter_call_input { + bool ignore_args; bool notify; unsigned int count; int entries[MAX_ENTRIES_SYSCALL]; @@ -59,6 +60,8 @@ static bool has_args(long nr) if (call-> count < 1) return false; + if(call-> ignore_args) + return false; /* Check if the first entry has some arguments */ return need_check_arg(&entries[call->entries[0]]); @@ -160,6 +163,8 @@ void filter_add_arg(int index, struct bpf_arg arg, bool append) set_no_args(&entries[call->entries[0]]); return; } + if(call->ignore_args) + return; if (!append) call->entries[call->count++] = index_entries; memcpy(&entries[index_entries++].args[index], &arg, sizeof(arg)); @@ -169,8 +174,8 @@ void filter_needs_deref(void) { struct filter_call_input *call = filter_input + current_nr; - call->count = MAX_ENTRIES_SYSCALL; - set_no_args(&entries[call->entries[0]]); + call->ignore_args = true; + call->count = 0; } static int table[N_SYSCALL]; @@ -564,7 +569,6 @@ void filter_write(const char *path) n = create_table_syscall(); n = filter_build(filter, n); - fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, S_IRUSR | S_IWUSR); write(fd, filter, sizeof(struct sock_filter) * n); -- cgit v1.2.3