From e0146fa254496dc12187053cd0cd6e5d20eb6a43 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sat, 8 Jul 2017 05:07:23 +0530 Subject: include: Pass nf_sock where needed as parameter This socket should not be global, it is also hidden in many layers of code. Expose it as function parameters to decouple the netlink socket handling logic from the command parsing, evaluation and bytecode generation. Joint work with Varsha Rao. Signed-off-by: Varsha Rao Signed-off-by: Pablo Neira Ayuso --- include/netlink.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include/netlink.h') diff --git a/include/netlink.h b/include/netlink.h index bb25ad48..5b43c5c7 100644 --- a/include/netlink.h +++ b/include/netlink.h @@ -41,6 +41,7 @@ extern const struct location netlink_location; * @octx: output context */ struct netlink_ctx { + struct mnl_socket *nf_sock; struct list_head *msgs; struct list_head list; struct set *set; @@ -191,8 +192,8 @@ extern void netlink_dump_obj(struct nftnl_obj *nlo); extern int netlink_batch_send(struct netlink_ctx *ctx, struct list_head *err_list); -extern void netlink_genid_get(void); -extern void netlink_restart(void); +extern void netlink_genid_get(struct mnl_socket *nf_sock); +extern void netlink_restart(struct mnl_socket *nf_sock); #define netlink_abi_error() \ __netlink_abi_error(__FILE__, __LINE__, strerror(errno)); extern void __noreturn __netlink_abi_error(const char *file, int line, const char *reason); @@ -218,6 +219,6 @@ struct netlink_mon_handler { }; extern int netlink_monitor(struct netlink_mon_handler *monhandler); -bool netlink_batch_supported(void); +bool netlink_batch_supported(struct mnl_socket *nf_sock); #endif /* NFTABLES_NETLINK_H */ -- cgit v1.2.3