diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2025-02-13 18:56:46 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2025-02-21 23:23:10 +0100 |
commit | 347039f64509e77ad5f6ef52ae70950c91886f8e (patch) | |
tree | e1d9857388672f1a08dccf6ab310c2a2b1ad8288 /include | |
parent | b15854ef81b4c22e4660d3876384f375554887b2 (diff) |
src: add symbol range expression to further compact intervals
Update parser to use a new symbol range expression with smaller memory
footprint than range expression + two symbol expressions.
The evaluation step translates this into EXPR_RANGE_VALUE for interval
sets.
Note that maps or concatenations still use the less compact range
expressions representation, those require more work to use this new
symbol range expression. The parser also uses the classic range
expression if variables are used.
Testing with a 100k intervals, worst case scenario: no prefix or
singleton elements. This shows a reduction from 49.58 Mbytes to
35.47 Mbytes (-29.56% memory footprint for this case).
This follow up work to previous commits:
91dc281a82ea ("src: rework singleton interval transformation to reduce memory consumption")
c9ee9032b0ee ("src: add EXPR_RANGE_VALUE expression and use it")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/expression.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/include/expression.h b/include/expression.h index f2b45250..84727486 100644 --- a/include/expression.h +++ b/include/expression.h @@ -49,6 +49,7 @@ * @EXPR_SET_ELEM_CATCHALL catchall element expression * @EXPR_FLAGCMP flagcmp expression * @EXPR_RANGE_VALUE constant range expression + * @EXPR_RANGE_SYMBOL unparse symbol range expression */ enum expr_types { EXPR_INVALID, @@ -82,6 +83,7 @@ enum expr_types { EXPR_SET_ELEM_CATCHALL, EXPR_FLAGCMP, EXPR_RANGE_VALUE, + EXPR_RANGE_SYMBOL, EXPR_MAX = EXPR_FLAGCMP }; @@ -261,9 +263,12 @@ struct expr { union { struct { - /* EXPR_SYMBOL */ + /* EXPR_SYMBOL, EXPR_RANGE_SYMBOL */ const struct scope *scope; - const char *identifier; + union { + const char *identifier; + const char *identifier_range[2]; + }; enum symbol_types symtype; }; struct { @@ -486,6 +491,10 @@ extern struct expr *constant_range_expr_alloc(const struct location *loc, unsigned int len, mpz_t low, mpz_t high); +struct expr *symbol_range_expr_alloc(const struct location *loc, + enum symbol_types type, const struct scope *scope, + const char *identifier_low, const char *identifier_high); + extern struct expr *flag_expr_alloc(const struct location *loc, const struct datatype *dtype, enum byteorder byteorder, |