From: Jeremy Sowden <jeremy@azazel.net>
To: Pablo Neira Ayuso <pablo@netfilter.org>, Florian Westphal <fw@strlen.de>
Cc: Netfilter Devel <netfilter-devel@vger.kernel.org>
Subject: [PATCH nft v3 10/18] evaluate: allow boolean binop expressions with variable righthand arguments.
Date: Tue, 3 Mar 2020 09:48:36 +0000 [thread overview]
Message-ID: <20200303094844.26694-11-jeremy@azazel.net> (raw)
In-Reply-To: <20200303094844.26694-1-jeremy@azazel.net>
Hitherto, the kernel has required constant values for the xor and mask
attributes of boolean bitwise expressions. This has meant that the
righthand argument of a boolean binop must be constant. Now the kernel
supports passing mask and xor via registers, we can relax this
restriction.
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
---
src/evaluate.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/evaluate.c b/src/evaluate.c
index 4a23b231c74d..1db175007c2d 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -1135,7 +1135,7 @@ static int expr_evaluate_bitwise(struct eval_ctx *ctx, struct expr **expr)
op->byteorder = left->byteorder;
op->len = left->len;
- if (expr_is_constant(left))
+ if (expr_is_constant(left) && expr_is_constant(op->right))
return constant_binop_simplify(ctx, expr);
return 0;
}
@@ -1179,23 +1179,22 @@ static int expr_evaluate_binop(struct eval_ctx *ctx, struct expr **expr)
"for %s expressions",
sym, expr_name(left));
- if (!expr_is_constant(right))
- return expr_binary_error(ctx->msgs, right, op,
- "Right hand side of binary operation "
- "(%s) must be constant", sym);
-
- if (!expr_is_singleton(right))
- return expr_binary_error(ctx->msgs, left, op,
- "Binary operation (%s) is undefined "
- "for %s expressions",
- sym, expr_name(right));
-
/* The grammar guarantees this */
assert(expr_basetype(left) == expr_basetype(right));
switch (op->op) {
case OP_LSHIFT:
case OP_RSHIFT:
+ if (!expr_is_constant(right))
+ return expr_binary_error(ctx->msgs, right, op,
+ "Right hand side of binary operation "
+ "(%s) must be constant", sym);
+
+ if (!expr_is_singleton(right))
+ return expr_binary_error(ctx->msgs, left, op,
+ "Binary operation (%s) is undefined "
+ "for %s expressions",
+ sym, expr_name(right));
return expr_evaluate_shift(ctx, expr);
case OP_AND:
case OP_XOR:
--
2.25.1
next prev parent reply other threads:[~2020-03-03 10:14 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-03 9:48 [PATCH nft v3 00/18] Support for boolean binops with variable RHS operands Jeremy Sowden
2020-03-03 9:48 ` [PATCH nft v3 01/18] evaluate: add separate variables for lshift and xor binops Jeremy Sowden
2020-03-03 9:48 ` [PATCH nft v3 02/18] evaluate: simplify calculation of payload size Jeremy Sowden
2020-03-03 9:48 ` [PATCH nft v3 03/18] evaluate: don't evaluate payloads twice Jeremy Sowden
2020-03-03 9:48 ` [PATCH nft v3 04/18] evaluate: convert the byte-order of payload statement arguments Jeremy Sowden
2020-03-03 9:48 ` [PATCH nft v3 05/18] evaluate: no need to swap byte-order for values of fewer than 16 bits Jeremy Sowden
2020-03-03 9:48 ` [PATCH nft v3 06/18] netlink_delinearize: set shift RHS byte-order Jeremy Sowden
2020-03-03 9:48 ` [PATCH nft v3 07/18] src: fix leaks Jeremy Sowden
2020-03-03 9:48 ` [PATCH nft v3 08/18] include: update nf_tables.h Jeremy Sowden
2020-03-03 9:48 ` [PATCH nft v3 09/18] src: support (de)linearization of bitwise op's with variable right operands Jeremy Sowden
2020-03-03 9:48 ` Jeremy Sowden [this message]
2020-03-03 9:48 ` [PATCH nft v3 11/18] evaluate: don't clobber binop bitmask lengths Jeremy Sowden
2020-03-03 9:48 ` [PATCH nft v3 12/18] netlink_delinearize: fix typo Jeremy Sowden
2020-03-03 9:48 ` [PATCH nft v3 13/18] netlink_delinearize: refactor stmt_payload_binop_postprocess Jeremy Sowden
2020-03-03 9:48 ` [PATCH nft v3 14/18] netlink_delinearize: add support for processing variable payload statement arguments Jeremy Sowden
2020-03-03 9:48 ` [PATCH nft v3 15/18] netlink_delinearize: add postprocessing for payload binops Jeremy Sowden
2020-03-03 9:48 ` [PATCH nft v3 16/18] tests: shell: remove stray debug flag Jeremy Sowden
2020-03-03 9:48 ` [PATCH nft v3 17/18] tests: shell: add variable binop RHS tests Jeremy Sowden
2020-03-03 9:48 ` [PATCH nft v3 18/18] tests: py: " Jeremy Sowden
2020-03-10 2:39 ` Pablo Neira Ayuso
2020-03-10 9:30 ` Jeremy Sowden
2020-03-11 13:26 ` Pablo Neira Ayuso
2020-03-11 14:35 ` Jeremy Sowden
2020-03-11 17:17 ` Pablo Neira Ayuso
2020-03-11 20:54 ` Jeremy Sowden
2020-03-05 10:53 ` [PATCH nft v3 00/18] Support for boolean binops with variable RHS operands Florian Westphal
2020-03-05 11:36 ` Jeremy Sowden
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=20200303094844.26694-11-jeremy@azazel.net \
--to=jeremy@azazel.net \
--cc=fw@strlen.de \
--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 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).