]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: call nft_init() and nft_exit() from context routines
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 24 Aug 2017 15:56:38 +0000 (17:56 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 24 Aug 2017 17:27:51 +0000 (19:27 +0200)
So we don't forget all these caches should be placed into struct
nft_ctx.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/nftables.h
src/main.c

index b55e144021870d5033b7f267bcef14330e7b14ea..256b06ee33fc41b70d88abee771ccf7bc0208fec 100644 (file)
@@ -135,13 +135,11 @@ void realm_table_rt_init(void);
 void devgroup_table_init(void);
 void realm_table_meta_init(void);
 void xt_init(void);
-void nft_init(void);
 
 void ct_label_table_exit(void);
 void mark_table_exit(void);
 void realm_table_meta_exit(void);
 void devgroup_table_exit(void);
 void realm_table_rt_exit(void);
-void nft_exit(void);
 
 #endif /* NFTABLES_NFTABLES_H */
index 1df53adb6553360397ee9d8e2c3a542e98fd7ceb..eecd430a2e3fe81371aa02bd6ae66bd4d430490e 100644 (file)
@@ -259,7 +259,7 @@ err1:
        return ret;
 }
 
-void nft_init(void)
+static void nft_init(void)
 {
        mark_table_init();
        realm_table_rt_init();
@@ -272,7 +272,7 @@ void nft_init(void)
 #endif
 }
 
-void nft_exit(void)
+static void nft_exit(void)
 {
        ct_label_table_exit();
        realm_table_rt_exit();
@@ -285,6 +285,7 @@ static struct nft_ctx *nft_ctx_new(void)
 {
        struct nft_ctx *ctx;
 
+       nft_init();
        ctx = xzalloc(sizeof(struct nft_ctx));
 
        ctx->include_paths[0]   = DEFAULT_INCLUDE_PATH;
@@ -300,6 +301,7 @@ static void nft_ctx_free(const struct nft_ctx *ctx)
        iface_cache_release();
        cache_release(&nft->cache);
        xfree(ctx);
+       nft_exit();
 }
 
 static int nft_run_cmd_from_buffer(struct nft_ctx *nft,
@@ -361,8 +363,6 @@ int main(int argc, char * const *argv)
        struct parser_state state;
        int i, val, rc;
 
-       nft_init();
-
        nft = nft_ctx_new();
 
        nf_sock = netlink_open_sock();
@@ -478,7 +478,6 @@ int main(int argc, char * const *argv)
        xfree(buf);
        netlink_close_sock(nf_sock);
        nft_ctx_free(nft);
-       nft_exit();
 
        return rc;
 }