From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Phil Sutter <phil@nwl.cc>
Cc: netfilter-devel@vger.kernel.org, Yi Chen <yiche@redhat.com>
Subject: Re: [nft PATCH] fib: Fix for existence check on Big Endian
Date: Tue, 9 Sep 2025 23:34:00 +0200 [thread overview]
Message-ID: <aMCdSDWhxCJM_kjY@calendula> (raw)
In-Reply-To: <20250909204948.17757-1-phil@nwl.cc>
Hi Phil,
On Tue, Sep 09, 2025 at 10:49:48PM +0200, Phil Sutter wrote:
> Adjust the expression size to 1B so cmp expression value is correct.
> Without this, the rule 'fib saddr . iif check exists' generates
> following byte code on BE:
>
> | [ fib saddr . iif oif present => reg 1 ]
> | [ cmp eq reg 1 0x00000001 ]
>
> Though with NFTA_FIB_F_PRESENT flag set, nft_fib.ko writes to the first
> byte of reg 1 only (using nft_reg_store8()). With this patch in place,
> byte code is correct:
>
> | [ fib saddr . iif oif present => reg 1 ]
> | [ cmp eq reg 1 0x01000000 ]
Is this a generic issue of boolean that is using 1 bit?
const struct datatype boolean_type = {
.type = TYPE_BOOLEAN,
.name = "boolean",
.desc = "boolean type",
.size = 1,
> Fixes: f686a17eafa0b ("fib: Support existence check")
> Cc: Yi Chen <yiche@redhat.com>
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
> src/evaluate.c | 1 +
> src/fib.c | 4 +++-
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/evaluate.c b/src/evaluate.c
> index 8cecbe09de01c..6a1aa4963bceb 100644
> --- a/src/evaluate.c
> +++ b/src/evaluate.c
> @@ -3002,6 +3002,7 @@ static int expr_evaluate_fib(struct eval_ctx *ctx, struct expr **exprp)
> if (expr->flags & EXPR_F_BOOLEAN) {
> expr->fib.flags |= NFTA_FIB_F_PRESENT;
> datatype_set(expr, &boolean_type);
> + expr->len = BITS_PER_BYTE;
> }
> return expr_evaluate_primary(ctx, exprp);
> }
> diff --git a/src/fib.c b/src/fib.c
> index 5383613292a5e..4db7cd2bbc9c3 100644
> --- a/src/fib.c
> +++ b/src/fib.c
> @@ -198,8 +198,10 @@ struct expr *fib_expr_alloc(const struct location *loc,
> BUG("Unknown result %d\n", result);
> }
>
> - if (flags & NFTA_FIB_F_PRESENT)
> + if (flags & NFTA_FIB_F_PRESENT) {
> type = &boolean_type;
> + len = BITS_PER_BYTE;
> + }
>
> expr = expr_alloc(loc, EXPR_FIB, type,
> BYTEORDER_HOST_ENDIAN, len);
> --
> 2.51.0
>
next prev parent reply other threads:[~2025-09-09 21:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-09 20:49 [nft PATCH] fib: Fix for existence check on Big Endian Phil Sutter
2025-09-09 21:34 ` Pablo Neira Ayuso [this message]
2025-09-09 22:48 ` Phil Sutter
2025-09-11 8:14 ` Pablo Neira Ayuso
2025-09-11 10:19 ` Phil Sutter
2025-09-11 14:20 ` Pablo Neira Ayuso
2025-09-11 16:17 ` Phil Sutter
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=aMCdSDWhxCJM_kjY@calendula \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=phil@nwl.cc \
--cc=yiche@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).