diff mbox series

[nft,1/4] libnftables: always initialize netlink socket in nft_ctx_new()

Message ID 20230710084926.172198-2-thaller@redhat.com
State Accepted
Delegated to: Pablo Neira
Headers show
Series libnftables: minor cleanups initalizing nf_sock instance of nft_ctx | expand

Commit Message

Thomas Haller July 10, 2023, 8:45 a.m. UTC
nft_ctx_new() has a flags argument, but currently no flags are
supported. The documentation suggests to pass 0 (NFT_CTX_DEFAULT).

Initializing the netlink socket happens by default already, we should do
it for all flags. Also because  nft_ctx_netlink_init() is not public
API so it's not clear how the user gets a functioning context instance
otherwise.

If we ever want to not initialize the netlink socket for a context
instance, then there should be a dedicated flag for doing that (and
additional API for making that mode of operation usable).

Signed-off-by: Thomas Haller <thaller@redhat.com>
---
 src/libnftables.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/libnftables.c b/src/libnftables.c
index de16d203a017..57e0fc77f989 100644
--- a/src/libnftables.c
+++ b/src/libnftables.c
@@ -219,8 +219,7 @@  struct nft_ctx *nft_ctx_new(uint32_t flags)
 	ctx->output.error_fp = stderr;
 	init_list_head(&ctx->vars_ctx.indesc_list);
 
-	if (flags == NFT_CTX_DEFAULT)
-		nft_ctx_netlink_init(ctx);
+	nft_ctx_netlink_init(ctx);
 
 	return ctx;
 }