netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [nft PATCH 0/4] Misc minor fixes
@ 2019-04-25 12:59 Phil Sutter
  2019-04-25 12:59 ` [nft PATCH 1/4] tests: monitor: Adjust to changed events ordering Phil Sutter
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Phil Sutter @ 2019-04-25 12:59 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

This series contains a few smaller fixes to tests and JSON parser.

Phil Sutter (4):
  tests: monitor: Adjust to changed events ordering
  tests/py: Fix error messages in chain_delete()
  parser_json: Fix typo in ct timeout policy parser
  parser_json: Fix parser for list maps command

 src/parser_json.c                | 4 ++--
 tests/monitor/testcases/simple.t | 4 ++--
 tests/py/nft-test.py             | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

-- 
2.21.0


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

* [nft PATCH 1/4] tests: monitor: Adjust to changed events ordering
  2019-04-25 12:59 [nft PATCH 0/4] Misc minor fixes Phil Sutter
@ 2019-04-25 12:59 ` Phil Sutter
  2019-04-25 12:59 ` [nft PATCH 2/4] tests/py: Fix error messages in chain_delete() Phil Sutter
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Phil Sutter @ 2019-04-25 12:59 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

When replacing a rule, kernel nowadays seems to report rule add event
before rule delete one. Since both events belong to the same
transaction, this is harmless per definition and merely needs adjustment
in expected output.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 tests/monitor/testcases/simple.t | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/monitor/testcases/simple.t b/tests/monitor/testcases/simple.t
index 78d8f8b04bd36..78fd6616eb074 100644
--- a/tests/monitor/testcases/simple.t
+++ b/tests/monitor/testcases/simple.t
@@ -18,10 +18,10 @@ O add rule ip t c counter packets 0 bytes 0 accept
 J {"add": {"rule": {"family": "ip", "table": "t", "chain": "c", "handle": 0, "expr": [{"counter": {"packets": 0, "bytes": 0}}, {"accept": null}]}}}
 
 I replace rule ip t c handle 2 accept comment "foo bar"
-O delete rule ip t c handle 2
 O add rule ip t c accept comment "foo bar"
-J {"delete": {"rule": {"family": "ip", "table": "t", "chain": "c", "handle": 0, "expr": [{"accept": null}]}}}
+O delete rule ip t c handle 2
 J {"add": {"rule": {"family": "ip", "table": "t", "chain": "c", "handle": 0, "comment": "foo bar", "expr": [{"accept": null}]}}}
+J {"delete": {"rule": {"family": "ip", "table": "t", "chain": "c", "handle": 0, "expr": [{"accept": null}]}}}
 
 I add counter ip t cnt
 O add counter ip t cnt { packets 0 bytes 0 }
-- 
2.21.0


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

* [nft PATCH 2/4] tests/py: Fix error messages in chain_delete()
  2019-04-25 12:59 [nft PATCH 0/4] Misc minor fixes Phil Sutter
  2019-04-25 12:59 ` [nft PATCH 1/4] tests: monitor: Adjust to changed events ordering Phil Sutter
@ 2019-04-25 12:59 ` Phil Sutter
  2019-04-25 12:59 ` [nft PATCH 3/4] parser_json: Fix typo in ct timeout policy parser Phil Sutter
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Phil Sutter @ 2019-04-25 12:59 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

Adding string and chain object is an illegal operation in Python.
Instead concatenate with cmd string since that contains all required
information already.

Fixes: 820fd08b5f1d4 ("tests/py: Review print statements in nft-test.py")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 tests/py/nft-test.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py
index 5c7e28a070204..1c0afd0ec0eb3 100755
--- a/tests/py/nft-test.py
+++ b/tests/py/nft-test.py
@@ -310,14 +310,14 @@ def chain_delete(chain, table, filename=None, lineno=None):
     cmd = "flush chain %s %s" % (table, chain)
     ret = execute_cmd(cmd, filename, lineno)
     if ret != 0:
-        reason = "I cannot flush this chain " + chain
+        reason = "I cannot " + cmd
         print_error(reason, filename, lineno)
         return -1
 
     cmd = "delete chain %s %s" % (table, chain)
     ret = execute_cmd(cmd, filename, lineno)
     if ret != 0:
-        reason = cmd + "I cannot delete this chain " + chain
+        reason = "I cannot " + cmd
         print_error(reason, filename, lineno)
         return -1
 
-- 
2.21.0


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

* [nft PATCH 3/4] parser_json: Fix typo in ct timeout policy parser
  2019-04-25 12:59 [nft PATCH 0/4] Misc minor fixes Phil Sutter
  2019-04-25 12:59 ` [nft PATCH 1/4] tests: monitor: Adjust to changed events ordering Phil Sutter
  2019-04-25 12:59 ` [nft PATCH 2/4] tests/py: Fix error messages in chain_delete() Phil Sutter
