netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft 4/9] evaluate: don't eval unary arguments
Date: Fri, 17 Mar 2023 10:58:28 +0100	[thread overview]
Message-ID: <20230317095833.1225401-5-pablo@netfilter.org> (raw)
In-Reply-To: <20230317095833.1225401-1-pablo@netfilter.org>

From: Jeremy Sowden <jeremy@azazel.net>

When a unary expression is inserted to implement a byte-order
conversion, the expression being converted has already been evaluated
and so `expr_evaluate_unary` doesn't need to do so.

This is required by {ct|meta} statements with bitwise operations, which
might result in byteorder conversion of the expression.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/evaluate.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/evaluate.c b/src/evaluate.c
index 06aa71561619..6d61cdb25f3d 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -1198,12 +1198,10 @@ static int expr_evaluate_range(struct eval_ctx *ctx, struct expr **expr)
  */
 static int expr_evaluate_unary(struct eval_ctx *ctx, struct expr **expr)
 {
-	struct expr *unary = *expr, *arg;
+	struct expr *unary = *expr, *arg = unary->arg;
 	enum byteorder byteorder;
 
-	if (expr_evaluate(ctx, &unary->arg) < 0)
-		return -1;
-	arg = unary->arg;
+	/* unary expression arguments has already been evaluated. */
 
 	assert(!expr_is_constant(arg));
 	assert(expr_basetype(arg)->type == TYPE_INTEGER);
-- 
2.30.2


  parent reply	other threads:[~2023-03-17  9:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17  9:58 [PATCH nft 0/9] mark statement support for non-constant expression Pablo Neira Ayuso
2023-03-17  9:58 ` [PATCH nft 1/9] evaluate: insert byte-order conversions for expressions between 9 and 15 bits Pablo Neira Ayuso
2023-03-17  9:58 ` [PATCH nft 2/9] netlink_delinearize: correct type and byte-order of shifts Pablo Neira Ayuso
2023-03-17  9:58 ` [PATCH nft 3/9] evaluate: support shifts larger than the width of the left operand Pablo Neira Ayuso
2023-03-17  9:58 ` Pablo Neira Ayuso [this message]
2023-03-17  9:58 ` [PATCH nft 5/9] evaluate: get length from statement instead of lhs expression Pablo Neira Ayuso
2023-03-17  9:58 ` [PATCH nft 6/9] evaluate: relax type-checking for integer arguments in mark statements Pablo Neira Ayuso
2023-03-17  9:58 ` [PATCH nft 7/9] tests: py: add test-cases for ct and packet mark payload expressions Pablo Neira Ayuso
2023-03-17  9:58 ` [PATCH nft 8/9] tests: shell: rename and move bitwise test-cases Pablo Neira Ayuso
2023-03-17  9:58 ` [PATCH nft 9/9] tests: shell: add test-cases for ct and packet mark payload 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=20230317095833.1225401-5-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;
as well as URLs for NNTP newsgroup(s).