Misc minor fixes
Phil Sutter
reviewercover Misc minor fixes
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(-)
Signature · 1 line
2.21.0
Phil Sutter
reviewerPATCH 1/4 tests: monitor: Adjust to changed events ordering
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.
--- tests/monitor/testcases/simple.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tests/monitor/testcases/simple.t +2 -2
@@ -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 }
Signature · 1 line
2.21.0
Phil Sutter
reviewerPATCH 2/4 tests/py: Fix error messages in chain_delete()
In reply to Phil SutterAdding string and chain object is an illegal operation in Python. Instead concatenate with cmd string since that contains all required information already.
--- tests/py/nft-test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tests/py/nft-test.py +2 -2
@@ -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
Signature · 1 line
2.21.0
Phil Sutter
reviewerPATCH 3/4 parser_json: Fix typo in ct timeout policy parser
In reply to Phil SutterParser expects an object in policy property and json_is_object() returns true if given parameter is an object. The check was inverse by accident.
--- src/parser_json.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/parser_json.c +1 -1
@@ -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 ; }
Signature · 1 line
2.21.0
Phil Sutter
reviewerPATCH 4/4 parser_json: Fix parser for list maps command
In reply to Phil SutterWrong callback in json_parse_cmd_list() for "maps" key.
--- src/parser_json.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/parser_json.c +1 -1
@@ -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 },
Signature · 1 line
2.21.0
Quoted 1 line · Phil Sutter
This series contains a few smaller fixes to tests and JSON parser.
Applied, thanks Phil.