]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: simplify netlink_get_setelems() and rename it to netlink_list_setelems()
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 23 Apr 2018 23:21:32 +0000 (01:21 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 23 Apr 2018 23:30:09 +0000 (01:30 +0200)
This is called from cache population path, remove netlink_io_error()
call since this is not needed. Rename it for consistency with similar
netlink_list_*() NLM_F_DUMP functions. Get rid of location parameter.

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

index 92bae138bf919d612befc56af88c7d78d518f6ef..d153e2be03ac5d0fa2c19f845261491ae597cc5d 100644 (file)
@@ -156,8 +156,8 @@ extern int netlink_add_setelems_batch(struct netlink_ctx *ctx, const struct hand
                                const struct expr *expr, uint32_t flags);
 extern int netlink_delete_setelems_batch(struct netlink_ctx *ctx,
                                         const struct cmd *cmd);
-extern int netlink_get_setelems(struct netlink_ctx *ctx, const struct handle *h,
-                               const struct location *loc, struct set *set);
+extern int netlink_list_setelems(struct netlink_ctx *ctx,
+                                const struct handle *h, struct set *set);
 extern int netlink_get_setelem(struct netlink_ctx *ctx, const struct handle *h,
                               const struct location *loc, struct table *table,
                               struct set *set, struct expr *init);
index 9e11af5d026f9afbbc0fb560239940deb826836b..372caaa963ca5c634aada7b0ba2fc819c01aef43 100644 (file)
@@ -1294,8 +1294,8 @@ static int list_setelem_cb(struct nftnl_set_elem *nlse, void *arg)
        return netlink_delinearize_setelem(nlse, ctx->set, ctx->cache);
 }
 
-int netlink_get_setelems(struct netlink_ctx *ctx, const struct handle *h,
-                        const struct location *loc, struct set *set)
+int netlink_list_setelems(struct netlink_ctx *ctx, const struct handle *h,
+                         struct set *set)
 {
        struct nftnl_set *nls;
        int err;
@@ -1308,11 +1308,11 @@ int netlink_get_setelems(struct netlink_ctx *ctx, const struct handle *h,
                if (errno == EINTR)
                        return -1;
 
-               goto out;
+               return 0;
        }
 
        ctx->set = set;
-       set->init = set_expr_alloc(loc, set);
+       set->init = set_expr_alloc(&internal_location, set);
        nftnl_set_elem_foreach(nls, list_setelem_cb, ctx);
 
        if (!(set->flags & NFT_SET_INTERVAL))
@@ -1323,11 +1323,8 @@ int netlink_get_setelems(struct netlink_ctx *ctx, const struct handle *h,
 
        if (set->flags & NFT_SET_INTERVAL)
                interval_map_decompose(set->init);
-out:
-       if (err < 0)
-               netlink_io_error(ctx, loc, "Could not receive set elements: %s",
-                                strerror(errno));
-       return err;
+
+       return 0;
 }
 
 int netlink_get_setelem(struct netlink_ctx *ctx, const struct handle *h,
index 2ad7f23ef02da96aac87a8c0b37bb103136700bb..1f69afd1d6c98c61a33c46d04d15256b6517f914 100644 (file)
@@ -84,8 +84,7 @@ static int cache_init_objects(struct netlink_ctx *ctx, enum cmd_ops cmd)
                        return -1;
 
                list_for_each_entry(set, &table->sets, list) {
-                       ret = netlink_get_setelems(ctx, &set->handle,
-                                                  &internal_location, set);
+                       ret = netlink_list_setelems(ctx, &set->handle, set);
                        if (ret < 0)
                                return -1;
                }