[nft PATCH v4 23/32] evaluate: set eval context to leftmost bitwise operand

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A bitwise expression currently derives its type and size from its
left operand.  Thus:

  ct mark & 0xff

has type `mark` and size `32`.

However, currently, something like:

  ct mark | ip dscp | 0x200

will fail because, although evaluation is left-associative, and
therefore this expression will be evaluated as:

 (ct mark | ip dscp) | 0x200

after the evaluation of `ct mark | ip dscp`, the evaluation context
contains the size and data-type of the `ip dscp` expression and so
`0x200` is out of range.

Instead, reset the evaluation context to the values from the left-hand
operand once both operands have been evaluated.

Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx>
---
 src/evaluate.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/evaluate.c b/src/evaluate.c
index 6b1e295d216a..02bfde2a2ded 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -1153,6 +1153,8 @@ static int expr_evaluate_bitwise(struct eval_ctx *ctx, struct expr **expr)
 {
 	struct expr *op = *expr, *left = op->left;
 
+	expr_evaluate_primary(ctx, &left);
+
 	if (byteorder_conversion(ctx, &op->right, left->byteorder) < 0)
 		return -1;
 
-- 
2.35.1




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux