All of lore.kernel.org
 help / color / mirror / Atom feed
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: Wed, 25 Nov 2026 11:49:28 +0100	[thread overview]
Message-ID: <awa9OPt8pbWg6fol@orbyte.nwl.cc> (raw)
In-Reply-To: <awYpSv50FCy3yFhV@chamomile>

Hi Pablo,

On Wed, Nov 25, 2026 at 01:18:18AM +0100, Pablo Neira Ayuso wrote:
> On Tue, Nov 24, 2026 at 07:05:00PM +0100, Phil Sutter wrote:
[...]
> > 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.
> 
> Yes, wrong byteorder. TYPE_INTEGER (integer_type) uses
> BYTEORDER_INVALID in this case, which is handled as
> BYTEORDER_BIG_ENDIAN for historical reasons.

Ah yes, I reached that spot yesterday evening already but wasn't sure
how things were supposed to be.

> > 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. :(
> 
> Patch:
> https://lore.kernel.org/netfilter-devel/20261124235306.1777-1-pablo@netfilter.org/
> 
> This rework uncovered this underlying bug.
> 
> BTW, nft --debug=netlink does not help to find endianness bugs anymore.

You know we disagree on that. ;P

The endianness-aware netlink debug output actually uncovered Big
Endian-specific bugs (due to py test suite becoming useful on Big Endian
systems).

It's just that we don't notice if a value is in wrong byteorder but also
marked as such (and therefore "corrected" when printing). To make up for
that, I tried the following in libnftnl:

| --- a/src/expr/data_reg.c
| +++ b/src/expr/data_reg.c
| @@ -70,6 +70,12 @@ nftnl_data_reg_value_snprintf_default(char *buf, size_t remain,
|                         SNPRINTF_BUFFER_SIZE(ret, remain, offset);
|                 }
|  
| +               if (flags & DATA_F_HNPFX) {
| +                       ret = snprintf(buf + offset, remain, "%c:",
| +                                      reg->byteorder & (1 << i) ? 'n' : 'h');
| +                       SNPRINTF_BUFFER_SIZE(ret, remain, offset);
| +               }
| +
|                 ret = __reg_value_snprintf(buf + offset, remain,
|                                            (void *)&reg->val[pos],
|                                            curlen, reverse, pfx);

Then we could add --debug=byteorder option in nft tool to set the flag.
We could also permanently add the prefix, but that would need a bulk
update of payload files. What do you think?

Cheers, Phil

  reply	other threads:[~2026-11-25 10:49 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
2026-11-25  0:18     ` Pablo Neira Ayuso
2026-11-25 10:49       ` Phil Sutter [this message]
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=awa9OPt8pbWg6fol@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.