diff options
author | Florian Westphal <fw@strlen.de> | 2019-08-16 16:42:34 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2019-08-19 10:32:17 +0200 |
commit | 96afeddb2fe4f8c23677b92835e0aecf3c2945a6 (patch) | |
tree | ff7f47e25b65035895c355767df14c2c61d7d0b7 /src | |
parent | 7ff3e2b18305af07d322eef26111aa7ec4bde79d (diff) |
src: libnftnl: run single-initcalls only once
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/libnftables.c | 14 |
1 files changed, 9 insertions, 5 deletions
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); |