From 19cd540390e32f2e1f62e205ddb691d1e6e06152 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Wed, 12 Jul 2017 14:14:16 +0200 Subject: 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 Fixes: a9dc3ceabc10f ("expression: print sets and maps in pretty format") Signed-off-by: Phil Sutter Acked-by: Arturo Borrero Gonzalez Signed-off-by: Pablo Neira Ayuso --- src/netlink.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/netlink.c') diff --git a/src/netlink.c b/src/netlink.c index 7355036b..e3c90dac 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -1734,10 +1734,8 @@ int netlink_get_setelems(struct netlink_ctx *ctx, const struct handle *h, } ctx->set = set; - set->init = set_expr_alloc(loc); + set->init = set_expr_alloc(loc, set); nftnl_set_elem_foreach(nls, list_setelem_cb, ctx); - set->init->set_flags = set->flags; - set->init->dtype = set->keytype; if (!(set->flags & NFT_SET_INTERVAL)) list_expr_sort(&ctx->set->init->expressions); @@ -2234,7 +2232,7 @@ static int netlink_events_setelem_cb(const struct nlmsghdr *nlh, int type, dummyset = set_alloc(monh->loc); dummyset->keytype = set->keytype; dummyset->datatype = set->datatype; - dummyset->init = set_expr_alloc(monh->loc); + dummyset->init = set_expr_alloc(monh->loc, set); nlsei = nftnl_set_elems_iter_create(nls); if (nlsei == NULL) @@ -2432,7 +2430,7 @@ static void netlink_events_cache_addset(struct netlink_mon_handler *monh, s = netlink_delinearize_set(&set_tmpctx, nls); if (s == NULL) goto out; - s->init = set_expr_alloc(monh->loc); + s->init = set_expr_alloc(monh->loc, s); t = table_lookup(&s->handle); if (t == NULL) { -- cgit v1.2.3