cache: fix --echo with index/position
Pablo Neira Ayuso
maintainerPATCH 1/1 cache: fix --echo with index/position
Check for the index/position in case the echo flag is set on. Set the NFT_CACHE_UPDATE flag in this case to enable incremental cache updates.
--- src/cache.c | 3 +++ 1 file changed, 3 insertions(+)
src/cache.c +3 -0
@@ -106,6 +106,9 @@ unsigned int cache_evaluate(struct nft_ctx *nft, struct list_head *cmds)case CMD_CREATE :if (nft_output_echo (&nft->output)) { flags =NFT_CACHE_FULL ; +if (cmd->handle.index.id || + cmd->handle.position.id) + flags |=NFT_CACHE_UPDATE ;break ; } flags =evaluate_cache_add (cmd, flags);
Signature · 1 line
2.11.0
Quoted 15 lines · Pablo Neira Ayuso
Check for the index/position in case the echo flag is set on. Set the
NFT_CACHE_UPDATEflag in this case to enable incremental cache updates.Reported-by Eric Garver <[email protected]>Fixes 01e5c6f0ed03 ("src: add cache level flags")Signed-off-by Pablo Neira Ayuso <[email protected]>--- src/cache.c | 3 +++ 1 file changed, 3 insertions(+)src/cache.c +0
-0
src/cache.c unsigned int cache_evaluate(struct nft_ctx *nft, struct list_head *cmds) · line 114
Quoted 9 lines
src/cache.c +3
-0@@ -106,6 +106,9 @@ unsigned int cache_evaluate(struct nft_ctx *nft, struct list_head *cmds)case CMD_CREATE :if (nft_output_echo (&nft->output)) { flags =NFT_CACHE_FULL ; +if (cmd->handle.index.id || + cmd->handle.position.id) + flags |=NFT_CACHE_UPDATE ;break ; } flags =evaluate_cache_add (cmd, flags);
We can keep the special cases isolated to evaluate_cache_add() by always calling it.
src/cache.c +2 -3
@@ -104,11 +104,10 @@ unsigned int cache_evaluate(struct nft_ctx *nft, struct list_head *cmds)case CMD_ADD :case CMD_INSERT :case CMD_CREATE : + flags =evaluate_cache_add (cmd, flags);if (nft_output_echo (&nft->output)) { - flags =NFT_CACHE_FULL ; -break ; + flags |=NFT_CACHE_FULL ; } - flags =evaluate_cache_add (cmd, flags);break ;case CMD_REPLACE : flags =NFT_CACHE_FULL ;
Pablo Neira Ayuso
maintainerQuoted 20 lines · Eric Garver
Quoted 19 lines · Pablo Neira Ayuso
Check for the index/position in case the echo flag is set on. Set the
NFT_CACHE_UPDATEflag in this case to enable incremental cache updates.Reported-by Eric Garver <[email protected]>Fixes 01e5c6f0ed03 ("src: add cache level flags")Signed-off-by Pablo Neira Ayuso <[email protected]>--- src/cache.c | 3 +++ 1 file changed, 3 insertions(+)src/cache.c +1
-0@@ -106,6 +106,9 @@ unsigned int cache_evaluate(struct nft_ctx *nft, struct list_head *cmds)case CMD_CREATE :if (nft_output_echo (&nft->output)) { flags =NFT_CACHE_FULL ; + if (cmd->handle.index.id ||
Quoted 8 lines
src/cache.c unsigned int cache_evaluate(struct nft_ctx *nft, struct list_head *cmds) · line 114
Quoted 5 lines
src/cache.c +2
-0+ cmd->handle.position.id) + flags |=NFT_CACHE_UPDATE ;break ; } flags =evaluate_cache_add (cmd, flags);We can keep the special cases isolated to
evaluate_cache_add()by always calling it.
That's fine too, yes. Would you formally submit this patch? Thanks.
Quoted 18 lines
src/cache.c +2
-3@@ -104,11 +104,10 @@ unsigned int cache_evaluate(struct nft_ctx *nft, struct list_head *cmds)case CMD_ADD :case CMD_INSERT :case CMD_CREATE : + flags =evaluate_cache_add (cmd, flags);if (nft_output_echo (&nft->output)) { - flags =NFT_CACHE_FULL ; -break ; + flags |=NFT_CACHE_FULL ; } - flags =evaluate_cache_add (cmd, flags);break ;case CMD_REPLACE : flags =NFT_CACHE_FULL ;