@ 2019-04-25 12:59 ` Phil Sutter
  2019-04-25 12:59 ` [nft PATCH 4/4] parser_json: Fix parser for list maps command Phil Sutter
  2019-04-30 12:21 ` [nft PATCH 0/4] Misc minor fixes Pablo Neira Ayuso
  4 siblings, 0 replies; 6+ messages in thread
From: Phil Sutter @ 2019-04-25 12:59 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

Parser expects an object in policy property and json_is_object() returns
true if given parameter is an object. The check was inverse by accident.

Fixes: c82a26ebf7e9f ("json: Add ct timeout support")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/parser_json.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/parser_json.c b/src/parser_json.c
index 53017935eba53..01f340802bec9 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -2782,7 +2782,7 @@ static int json_parse_ct_timeout_policy(struct json_ctx *ctx,
 	if (!json_unpack(root, "{s:o}", "policy", &tmp))
 		return 0;
 
-	if (json_is_object(tmp)) {
+	if (!json_is_object(tmp)) {
 		json_error(ctx, "Invalid ct timeout policy.");
 		return 1;
 	}
-- 
2.21.0


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

* [nft PATCH 4/4] parser_json: Fix parser for list maps command
  2019-04-25 12:59 [nft PATCH 0/4] Misc minor fixes Phil Sutter
                   ` (2 preceding siblings ...)
  2019-04-25 12:59 ` [nft PATCH 3/4] parser_json: Fix typo in ct timeout policy parser Phil Sutter
@ 2019-04-25 12:59 ` Phil Sutter
  2019-04-30 12:21 ` [nft PATCH 0/4] Misc minor fixes Pablo Neira Ayuso
  4 siblings, 0 replies; 6+ messages in thread
From: Phil Sutter @ 2019-04-25 12:59 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

Wrong callback in json_parse_cmd_list() for "maps" key.

Fixes: 586ad210368b7 ("libnftables: Implement JSON parser")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/parser_json.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/parser_json.c b/src/parser_json.c
index 01f340802bec9..5c00c9b003b60 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -3147,7 +3147,7 @@ static struct cmd *json_parse_cmd_list(struct json_ctx *ctx,
 		{ "set", CMD_OBJ_SET, json_parse_cmd_add_set },
 		{ "sets", CMD_OBJ_SETS, json_parse_cmd_list_multiple },
 		{ "map", CMD_OBJ_MAP, json_parse_cmd_add_set },
-		{ "maps", CMD_OBJ_MAPS, json_parse_cmd_add_set },
+		{ "maps", CMD_OBJ_MAPS, json_parse_cmd_list_multiple },
 		{ "counter", CMD_OBJ_COUNTER, json_parse_cmd_add_object },
 		{ "counters", CMD_OBJ_COUNTERS, json_parse_cmd_list_multiple },
 		{ "quota", CMD_OBJ_QUOTA, json_parse_cmd_add_object },
-- 
2.21.0


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

* Re: [nft PATCH 0/4] Misc minor fixes
  2019-04-25 12:59 [nft PATCH 0/4] Misc minor fixes Phil Sutter
                   ` (3 preceding siblings ...)
  2019-04-25 12:59 ` [nft PATCH 4/4] parser_json: Fix parser for list maps command Phil Sutter
@ 2019-04-30 12:21 ` Pablo Neira Ayuso
  4 siblings, 0 replies; 6+ messages in thread
From: Pablo Neira Ayuso @ 2019-04-30 12:21 UTC (permalink / raw)
  To: Phil Sutter; +Cc: netfilter-devel

On Thu, Apr 25, 2019 at 02:59:39PM +0200, Phil Sutter wrote:
> This series contains a few smaller fixes to tests and JSON parser.

Applied, thanks Phil.

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

end of thread, other threads:[~2019-04-30 12:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-25 12:59 [nft PATCH 0/4] Misc minor fixes Phil Sutter
2019-04-25 12:59 ` [nft PATCH 1/4] tests: monitor: Adjust to changed events ordering Phil Sutter
2019-04-25 12:59 ` [nft PATCH 2/4] tests/py: Fix error messages in chain_delete() Phil Sutter
2019-04-25 12:59 ` [nft PATCH 3/4] parser_json: Fix typo in ct timeout policy parser Phil Sutter
2019-04-25 12:59 ` [nft PATCH 4/4] parser_json: Fix parser for list maps command Phil Sutter
2019-04-30 12:21 ` [nft PATCH 0/4] Misc minor fixes Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).