netfilter: nf_tables: prefer nft_trans_elem_alloc helper
authorFlorian Westphal <fw@strlen.de>
Tue, 23 Jul 2024 13:08:16 +0000 (15:08 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 15 Oct 2024 15:29:51 +0000 (17:29 +0200)
Reduce references to sizeof(struct nft_trans_elem).
Preparation patch to move this to a flexiable array to store
elem references.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c

index 6552ec6167456b21f39a9abe2d4e1141edd2d81e..30331688301e7d75027f6f6a63430173a95e4a24 100644 (file)
@@ -6409,7 +6409,7 @@ err:
        nfnetlink_set_err(net, portid, NFNLGRP_NFTABLES, -ENOBUFS);
 }
 
-static struct nft_trans *nft_trans_elem_alloc(struct nft_ctx *ctx,
+static struct nft_trans *nft_trans_elem_alloc(const struct nft_ctx *ctx,
                                              int msg_type,
                                              struct nft_set *set)
 {
@@ -7471,13 +7471,11 @@ static int __nft_set_catchall_flush(const struct nft_ctx *ctx,
 {
        struct nft_trans *trans;
 
-       trans = nft_trans_alloc_gfp(ctx, NFT_MSG_DELSETELEM,
-                                   sizeof(struct nft_trans_elem), GFP_KERNEL);
+       trans = nft_trans_elem_alloc(ctx, NFT_MSG_DELSETELEM, set);
        if (!trans)
                return -ENOMEM;
 
        nft_setelem_data_deactivate(ctx->net, set, elem_priv);
-       nft_trans_elem_set(trans) = set;
        nft_trans_elem_priv(trans) = elem_priv;
        nft_trans_commit_list_add_tail(ctx->net, trans);