]> git.ipfire.org Git - thirdparty/nftables.git/commit
src: add EXPR_RANGE_VALUE expression and use it
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 3 Jan 2025 16:40:54 +0000 (17:40 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 10 Jan 2025 10:21:02 +0000 (11:21 +0100)
commitc9ee9032b0ee9e802f73dda90f5c84357aff8148
treecdc07e291d03ebacbe4a3dff9d5d2bcfca3f96ec
parentda0bac050c8b2588242727f9915a1ea8bc48ceb2
src: add EXPR_RANGE_VALUE expression and use it

set element with range takes 4 instances of struct expr:

  EXPR_SET_ELEM -> EXPR_RANGE -> (2) EXPR_VALUE

where EXPR_RANGE represents two references to struct expr with constant
value.

This new EXPR_RANGE_VALUE trims it down to two expressions:

  EXPR_SET_ELEM -> EXPR_RANGE_VALUE

with two direct low and high values that represent the range:

  struct {
      mpz_t low;
      mpz_t high;
  };

this two new direct values in struct expr do not modify its size.

setelem_expr_to_range() translates EXPR_RANGE to EXPR_RANGE_VALUE, this
conversion happens at a later stage.

constant_range_expr_print() translates this structure to constant values
to reuse the existing datatype_print() which relies in singleton values.

The automerge routine has been updated to use EXPR_RANGE_VALUE.

This requires a follow up patch to rework the conversion from range
expression to singleton element to provide a noticeable memory
consumption reduction.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/expression.h
src/expression.c
src/intervals.c
src/mergesort.c