cache: fix --echo with index/position
PATCH 1/2 cache: fix --echo with index/position
Always call evaluate_cache_add() so it can set special flags - in this case NFT_CACHE_UPDATE.
Fixes 01e5c6f0ed03 ("src: add cache level flags")
Signed-off-by Eric Garver <[email protected]>
--- src/cache.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
src/cache.c +2 -4
@@ -104,11 +104,9 @@ unsigned int cache_evaluate(struct nft_ctx *nft, struct list_head *cmds)case CMD_ADD :case CMD_INSERT :case CMD_CREATE : -if (nft_output_echo (&nft->output)) { - flags =NFT_CACHE_FULL ; -break ; - } flags =evaluate_cache_add (cmd, flags); +if (nft_output_echo (&nft->output)) + flags |=NFT_CACHE_FULL ;break ;case CMD_REPLACE : flags =NFT_CACHE_FULL ;
Signature · 1 line
2.20.1
PATCH 2/2 tests: shell: check that rule add with index works with echo
Signed-off-by Eric Garver <[email protected]>
--- tests/shell/testcases/cache/0007_echo_cache_init_0 | 14 ++++++++++++++ .../cache/dumps/0007_echo_cache_init_0.nft | 7 +++++++ 2 files changed, 21 insertions(+) create mode 100755 tests/shell/testcases/cache/0007_echo_cache_init_0 create mode 100644 tests/shell/testcases/cache/dumps/0007_echo_cache_init_0.nft
tests/shell/testcases/cache/0007_echo_cache_init_0 new file +14 -0
@@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +$NFT -i >/dev/null <<EOF +add table inet t +add chain inet t c +add rule inet t c accept comment "first" +add rule inet t c accept comment "third" +EOF + +# make sure the rule cache gets initialized when using echo option +# +$NFT --echo add rule inet t c index 0 accept comment '"second"' >/dev/null
tests/shell/testcases/cache/dumps/0007_echo_cache_init_0.nft new file +7 -0
@@ -0,0 +1,7 @@ +table inet t { + chain c { + accept comment "first" + accept comment "second" + accept comment "third" + } +}
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerRe: [PATCH 2/2] tests: shell: check that rule add with index works with echo
Also applied, thanks.
Quoted 2 lines · Eric Garver
Always call
evaluate_cache_add()so it can set special flags - in this caseNFT_CACHE_UPDATE.
Applied, thanks.