]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
libnftables: drop check for nf_sock in nft_ctx_free()
authorThomas Haller <thaller@redhat.com>
Mon, 10 Jul 2023 08:45:19 +0000 (10:45 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 10 Jul 2023 16:21:19 +0000 (18:21 +0200)
The "nft_ctx" API does not provide a way to change or reconnect the
netlink socket. And none of the users would rely on that.

Also note that nft_ctx_new() initializes nf_sock via
nft_mnl_socket_open(), which panics of the socket could not be
initialized.

This means, the check is unnecessary and needlessly confusing. Drop it.

Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/libnftables.c

index 79dfdfc7c6ecde4559d8d9794c64ca79f3cb8d7b..6fc4f7db676096784cbab8afa098b378bc4b89f9 100644 (file)
@@ -337,8 +337,7 @@ const char *nft_ctx_get_error_buffer(struct nft_ctx *ctx)
 EXPORT_SYMBOL(nft_ctx_free);
 void nft_ctx_free(struct nft_ctx *ctx)
 {
-       if (ctx->nf_sock)
-               mnl_socket_close(ctx->nf_sock);
+       mnl_socket_close(ctx->nf_sock);
 
        exit_cookie(&ctx->output.output_cookie);
        exit_cookie(&ctx->output.error_cookie);