]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
mnl: Drop --echo support for non-batch calls
authorPhil Sutter <phil@nwl.cc>
Mon, 14 Aug 2017 23:43:02 +0000 (01:43 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 15 Aug 2017 10:26:36 +0000 (12:26 +0200)
Echo support in nft_mnl_talk() was broken: nft_mnl_talk_cb() passed
cbdata->data as second parameter to netlink_echo_callback() which
expected it to be of type struct netlink_ctx while in fact it was
whatever callers of nft_mnl_talk() passed as callback data (in most
cases a NULL pointer).

I didn't notice this because I didn't test for kernels without support
for transactions. This has been added to nftables in kernel version 3.16
back in 2014. Since then, user space which doesn't support it can't even
add a table anymore. So adding this new feature to the old code path is
really not feasible, therefore drop this broken attempt at supporting
it.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/mnl.c

index 031b7f39da8f5ae5a11eb12b8a522467bb7a2562..5017b81c96e7c7384cb279412b7579dea0caff71 100644 (file)
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -67,32 +67,11 @@ out:
        return ret;
 }
 
-struct nft_mnl_talk_cb_data {
-       int (*cb)(const struct nlmsghdr *nlh, void *data);
-       void *data;
-};
-
-static int nft_mnl_talk_cb(const struct nlmsghdr *nlh, void *data)
-{
-       struct nft_mnl_talk_cb_data *cbdata = data;
-       int rc;
-
-       if (cbdata->cb)
-               rc = cbdata->cb(nlh, cbdata->data);
-       if (rc)
-               return rc;
-       return netlink_echo_callback(nlh, cbdata->data);
-}
-
 static int
 nft_mnl_talk(struct mnl_socket *nf_sock, const void *data, unsigned int len,
             int (*cb)(const struct nlmsghdr *nlh, void *data), void *cb_data)
 {
        uint32_t portid = mnl_socket_get_portid(nf_sock);
-       struct nft_mnl_talk_cb_data tcb_data = {
-               .cb = cb,
-               .data = cb_data,
-       };
 
 #ifdef DEBUG
        if (debug_level & DEBUG_MNL)
@@ -102,7 +81,7 @@ nft_mnl_talk(struct mnl_socket *nf_sock, const void *data, unsigned int len,
        if (mnl_socket_sendto(nf_sock, data, len) < 0)
                return -1;
 
-       return nft_mnl_recv(nf_sock, seq, portid, &nft_mnl_talk_cb, &tcb_data);
+       return nft_mnl_recv(nf_sock, seq, portid, cb, cb_data);
 }
 
 /*