From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft 1/7] src: normalize set element with EXPR_MAPPING
Date: Tue, 24 Nov 2026 19:05:00 +0100 [thread overview]
Message-ID: <awXRzNwL7JIR8InP@orbyte.nwl.cc> (raw)
In-Reply-To: <20250905153627.1315405-2-pablo@netfilter.org>
Hi Pablo,
On Fri, Sep 05, 2025 at 05:36:21PM +0200, Pablo Neira Ayuso wrote:
> EXPR_SET_ELEM provides the timeout, expiration, comment and list of
> statements, this is a shim expression.
>
> Currently, expr_set(x)->expressions can have either:
>
> - EXPR_SET_ELEM
>
> EXPR_SET_ELEM -> EXPR_VALUE
>
> - EXPR_MAPPING, which contains EXPR_SET_ELEM in the lhs.
>
> EXPR_SET_ELEM -> EXPR_VALUE
> /
> EXPR_MAPPING |
> \
> EXPR_VALUE
>
> This patch normalizes the expression for mappings:
>
> EXPR_SET_ELEM -> EXPR_VALUE
> /
> EXPR_SET_ELEM -> EXPR_MAPPING |
> \
> EXPR_VALUE
>
> The previous representation makes it natural for expr_print() to print the
> timeout, expiration, statements and comments.
>
> 1.1.1.1 counter packets 1 bytes 564 : 0x00000001,
>
> This patch adds an exception for expr_mapping_print() to stick to the
> existing representation.
>
> The JSON representation provides this set element information too in the
> lhs, which is does not really belong there because it is exposing
> transparently the syntax tree for set elements. A workaround to retain
> compatibility is included in this patch.
>
> The end goal is to replace EXPR_SET_ELEM by a smaller shim object, to
> further reduce memory consumption in set elements in userspace.
>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Git bisect identified this commit as the culprit of a regression I
noticed: Restoring the following ruleset exposes it:
| table inet t {
| map m6 {
| typeof numgen inc mod 2000 : ct zone
| elements = { 1 : 1 }
| }
| }
When listing, the element shows as '16777216 : 1', whereas:
| % bc <<< "obase = 16; 16777216"
| 1000000
The key seems to be in wrong byte order. It is not just a display issue:
nft_zones_many.sh kselftest is failing due to it which performs lookups
in such a set.
Can you quickly point at where we lost some byteorder conversion (or got
an extra one?) by your patch? I guess it missed to adjust a check. I'll
start digging through the code meanwhile, but tracing expression
manipulation in eval phase is tedious. :(
Thanks, Phil
next prev parent reply other threads:[~2026-11-24 18:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-05 15:36 [PATCH nft 0/7] prepare for EXPR_SET_ELEM removal Pablo Neira Ayuso
2025-09-05 15:36 ` [PATCH nft 1/7] src: normalize set element with EXPR_MAPPING Pablo Neira Ayuso
2025-09-07 14:10 ` Florian Westphal
2025-09-08 7:59 ` Pablo Neira Ayuso
2026-11-24 18:05 ` Phil Sutter [this message]
2026-11-25 0:18 ` Pablo Neira Ayuso
2026-11-25 10:49 ` Phil Sutter
2025-09-05 15:36 ` [PATCH nft 2/7] src: allocate EXPR_SET_ELEM for EXPR_SET in embedded set declaration in sets Pablo Neira Ayuso
2025-09-05 15:36 ` [PATCH nft 3/7] src: assert on EXPR_SET only contains EXPR_SET_ELEM in the expressions list Pablo Neira Ayuso
2025-09-05 15:36 ` [PATCH nft 4/7] evaluate: simplify sets as set elems evaluation Pablo Neira Ayuso
2025-09-05 15:36 ` [PATCH nft 5/7] evaluate: clean up expr_evaluate_set() Pablo Neira Ayuso
2025-09-05 15:36 ` [PATCH nft 6/7] segtree: rename set_elem_add() to set_elem_expr_add() Pablo Neira Ayuso
2025-09-05 15:36 ` [PATCH nft 7/7] src: move flags from EXPR_SET_ELEM to key 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=awXRzNwL7JIR8InP@orbyte.nwl.cc \
--to=phil@nwl.cc \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.