From ea0bdcf104654ec45d4a32055a4fb2573613ea16 Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Fri, 19 May 2023 16:53:53 +0200 Subject: filter: adjust filter build Add filter_flush_args() to flush the arguments when finish to add the syscall arguments. Fixed test compilation after refactoring. --- cooker/filter.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'cooker/filter.c') diff --git a/cooker/filter.c b/cooker/filter.c index 9ca696b..ef76835 100644 --- a/cooker/filter.c +++ b/cooker/filter.c @@ -148,26 +148,31 @@ void filter_notify(long nr) { * filter_add_arg(): Add a new argument to the current syscall * @index: position of the argument * @arg: the argument to add - * @append: if it is the first element add to the syscall entry */ -void filter_add_arg(int index, struct bpf_arg arg, bool append) +void filter_add_arg(int index, struct bpf_arg arg) { struct filter_call_input *call = filter_input + current_nr; + struct bpf_entry *entry = &entries[index_entries]; - fprintf(stderr, "count=%d cmp=%d value=%X\n", call->count, arg.cmp, - arg.value.v32); /* If it reaches the maximum number of entries per syscall, then we simply * notify for all the arguments and ignore the other arguments. */ if (call->count >= MAX_ENTRIES_SYSCALL) { - set_no_args(&entries[call->entries[0]]); + call->ignore_args = true; return; } if(call->ignore_args) return; - if (!append) - call->entries[call->count++] = index_entries; - memcpy(&entries[index_entries++].args[index], &arg, sizeof(arg)); + + call->entries[call->count] = index_entries; + memcpy(&entry->args[index], &arg, sizeof(arg)); +} + +void filter_flush_args() +{ + struct filter_call_input *call = filter_input + current_nr; + call->count++; + index_entries++; } void filter_needs_deref(void) -- cgit v1.2.3