summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libnftables.c14
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);