From 96afeddb2fe4f8c23677b92835e0aecf3c2945a6 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Fri, 16 Aug 2019 16:42:34 +0200 Subject: src: libnftnl: run single-initcalls only once Signed-off-by: Florian Westphal --- src/libnftables.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/libnftables.c b/src/libnftables.c index a693c0c6..b169dd2f 100644 --- a/src/libnftables.c +++ b/src/libnftables.c @@ -90,11 +90,6 @@ static void nft_init(struct nft_ctx *ctx) realm_table_rt_init(ctx); devgroup_table_init(ctx); ct_label_table_init(ctx); - - gmp_init(); -#ifdef HAVE_LIBXTABLES - xt_init(); -#endif } static void nft_exit(struct nft_ctx *ctx) @@ -142,8 +137,17 @@ static void nft_ctx_netlink_init(struct nft_ctx *ctx) EXPORT_SYMBOL(nft_ctx_new); struct nft_ctx *nft_ctx_new(uint32_t flags) { + static bool init_once; struct nft_ctx *ctx; + if (!init_once) { + init_once = true; + gmp_init(); +#ifdef HAVE_LIBXTABLES + xt_init(); +#endif + } + ctx = xzalloc(sizeof(struct nft_ctx)); nft_init(ctx); -- cgit v1.2.3