diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2014-05-19 12:21:46 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2014-05-19 12:21:48 +0200 |
commit | 15cd2494198fa64cfcdf26298e0809cf14fafbbb (patch) | |
tree | 11dd1b5edec9cc82a3311cbf6c80e3fbaf2f6270 /src/mnl.c | |
parent | dda742096bdf19d6993da0412bd3f48f2fd463fd (diff) |
src: add table netlink messages to the batch
This patch moves the table messages to the netlink batch that
is sent to kernel-space.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/mnl.c')
-rw-r--r-- | src/mnl.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -550,6 +550,23 @@ int mnl_nft_table_add(struct mnl_socket *nf_sock, struct nft_table *nlt, return nft_mnl_talk(nf_sock, nlh, nlh->nlmsg_len, NULL, NULL); } +int mnl_nft_table_batch_add(struct mnl_socket *nf_sock, struct nft_table *nlt, + unsigned int flags, uint32_t seqnum) +{ + struct nlmsghdr *nlh; + + nlh = nft_table_nlmsg_build_hdr(mnl_nlmsg_batch_current(batch), + NFT_MSG_NEWTABLE, + nft_table_attr_get_u32(nlt, NFT_TABLE_ATTR_FAMILY), + flags, seqnum); + nft_table_nlmsg_build_payload(nlh, nlt); + + if (!mnl_nlmsg_batch_next(batch)) + mnl_batch_page_add(); + + return 0; +} + int mnl_nft_table_delete(struct mnl_socket *nf_sock, struct nft_table *nlt, unsigned int flags) { @@ -564,6 +581,23 @@ int mnl_nft_table_delete(struct mnl_socket *nf_sock, struct nft_table *nlt, return nft_mnl_talk(nf_sock, nlh, nlh->nlmsg_len, NULL, NULL); } +int mnl_nft_table_batch_del(struct mnl_socket *nf_sock, struct nft_table *nlt, + unsigned int flags, uint32_t seqnum) +{ + struct nlmsghdr *nlh; + + nlh = nft_table_nlmsg_build_hdr(mnl_nlmsg_batch_current(batch), + NFT_MSG_DELTABLE, + nft_table_attr_get_u32(nlt, NFT_TABLE_ATTR_FAMILY), + NLM_F_ACK, seqnum); + nft_table_nlmsg_build_payload(nlh, nlt); + + if (!mnl_nlmsg_batch_next(batch)) + mnl_batch_page_add(); + + return 0; +} + static int table_cb(const struct nlmsghdr *nlh, void *data) { struct nft_table_list *nlt_list = data; |