summaryrefslogtreecommitdiffstats
path: root/src/parser_json.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2019-05-09 13:35:41 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2019-05-09 17:19:50 +0200
commit1b8953e75c20437b5c563d86c3ba11d1b24e3ec4 (patch)
tree6d71a2ffbede3d03f74d350a0a9feb81551f7b7d /src/parser_json.c
parent43cb4f27da74184da350c62cad8dd573590b09c6 (diff)
json: Fix tproxy support regarding latest changes
Family may be specified also if no address is given at the same time, make parser/printer tolerant to that. Also fix for missing/incorrect JSON equivalents in tests/py. While being at it, fix two issues in non-JSON tests: * Ruleset is printed in numeric mode, so use 'l4proto 6' instead of 'l4proto tcp' in rules to avoid having to specify expected output for that unrelated bit. * In ip and ip6 family tables, family parameter is not deserialized on output. Fixes: 3edb96200690b ("parser_bison: missing tproxy syntax with port only for inet family") Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/parser_json.c')
-rw-r--r--src/parser_json.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/parser_json.c b/src/parser_json.c
index e042d776..9c5fafba 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -1899,17 +1899,15 @@ static struct stmt *json_parse_tproxy_stmt(struct json_ctx *ctx,
if (familyval < 0)
goto out_free;
- if (familyval == NFPROTO_UNSPEC ||
- json_unpack(value, "{s:o}", "addr", &jaddr))
- goto try_port;
-
stmt->tproxy.family = familyval;
- stmt->tproxy.addr = json_parse_stmt_expr(ctx, jaddr);
- if (!stmt->tproxy.addr) {
- json_error(ctx, "Invalid addr.");
- goto out_free;
+
+ if (!json_unpack(value, "{s:o}", "addr", &jaddr)) {
+ stmt->tproxy.addr = json_parse_stmt_expr(ctx, jaddr);
+ if (!stmt->tproxy.addr) {
+ json_error(ctx, "Invalid addr.");
+ goto out_free;
+ }
}
-try_port:
if (!json_unpack(value, "{s:o}", "port", &tmp)) {
stmt->tproxy.port = json_parse_stmt_expr(ctx, tmp);
if (!stmt->tproxy.port) {