summaryrefslogtreecommitdiffstats
path: root/src/netlink.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2016-12-05 22:45:22 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2016-12-05 22:50:46 +0100
commit23b760a774cf12dd18fb68a84d502662ae6eebd8 (patch)
tree243a95e6647ab44bcf1815e15ff229823257aaa9 /src/netlink.c
parent1d398465831066c5e98fb2a58d7aa0547595de33 (diff)
src: add support to flush sets
You can use this new command to remove all existing elements in a set: # nft flush set filter xyz After this command, the set 'xyz' in table 'filter' becomes empty. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/netlink.c')
-rw-r--r--src/netlink.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/netlink.c b/src/netlink.c
index f8e600ff..714df4e8 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -1374,7 +1374,8 @@ static int netlink_del_setelems_batch(struct netlink_ctx *ctx,
int err;
nls = alloc_nftnl_set(h);
- alloc_setelem_cache(expr, nls);
+ if (expr)
+ alloc_setelem_cache(expr, nls);
netlink_dump_set(nls);
err = mnl_nft_setelem_batch_del(nls, 0, ctx->seqnum);
@@ -1406,6 +1407,12 @@ static int netlink_del_setelems_compat(struct netlink_ctx *ctx,
return err;
}
+int netlink_flush_setelems(struct netlink_ctx *ctx, const struct handle *h,
+ const struct location *loc)
+{
+ return netlink_del_setelems_batch(ctx, h, NULL);
+}
+
static struct expr *netlink_parse_concat_elem(const struct datatype *dtype,
struct expr *data)
{