From d545778d5933ab20c1d9d34a44ae93b2668c60d2 Mon Sep 17 00:00:00 2001 From: Elise Lennion Date: Thu, 26 Jan 2017 15:09:44 -0200 Subject: src: Allow reset single stateful object Currently the stateful objects can only be reseted in groups. With this patch reseting a single object is allowed: $ nft reset counter filter https-traffic table ip filter { counter https-traffic { packets 8774 bytes 542668 } } $ nft list counter filter https-traffic table ip filter { counter https-traffic { packets 0 bytes 0 } } Heavily based on work from Pablo Neira Ayuso . Signed-off-by: Elise Lennion Signed-off-by: Pablo Neira Ayuso --- src/netlink.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/netlink.c') diff --git a/src/netlink.c b/src/netlink.c index 73ee5c97..0cc3a517 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -1775,8 +1775,8 @@ int netlink_list_objs(struct netlink_ctx *ctx, const struct handle *h, struct nftnl_obj_list *obj_cache; int err; - obj_cache = mnl_nft_obj_dump(nf_sock, h->family, h->table, - NFT_OBJECT_UNSPEC, false); + obj_cache = mnl_nft_obj_dump(nf_sock, h->family, h->table, NULL, + 0, true, false); if (obj_cache == NULL) { if (errno == EINTR) return -1; @@ -1790,12 +1790,13 @@ int netlink_list_objs(struct netlink_ctx *ctx, const struct handle *h, } int netlink_reset_objs(struct netlink_ctx *ctx, const struct handle *h, - const struct location *loc, uint32_t type) + const struct location *loc, uint32_t type, bool dump) { struct nftnl_obj_list *obj_cache; int err; - obj_cache = mnl_nft_obj_dump(nf_sock, h->family, h->table, type, true); + obj_cache = mnl_nft_obj_dump(nf_sock, h->family, h->table, h->obj, + type, dump, true); if (obj_cache == NULL) { if (errno == EINTR) return -1; -- cgit v1.2.3