diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2023-06-09 18:52:16 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2023-06-09 18:52:38 +0200 |
commit | d4757b140364cd277f7f7f373475eb427003cb42 (patch) | |
tree | 159e5da9d3c9f151c99c25ec0e9bffc2222de970 /cooker/emit.c | |
parent | 65b5eacaa500e702b982c6848e1ffc18094bc9a9 (diff) | |
download | seitan-d4757b140364cd277f7f7f373475eb427003cb42.tar seitan-d4757b140364cd277f7f7f373475eb427003cb42.tar.gz seitan-d4757b140364cd277f7f7f373475eb427003cb42.tar.bz2 seitan-d4757b140364cd277f7f7f373475eb427003cb42.tar.lz seitan-d4757b140364cd277f7f7f373475eb427003cb42.tar.xz seitan-d4757b140364cd277f7f7f373475eb427003cb42.tar.zst seitan-d4757b140364cd277f7f7f373475eb427003cb42.zip |
cooker: Pass arguments to filter
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'cooker/emit.c')
-rw-r--r-- | cooker/emit.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cooker/emit.c b/cooker/emit.c index 41b64a6..57533a1 100644 --- a/cooker/emit.c +++ b/cooker/emit.c @@ -11,6 +11,7 @@ #include "cooker.h" #include "gluten.h" +#include "filter.h" #include "util.h" #include "emit.h" @@ -536,6 +537,32 @@ static void gluten_link(struct gluten_ctx *g, enum jump_type type, } } +void emit_bpf_arg(int index, enum type type, union value v, union value mask, + enum op_cmp_type cmp) +{ + struct bpf_arg bpf; + + /* gluten uses the comparison to skip to the next match, the BPF filter + * uses it to notify instead. + */ + if (mask.v_num) + bpf.cmp = (cmp == CMP_EQ) ? AND_NE : AND_EQ; + else + bpf.cmp = (cmp == CMP_EQ) ? NE : EQ; + + if (TYPE_IS_64BIT(type)) { + bpf.value.v64 = v.v_num; + bpf.op2.v64 = mask.v_num; + bpf.type = BPF_U64; + } else { + bpf.value.v32 = v.v_num; + bpf.op2.v32 = mask.v_num; + bpf.type = BPF_U32; + } + + filter_add_arg(index, bpf); +} + void link_block(struct gluten_ctx *g) { debug(" Linking block..."); |