summaryrefslogtreecommitdiffstats
path: root/src/expression.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2017-07-12 14:14:16 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2017-07-17 17:29:32 +0200
commit19cd540390e32f2e1f62e205ddb691d1e6e06152 (patch)
treed720e0a38e7c9162b92a3d34e4133097c4f6f8cc /src/expression.c
parenta177d08d82c4cf946324640a63581e837164dc0b (diff)
src: Allow passing the parent set to set_expr_alloc()
Usually one wants to at least initialize set_flags from the parent, so make allocation of a set's set expression more convenient. The idea to do this came when fixing an issue with output formatting of larger anonymous sets in nft monitor: Since netlink_events_cache_addset() didn't initialize set_flags, calculate_delim() didn't detect it's an anonymous set and therefore added newlines to the output. Reported-by: Arturo Borrero Gonzalez <arturo@netfilter.org> Fixes: a9dc3ceabc10f ("expression: print sets and maps in pretty format") Signed-off-by: Phil Sutter <phil@nwl.cc> Acked-by: Arturo Borrero Gonzalez <arturo@netfilter.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/expression.c')
-rw-r--r--src/expression.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/expression.c b/src/expression.c
index f90ca603..d41ada39 100644
--- a/src/expression.c
+++ b/src/expression.c
@@ -824,9 +824,17 @@ static const struct expr_ops set_expr_ops = {
.destroy = compound_expr_destroy,
};
-struct expr *set_expr_alloc(const struct location *loc)
+struct expr *set_expr_alloc(const struct location *loc, const struct set *set)
{
- return compound_expr_alloc(loc, &set_expr_ops);
+ struct expr *set_expr = compound_expr_alloc(loc, &set_expr_ops);
+
+ if (!set)
+ return set_expr;
+
+ set_expr->set_flags = set->flags;
+ set_expr->dtype = set->keytype;
+
+ return set_expr;
}
static void mapping_expr_print(const struct expr *expr, struct output_ctx *octx)