diff options
Diffstat (limited to 'src/mnl.c')
-rw-r--r-- | src/mnl.c | 64 |
1 files changed, 0 insertions, 64 deletions
@@ -1196,67 +1196,3 @@ int mnl_nft_event_listener(struct mnl_socket *nf_sock, unsigned int debug_mask, } return ret; } - -static void nft_mnl_batch_put(char *buf, uint16_t type, uint32_t seqnum) -{ - struct nlmsghdr *nlh; - struct nfgenmsg *nfg; - - nlh = mnl_nlmsg_put_header(buf); - nlh->nlmsg_type = type; - nlh->nlmsg_flags = NLM_F_REQUEST; - nlh->nlmsg_seq = seqnum; - - nfg = mnl_nlmsg_put_extra_header(nlh, sizeof(*nfg)); - nfg->nfgen_family = AF_INET; - nfg->version = NFNETLINK_V0; - nfg->res_id = NFNL_SUBSYS_NFTABLES; -} - -bool mnl_batch_supported(struct mnl_socket *nf_sock, uint32_t *seqnum) -{ - struct mnl_nlmsg_batch *b; - char buf[MNL_SOCKET_BUFFER_SIZE]; - int ret; - - b = mnl_nlmsg_batch_start(buf, sizeof(buf)); - - nft_mnl_batch_put(mnl_nlmsg_batch_current(b), NFNL_MSG_BATCH_BEGIN, - mnl_seqnum_alloc(seqnum)); - mnl_nlmsg_batch_next(b); - - nftnl_nlmsg_build_hdr(mnl_nlmsg_batch_current(b), NFT_MSG_NEWSET, - AF_INET, NLM_F_ACK, mnl_seqnum_alloc(seqnum)); - mnl_nlmsg_batch_next(b); - - nft_mnl_batch_put(mnl_nlmsg_batch_current(b), NFNL_MSG_BATCH_END, - mnl_seqnum_alloc(seqnum)); - mnl_nlmsg_batch_next(b); - - ret = mnl_socket_sendto(nf_sock, mnl_nlmsg_batch_head(b), - mnl_nlmsg_batch_size(b)); - if (ret < 0) - goto err; - - mnl_nlmsg_batch_stop(b); - - ret = mnl_socket_recvfrom(nf_sock, buf, sizeof(buf)); - while (ret > 0) { - ret = mnl_cb_run(buf, ret, 0, mnl_socket_get_portid(nf_sock), - NULL, NULL); - if (ret <= 0) - break; - - ret = mnl_socket_recvfrom(nf_sock, buf, sizeof(buf)); - } - - /* We're sending an incomplete message to see if the kernel supports - * set messages in batches. EINVAL means that we sent an incomplete - * message with missing attributes. The kernel just ignores messages - * that we cannot include in the batch. - */ - return (ret == -1 && errno == EINVAL) ? true : false; -err: - mnl_nlmsg_batch_stop(b); - return ret; -} |