Netfilter-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/2] cache: fix --echo with index/position
@ 2019-09-06  0:33 Eric Garver
  2019-09-06  0:33 ` [PATCH 2/2] tests: shell: check that rule add with index works with echo Eric Garver
  2019-09-06  0:36 ` [PATCH 1/2] cache: fix --echo with index/position Pablo Neira Ayuso
  0 siblings, 2 replies; 4+ messages in thread
From: Eric Garver @ 2019-09-06  0:33 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Pablo Neira Ayuso

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 <eric@garver.life>
---
 src/cache.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/cache.c b/src/cache.c
index cffcbb623ced..a778650ac133 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -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;
-- 
2.20.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] tests: shell: check that rule add with index works with echo
  2019-09-06  0:33 [PATCH 1/2] cache: fix --echo with index/position Eric Garver
@ 2019-09-06  0:33 ` Eric Garver
  2019-09-06  0:36   ` Pablo Neira Ayuso
  2019-09-06  0:36 ` [PATCH 1/2] cache: fix --echo with index/position Pablo Neira Ayuso
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Garver @ 2019-09-06  0:33 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Pablo Neira Ayuso

Signed-off-by: Eric Garver <eric@garver.life>
---
 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

diff --git a/tests/shell/testcases/cache/0007_echo_cache_init_0 b/tests/shell/testcases/cache/0007_echo_cache_init_0
new file mode 100755
index 000000000000..280a0d06bdc3
--- /dev/null
+++ b/tests/shell/testcases/cache/0007_echo_cache_init_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
diff --git a/tests/shell/testcases/cache/dumps/0007_echo_cache_init_0.nft b/tests/shell/testcases/cache/dumps/0007_echo_cache_init_0.nft
new file mode 100644
index 000000000000..c774ee72a683
--- /dev/null
+++ b/tests/shell/testcases/cache/dumps/0007_echo_cache_init_0.nft
@@ -0,0 +1,7 @@
+table inet t {
+	chain c {
+		accept comment "first"
+		accept comment "second"
+		accept comment "third"
+	}
+}
-- 
2.20.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] cache: fix --echo with index/position
  2019-09-06  0:33 [PATCH 1/2] cache: fix --echo with index/position Eric Garver
  2019-09-06  0:33 ` [PATCH 2/2] tests: shell: check that rule add with index works with echo Eric Garver
@ 2019-09-06  0:36 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2019-09-06  0:36 UTC (permalink / raw)
  To: Eric Garver; +Cc: netfilter-devel

On Thu, Sep 05, 2019 at 08:33:01PM -0400, Eric Garver wrote:
> Always call evaluate_cache_add() so it can set special flags - in this
> case NFT_CACHE_UPDATE.

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] tests: shell: check that rule add with index works with echo
  2019-09-06  0:33 ` [PATCH 2/2] tests: shell: check that rule add with index works with echo Eric Garver
@ 2019-09-06  0:36   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2019-09-06  0:36 UTC (permalink / raw)
  To: Eric Garver; +Cc: netfilter-devel

Also applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-06  0:33 [PATCH 1/2] cache: fix --echo with index/position Eric Garver
2019-09-06  0:33 ` [PATCH 2/2] tests: shell: check that rule add with index works with echo Eric Garver
2019-09-06  0:36   ` Pablo Neira Ayuso
2019-09-06  0:36 ` [PATCH 1/2] cache: fix --echo with index/position Pablo Neira Ayuso

Netfilter-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netfilter-devel/0 netfilter-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netfilter-devel netfilter-devel/ https://lore.kernel.org/netfilter-devel \
		netfilter-devel@vger.kernel.org netfilter-devel@archiver.kernel.org
	public-inbox-index netfilter-devel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netfilter-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox