evaluate: reset ctx->set after set interval evaluation
Pablo Neira Ayuso
maintainerPATCH 1/1 evaluate: reset ctx->set after set interval evaluation
Otherwise bogus error reports on set datatype mismatch might occur, such as:
Error: datatype mismatch, expected Internet protocol, expression has type IPv4 address
meta l4proto { tcp, udp } th dport 443 dnat to 10.0.0.1
^^^^^^^^^^^^with an unrelated set declaration.
table ip test {
set set_with_interval {
type ipv4_addr
flags interval
}
chain prerouting {
type nat hook prerouting priority dstnat; policy accept;
meta l4proto { tcp, udp } th dport 443 dnat to 10.0.0.1
}
}This bug has been introduced in the evaluation step.
Reported-by Roman Petrov <[email protected]>
Fixes 81e36530fcac ("src: replace interval segment tree overlap and automerge)"
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- src/evaluate.c | 10 ++++++---- tests/shell/testcases/sets/dumps/set_eval_0.nft | 11 +++++++++++ tests/shell/testcases/sets/set_eval_0 | 17 +++++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 tests/shell/testcases/sets/dumps/set_eval_0.nft create mode 100755 tests/shell/testcases/sets/set_eval_0
src/evaluate.c +6 -4
@@ -4005,8 +4005,9 @@ static int setelem_evaluate(struct eval_ctx *ctx, struct cmd *cmd) cmd->elem.set =set_get (set);if (set_is_interval (ctx->set->flags) && - !(set->flags &NFT_SET_CONCAT )) -return interval_set_eval (ctx, ctx->set, cmd->expr); + !(set->flags &NFT_SET_CONCAT ) && +interval_set_eval (ctx, ctx->set, cmd->expr) <0 ) +return -1 ; ctx->set =NULL ;
@@ -4184,8 +4185,9 @@ static int set_evaluate(struct eval_ctx *ctx, struct set *set) }if (set_is_interval (ctx->set->flags) && - !(ctx->set->flags &NFT_SET_CONCAT )) -return interval_set_eval (ctx, ctx->set, set->init); + !(ctx->set->flags &NFT_SET_CONCAT ) && +interval_set_eval (ctx, ctx->set, set->init) <0 ) +return -1 ; ctx->set =NULL ;
tests/shell/testcases/sets/dumps/set_eval_0.nft new file +11 -0
@@ -0,0 +1,11 @@ +table ip nat { + set set_with_interval { + type ipv4_addr + flags interval + } + + chain prerouting { + type nat hook prerouting priority dstnat; policy accept; + meta l4proto { tcp, udp } th dport 443 dnat to 10.0.0.1 + } +}
tests/shell/testcases/sets/set_eval_0 new file +17 -0
@@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +RULESET="table ip nat { + set set_with_interval { + type ipv4_addr + flags interval + } + + chain prerouting { + type nat hook prerouting priority dstnat; policy accept; + meta l4proto { tcp, udp } th dport 443 dnat to 10.0.0.1 + } +}" + +$NFT -f - <<< $RULESET
Signature · 1 line
2.30.2