This allows to identify the set elements that reside in the kernel. Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> --- include/expression.h | 2 ++ src/netlink.c | 1 + src/segtree.c | 10 ++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/expression.h b/include/expression.h index 742fcdd7bf75..09393f9c2372 100644 --- a/include/expression.h +++ b/include/expression.h @@ -190,6 +190,7 @@ const struct expr_ops *expr_ops_by_type(enum expr_types etype); * @EXPR_F_INTERVAL_END: set member ends an open interval * @EXPR_F_BOOLEAN: expression is boolean (set by relational expr on LHS) * @EXPR_F_INTERVAL: expression describes a interval + * @EXPR_F_KERNEL: expression resides in the kernel */ enum expr_flags { EXPR_F_CONSTANT = 0x1, @@ -198,6 +199,7 @@ enum expr_flags { EXPR_F_INTERVAL_END = 0x8, EXPR_F_BOOLEAN = 0x10, EXPR_F_INTERVAL = 0x20, + EXPR_F_KERNEL = 0x40, }; #include <payload.h> diff --git a/src/netlink.c b/src/netlink.c index ac73e96f9d24..642c28773b98 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -1273,6 +1273,7 @@ key_end: } expr = set_elem_expr_alloc(&netlink_location, key); + expr->flags |= EXPR_F_KERNEL; if (nftnl_set_elem_is_set(nlse, NFTNL_SET_ELEM_TIMEOUT)) expr->timeout = nftnl_set_elem_get_u64(nlse, NFTNL_SET_ELEM_TIMEOUT); diff --git a/src/segtree.c b/src/segtree.c index a61ea3d2854a..832bc7dd1402 100644 --- a/src/segtree.c +++ b/src/segtree.c @@ -1060,9 +1060,10 @@ void interval_map_decompose(struct expr *set) mpz_and(p, expr_value(low)->value, range); - if (!mpz_cmp_ui(range, 0)) + if (!mpz_cmp_ui(range, 0)) { + low->flags |= EXPR_F_KERNEL; compound_expr_add(set, expr_get(low)); - else if ((!range_is_prefix(range) || + } else if ((!range_is_prefix(range) || !(i->dtype->flags & DTYPE_F_PREFIX)) || mpz_cmp_ui(p, 0)) { struct expr *tmp; @@ -1087,6 +1088,7 @@ void interval_map_decompose(struct expr *set) } else { interval_expr_copy(tmp, low); } + tmp->flags |= EXPR_F_KERNEL; compound_expr_add(set, tmp); } else { @@ -1109,6 +1111,7 @@ void interval_map_decompose(struct expr *set) } else { interval_expr_copy(prefix, low); } + prefix->flags |= EXPR_F_KERNEL; compound_expr_add(set, prefix); } @@ -1134,6 +1137,7 @@ void interval_map_decompose(struct expr *set) i = range_expr_alloc(&low->location, expr_clone(expr_value(low)), i); i = set_elem_expr_alloc(&low->location, i); + if (low->etype == EXPR_MAPPING) { i = mapping_expr_alloc(&i->location, i, expr_clone(low->right)); @@ -1141,6 +1145,8 @@ void interval_map_decompose(struct expr *set) } else { interval_expr_copy(i, low); } + i->flags |= EXPR_F_KERNEL; + expr_free(low); } -- 2.30.2