Linux Netfilter development
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft 2/3] Revert "segtree: basic support for binary operations in concatenated set ranges"
Date: Mon, 24 Aug 2026 23:29:08 +0200	[thread overview]
Message-ID: <20260824212909.68597-2-pablo@netfilter.org> (raw)
In-Reply-To: <20260824212909.68597-1-pablo@netfilter.org>

Handling binary expression from the interval set postprocessing step is
tricky, it is easier to handle set element key as value at that stage.
Revert 1de3568ef07f ("segtree: basic support for binary operations in
concatenated set ranges"), this only works for concatenated set ranges.

A follow up patch postpones the conversion from value to symbol for
TYPE_BITMASK expressions after the interval set postprocessing.

Fixes: 1de3568ef07f ("segtree: basic support for binary operations in concatenated set ranges")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/segtree.c | 29 +++--------------------------
 1 file changed, 3 insertions(+), 26 deletions(-)

diff --git a/src/segtree.c b/src/segtree.c
index 4f758e6c9f99..5e178fa3c48d 100644
--- a/src/segtree.c
+++ b/src/segtree.c
@@ -369,29 +369,6 @@ static int range_mask_len(const mpz_t start, const mpz_t end, unsigned int len)
 	return ret;
 }
 
-static int concat_expr_cmp(const struct expr *r1, const struct expr *r2)
-{
-	int ret;
-
-	assert(r1->etype == r2->etype);
-
-	switch (r1->etype) {
-	case EXPR_BINOP:
-		assert(r1->op == r2->op);
-		ret = 0;
-		ret = mpz_cmp(r1->left->value, r2->left->value);
-		ret |= mpz_cmp(r1->right->value, r2->right->value);
-		break;
-	case EXPR_VALUE:
-		ret = mpz_cmp(r1->value, r2->value);
-		break;
-	default:
-		BUG("unexpected expression %s", expr_name(r1->key));
-	}
-
-	return ret;
-}
-
 /* Given a set with two elements (start and end), transform them into a
  * concatenation of ranges. That is, from a list of start expressions and a list
  * of end expressions, form a list of start - end expressions.
@@ -431,13 +408,13 @@ void concat_range_aggregate(struct expr *set)
 			r2_next = r2->list.next;
 			free_r1 = 0;
 
-			if (!concat_expr_cmp(r1, r2)) {
+			assert(r1->etype == EXPR_VALUE && r1->etype == EXPR_VALUE);
+
+			if (!mpz_cmp(r1->value, r2->value)) {
 				free_r1 = 1;
 				goto next;
 			}
 
-			assert(r1->etype == EXPR_VALUE && r1->etype == EXPR_VALUE);
-
 			if (expr_basetype(r1)->type == TYPE_STRING &&
 			    expr_basetype(r2)->type == TYPE_STRING) {
 				string_type = true;
-- 
2.47.3


  reply	other threads:[~2026-08-24 21:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24 21:29 [PATCH nft 1/3] segtree: assert on value expressions Pablo Neira Ayuso
2026-08-24 21:29 ` Pablo Neira Ayuso [this message]
2026-08-24 21:29 ` [PATCH nft 3/3] segtree: postpone bitmask to symbol conversion for interval sets Pablo Neira Ayuso
2026-08-27  9:03 ` [PATCH nft 1/3] segtree: assert on value expressions Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260824212909.68597-2-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox