Skip to contentSkip to conversation

cache: fix --echo with index/position

PATCH In review Pablo Neira Ayuso 2 participants 3 messages Sep 5, 2019 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 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.

Fixes 01e5c6f0ed03 ("src: add cache level flags")
---
 src/cache.c | 3 +++
 1 file changed, 3 insertions(+)
src/cache.c +3 -0
index cffcbb623ced..71d16a0fbeed 100644
@@ -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
#1 lore raw
Quoted 15 lines · Pablo Neira Ayuso

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.

Fixes 01e5c6f0ed03 ("src: add cache level flags")
---
 src/cache.c | 3 +++
 1 file changed, 3 insertions(+)
src/cache.c +0 -0
index cffcbb623ced..71d16a0fbeed 100644

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
index cffcbb623ced..f7ca8fe9068f 100644
@@ -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;
author maintainer
#2 lore raw
Quoted 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_UPDATE flag in this case to enable incremental cache updates.

Fixes 01e5c6f0ed03 ("src: add cache level flags")
---
 src/cache.c | 3 +++
 1 file changed, 3 insertions(+)
src/cache.c +1 -0
index cffcbb623ced..71d16a0fbeed 100644
@@ -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
index cffcbb623ced..f7ca8fe9068f 100644
@@ -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;