]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
mnl: update mnl_nft_setelem_del() to allow for more reuse
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 13 Apr 2022 02:01:16 +0000 (04:01 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 13 Apr 2022 11:43:53 +0000 (13:43 +0200)
Pass handle and element list as parameters to allow for code reuse.

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

index a4abe1ae3242e28d54b95e2b16de10b145de8907..4c701d4ee6dc1c2d7b67919b76e5cc0b115c4beb 100644 (file)
@@ -62,7 +62,8 @@ struct nftnl_set_list *mnl_nft_set_dump(struct netlink_ctx *ctx, int family,
 
 int mnl_nft_setelem_add(struct netlink_ctx *ctx, const struct set *set,
                        const struct expr *expr, unsigned int flags);
-int mnl_nft_setelem_del(struct netlink_ctx *ctx, const struct cmd *cmd);
+int mnl_nft_setelem_del(struct netlink_ctx *ctx, const struct handle *h,
+                       const struct expr *init);
 int mnl_nft_setelem_flush(struct netlink_ctx *ctx, const struct cmd *cmd);
 int mnl_nft_setelem_get(struct netlink_ctx *ctx, struct nftnl_set *nls);
 struct nftnl_set *mnl_nft_setelem_get_one(struct netlink_ctx *ctx,
index e83e0a16b4913d6b7cae5e9528074be25177050e..7dd77be1bec0b688e33a3e4f14bcec3e19acb580 100644 (file)
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -1728,9 +1728,9 @@ int mnl_nft_setelem_flush(struct netlink_ctx *ctx, const struct cmd *cmd)
        return 0;
 }
 
-int mnl_nft_setelem_del(struct netlink_ctx *ctx, const struct cmd *cmd)
+int mnl_nft_setelem_del(struct netlink_ctx *ctx, const struct handle *h,
+                       const struct expr *init)
 {
-       const struct handle *h = &cmd->handle;
        struct nftnl_set *nls;
        int err;
 
@@ -1748,7 +1748,7 @@ int mnl_nft_setelem_del(struct netlink_ctx *ctx, const struct cmd *cmd)
        netlink_dump_set(nls, ctx);
 
        err = mnl_nft_setelem_batch(nls, ctx->batch, NFT_MSG_DELSETELEM, 0,
-                                   ctx->seqnum, cmd->expr, ctx);
+                                   ctx->seqnum, init, ctx);
        nftnl_set_free(nls);
 
        return err;
index 89f1304b82225ceeaf3857266c914a6f55ef87fd..44e1febf0793a82e227ac930410568ac00965ec5 100644 (file)
@@ -1601,7 +1601,7 @@ static int do_delete_setelems(struct netlink_ctx *ctx, struct cmd *cmd)
            set_to_intervals(set, expr, false) < 0)
                return -1;
 
-       if (mnl_nft_setelem_del(ctx, cmd) < 0)
+       if (mnl_nft_setelem_del(ctx, &cmd->handle, cmd->elem.expr) < 0)
                return -1;
 
        return 0;