From: Thomas Haller <thaller@redhat.com>
To: NetFilter <netfilter-devel@vger.kernel.org>
Cc: Thomas Haller <thaller@redhat.com>
Subject: [nft PATCH 4/4] libnftables: drop check for nf_sock in nft_ctx_free()
Date: Mon, 10 Jul 2023 10:45:19 +0200 [thread overview]
Message-ID: <20230710084926.172198-5-thaller@redhat.com> (raw)
In-Reply-To: <20230710084926.172198-1-thaller@redhat.com>
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>
---
src/libnftables.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/libnftables.c b/src/libnftables.c
index 79dfdfc7c6ec..6fc4f7db6760 100644
--- a/src/libnftables.c
+++ b/src/libnftables.c
@@ -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);
--
2.41.0
next prev parent reply other threads:[~2023-07-10 8:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-10 8:45 [nft PATCH 0/4] libnftables: minor cleanups initalizing nf_sock instance of nft_ctx Thomas Haller
2023-07-10 8:45 ` [nft PATCH 1/4] libnftables: always initialize netlink socket in nft_ctx_new() Thomas Haller
2023-07-10 8:45 ` [nft PATCH 2/4] libnftables: drop unused argument nf_sock from nft_netlink() Thomas Haller
2023-07-10 8:45 ` [nft PATCH 3/4] libnftables: inline creation of nf_sock in nft_ctx_new() Thomas Haller
2023-07-10 8:45 ` Thomas Haller [this message]
2023-07-10 16:22 ` [nft PATCH 0/4] libnftables: minor cleanups initalizing nf_sock instance of nft_ctx Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230710084926.172198-5-thaller@redhat.com \
--to=thaller@redhat.com \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).