summaryrefslogtreecommitdiffstats
path: root/src/evaluate.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2016-04-27 12:29:46 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2016-05-13 18:57:04 +0200
commit01a5eaee44355cff75f4b320b995b40588b3eede (patch)
treedab2c3b729134f582140997da5066f929e65751b /src/evaluate.c
parent0ce93baa9f4db1acc393b185662b506aebbb759a (diff)
set: explicitly supply name to implicit set declarations
Support explicitly names implicitly declared sets. Also change the template names for literal sets and maps to use identifiers that can not clash with user supplied identifiers. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/evaluate.c')
-rw-r--r--src/evaluate.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/evaluate.c b/src/evaluate.c
index c5f87a19..9d89d905 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -87,6 +87,7 @@ static int __fmtstring(3, 4) set_error(struct eval_ctx *ctx,
}
static struct expr *implicit_set_declaration(struct eval_ctx *ctx,
+ const char *name,
const struct datatype *keytype,
unsigned int keylen,
struct expr *expr)
@@ -97,7 +98,7 @@ static struct expr *implicit_set_declaration(struct eval_ctx *ctx,
set = set_alloc(&expr->location);
set->flags = SET_F_ANONYMOUS | expr->set_flags;
- set->handle.set = xstrdup(set->flags & SET_F_MAP ? "map%d" : "set%d");
+ set->handle.set = xstrdup(name),
set->keytype = keytype;
set->keylen = keylen;
set->init = expr;
@@ -1100,7 +1101,8 @@ static int expr_evaluate_map(struct eval_ctx *ctx, struct expr **expr)
switch (map->mappings->ops->type) {
case EXPR_SET:
- mappings = implicit_set_declaration(ctx, ctx->ectx.dtype,
+ mappings = implicit_set_declaration(ctx, "__map%d",
+ ctx->ectx.dtype,
ctx->ectx.len, mappings);
mappings->set->datatype = ectx.dtype;
mappings->set->datalen = ectx.len;
@@ -1389,7 +1391,8 @@ static int expr_evaluate_relational(struct eval_ctx *ctx, struct expr **expr)
* the set
*/
right = rel->right =
- implicit_set_declaration(ctx, left->dtype,
+ implicit_set_declaration(ctx, "__set%d",
+ left->dtype,
left->len, right);
break;
case EXPR_SET_REF: