summaryrefslogtreecommitdiffstats
path: root/src/parser_json.c
diff options
context:
space:
mode:
authorFernando Fernandez Mancera <ffmancera@riseup.net>2019-08-02 12:12:08 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2019-08-08 12:32:48 +0200
commit627c451b2351310da9ad82dbdb64747b1fada8e5 (patch)
treea049c393ec78296bd014d807943c573c75695e81 /src/parser_json.c
parent45cb29a2ada4edfc2b547fe023d923ce0299a61d (diff)
src: allow variables in the chain priority specification
This patch allows you to use variables in chain priority definitions, e.g. define prio = filter define prionum = 10 define prioffset = "filter - 150" add table ip foo add chain ip foo bar { type filter hook input priority $prio; } add chain ip foo ber { type filter hook input priority $prionum; } add chain ip foo bor { type filter hook input priority $prioffset; } Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/parser_json.c')
-rw-r--r--src/parser_json.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/parser_json.c b/src/parser_json.c
index 76c0a5cc..a45234ad 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -2580,7 +2580,10 @@ static struct cmd *json_parse_cmd_add_chain(struct json_ctx *ctx, json_t *root,
chain = chain_alloc(NULL);
chain->flags |= CHAIN_F_BASECHAIN;
chain->type = xstrdup(type);
- chain->priority.num = prio;
+ chain->priority.expr = constant_expr_alloc(int_loc, &integer_type,
+ BYTEORDER_HOST_ENDIAN,
+ sizeof(int) * BITS_PER_BYTE,
+ &prio);
chain->hookstr = chain_hookname_lookup(hookstr);
if (!chain->hookstr) {
json_error(ctx, "Invalid chain hook '%s'.", hookstr);
@@ -2947,7 +2950,10 @@ static struct cmd *json_parse_cmd_add_flowtable(struct json_ctx *ctx,
flowtable = flowtable_alloc(int_loc);
flowtable->hookstr = hookstr;
- flowtable->priority.num = prio;
+ flowtable->priority.expr =
+ constant_expr_alloc(int_loc, &integer_type,
+ BYTEORDER_HOST_ENDIAN,
+ sizeof(int) * BITS_PER_BYTE, &prio);
flowtable->dev_expr = json_parse_flowtable_devs(ctx, devs);
if (!flowtable->dev_expr) {