src: use constant range expression for interval+concatenation sets
Pablo Neira Ayuso
maintainerPATCH 1/1 src: use constant range expression for interval+concatenation sets
Expand 347039f64509 ("src: add symbol range expression to further compact intervals") to use constant range expression for elements with concatenation of intervals.
Ruleset with 100k elements of this type:
table inet x {
set y {
typeof ip saddr . tcp dport
flags interval
elements = {
0.1.2.0-0.1.2.240 . 0-1,
...
}
}}
This reduces memory consumption by 35.23%.
Before: 123.80 Mbytes
After: 80.19 Mbytes
This patch keeps the workaround 2fbade3cd990 ("netlink: bogus concatenated set ranges with netlink message overrun") in place.
Signed-off-by Pablo Neira Ayuso <[email protected]>
---
Follow up to continue in this direction, to further reduce memory consumption.
src/evaluate.c | 1 - src/netlink.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
src/evaluate.c +0 -1
@@ -2368,7 +2368,6 @@ static int expr_evaluate_symbol_range(struct eval_ctx *ctx, struct expr **exprp)/* concatenation and maps need more work to use constant_range_expr. */ if (ctx->set && !set_is_map (ctx->set->flags) && -set_is_non_concat_range (ctx->set) && left->etype ==EXPR_VALUE && right->etype ==EXPR_VALUE ) { constant_range = constant_range_expr_alloc(&expr->location,
src/netlink.c +11 -0
@@ -285,6 +285,17 @@ static int __netlink_gen_concat_key(uint32_t flags, const struct expr *i,byteorder_switch_expr_value (value, expr); i = expr; +break ; +case EXPR_RANGE_VALUE : +if (flags &EXPR_F_INTERVAL_END ) +mpz_init_set (value, i->range.high); +else +mpz_init_set (value, i->range.low); + +if (expr_basetype (i)->type ==TYPE_INTEGER && + i->byteorder ==BYTEORDER_HOST_ENDIAN ) +byteorder_switch_expr_value (value, i); +break ;case EXPR_PREFIX :if (flags &EXPR_F_INTERVAL_END ) {
Signature · 1 line
2.30.2