From 4d38878b39be44ea3d6a146a7dd678c269a9804a Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sun, 27 Nov 2016 23:34:53 +0100 Subject: src: add/create/delete stateful objects This patch allows you to add and to delete objects, eg. # nft add quota filter test 1234567 bytes # nft list quotas table ip filter { quota test { 1234567 bytes } } # nft delete quota filter test Signed-off-by: Pablo Neira Ayuso --- src/mnl.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/mnl.c') diff --git a/src/mnl.c b/src/mnl.c index 534d02f4..9458e21b 100644 --- a/src/mnl.c +++ b/src/mnl.c @@ -796,6 +796,36 @@ err: return NULL; } +int mnl_nft_obj_batch_add(struct nftnl_obj *nln, unsigned int flags, + uint32_t seqnum) +{ + struct nlmsghdr *nlh; + + nlh = nftnl_nlmsg_build_hdr(nftnl_batch_buffer(batch), + NFT_MSG_NEWOBJ, + nftnl_obj_get_u32(nln, NFTNL_OBJ_FAMILY), + NLM_F_CREATE | flags, seqnum); + nftnl_obj_nlmsg_build_payload(nlh, nln); + mnl_nft_batch_continue(); + + return 0; +} + +int mnl_nft_obj_batch_del(struct nftnl_obj *nln, unsigned int flags, + uint32_t seqnum) +{ + struct nlmsghdr *nlh; + + nlh = nftnl_nlmsg_build_hdr(nftnl_batch_buffer(batch), + NFT_MSG_DELOBJ, + nftnl_obj_get_u32(nln, NFTNL_OBJ_FAMILY), + flags, seqnum); + nftnl_obj_nlmsg_build_payload(nlh, nln); + mnl_nft_batch_continue(); + + return 0; +} + static int obj_cb(const struct nlmsghdr *nlh, void *data) { struct nftnl_obj_list *nln_list = data; -- cgit v1.2.3