]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
mnl: Consolidate mnl_batch_talk() parameters
authorPhil Sutter <phil@nwl.cc>
Fri, 28 Jul 2017 11:55:45 +0000 (13:55 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 2 Aug 2017 13:03:31 +0000 (15:03 +0200)
The single caller of this function passes struct netlink_ctx fields as
the first two parameters. This can be simplified by passing the context
object itself and having mnl_batch_talk() access it's fields instead.

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

index 9f5b34f60d023283981e02919c8b180cd0777136..31dff2c2dd2cf48c7f9d084f53fb3ee221795aaf 100644 (file)
@@ -2,6 +2,7 @@
 #define _NFTABLES_MNL_H_
 
 #include <list.h>
+#include <netlink.h>
 
 struct mnl_socket;
 
@@ -24,8 +25,7 @@ bool mnl_batch_ready(struct nftnl_batch *batch);
 void mnl_batch_reset(struct nftnl_batch *batch);
 uint32_t mnl_batch_begin(struct nftnl_batch *batch);
 void mnl_batch_end(struct nftnl_batch *batch);
-int mnl_batch_talk(struct mnl_socket *nl, struct nftnl_batch *batch,
-                  struct list_head *err_list);
+int mnl_batch_talk(struct netlink_ctx *ctx, struct list_head *err_list);
 int mnl_nft_rule_batch_add(struct nftnl_rule *nlr, struct nftnl_batch *batch,
                           unsigned int flags, uint32_t seqnum);
 int mnl_nft_rule_batch_del(struct nftnl_rule *nlr, struct nftnl_batch *batch,
index 763931238150735409506f659ead6601565f4ded..862311a740e0e9d2df795ad1570961439c0cf60d 100644 (file)
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -246,9 +246,9 @@ static ssize_t mnl_nft_socket_sendmsg(const struct mnl_socket *nl,
        return sendmsg(mnl_socket_get_fd(nl), &msg, 0);
 }
 
-int mnl_batch_talk(struct mnl_socket *nl, struct nftnl_batch *batch,
-                  struct list_head *err_list)
+int mnl_batch_talk(struct netlink_ctx *ctx, struct list_head *err_list)
 {
+       struct mnl_socket *nl = ctx->nf_sock;
        int ret, fd = mnl_socket_get_fd(nl), portid = mnl_socket_get_portid(nl);
        char rcv_buf[MNL_SOCKET_BUFFER_SIZE];
        fd_set readfds;
@@ -257,7 +257,7 @@ int mnl_batch_talk(struct mnl_socket *nl, struct nftnl_batch *batch,
                .tv_usec        = 0
        };
 
-       ret = mnl_nft_socket_sendmsg(nl, batch);
+       ret = mnl_nft_socket_sendmsg(nl, ctx->batch);
        if (ret == -1)
                return -1;
 
index 9cef4c48f805a265637fcae286eb2c5cf4f2dc2a..b4386ad4ecf01e007abd21b131c91d0ac6a463fe 100644 (file)
@@ -1903,7 +1903,7 @@ int netlink_reset_objs(struct netlink_ctx *ctx, const struct handle *h,
 
 int netlink_batch_send(struct netlink_ctx *ctx, struct list_head *err_list)
 {
-       return mnl_batch_talk(ctx->nf_sock, ctx->batch, err_list);
+       return mnl_batch_talk(ctx, err_list);
 }
 
 int netlink_flush_ruleset(struct netlink_ctx *ctx, const struct handle *h,