]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: use set_is_anonymous()
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 15 Jul 2019 17:42:07 +0000 (19:42 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 16 Jul 2019 17:53:43 +0000 (19:53 +0200)
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/evaluate.c
src/expression.c
src/json.c
src/monitor.c
src/parser_json.c
src/rule.c
src/segtree.c

index f915187165ccf13ee663733421c06b75f0be7e12..e35291d28b6a972e5421cc401d0c28912d664c9f 100644 (file)
@@ -1642,7 +1642,7 @@ static int __binop_transfer(struct eval_ctx *ctx,
                }
                break;
        case EXPR_SET_REF:
-               if (!((*right)->set->flags & NFT_SET_ANONYMOUS))
+               if (!set_is_anonymous((*right)->set->flags))
                        return 0;
 
                return __binop_transfer(ctx, left, &(*right)->set->init);
index 5d0b4f82cae4638545071bfb690b35a5f07d9210..cb49e0b73f5a3ad494257b29a84ab42a804b7057 100644 (file)
@@ -851,7 +851,7 @@ static const char *calculate_delim(const struct expr *expr, int *count)
        const char *newline = ",\n\t\t\t     ";
        const char *singleline = ", ";
 
-       if (expr->set_flags & NFT_SET_ANONYMOUS)
+       if (set_is_anonymous(expr->set_flags))
                return singleline;
 
        if (!expr->dtype)
@@ -1035,7 +1035,7 @@ struct expr *map_expr_alloc(const struct location *loc, struct expr *arg,
 
 static void set_ref_expr_print(const struct expr *expr, struct output_ctx *octx)
 {
-       if (expr->set->flags & NFT_SET_ANONYMOUS) {
+       if (set_is_anonymous(expr->set->flags)) {
                if (expr->set->flags & NFT_SET_EVAL)
                        nft_print(octx, "%s", expr->set->handle.set.name);
                else
index f40dc51883b78b2e82c2435bca99c17fbc79dd5a..b21677efea9184152bad0ef99cba207764261669 100644 (file)
@@ -522,7 +522,7 @@ json_t *set_expr_json(const struct expr *expr, struct output_ctx *octx)
 
 json_t *set_ref_expr_json(const struct expr *expr, struct output_ctx *octx)
 {
-       if (expr->set->flags & NFT_SET_ANONYMOUS) {
+       if (set_is_anonymous(expr->set->flags)) {
                return expr_print_json(expr->set->init, octx);
        } else {
                return json_pack("s+", "@", expr->set->handle.set.name);
@@ -1473,7 +1473,7 @@ static json_t *table_print_json_full(struct netlink_ctx *ctx,
                json_array_append_new(root, tmp);
        }
        list_for_each_entry(set, &table->sets, list) {
-               if (set->flags & NFT_SET_ANONYMOUS)
+               if (set_is_anonymous(set->flags))
                        continue;
                tmp = set_print_json(&ctx->nft->output, set);
                json_array_append_new(root, tmp);
index 5b25c9d4854e7a3b29334cf955ff180f5cd4a4bb..40c381149cdaae9e89c2fde10d1f9e9ef5df9b77 100644 (file)
@@ -275,7 +275,7 @@ static int netlink_events_set_cb(const struct nlmsghdr *nlh, int type,
 
        nls = netlink_set_alloc(nlh);
        flags = nftnl_set_get_u32(nls, NFTNL_SET_FLAGS);
-       if (flags & NFT_SET_ANONYMOUS)
+       if (set_is_anonymous(flags))
                goto out;
 
        set = netlink_delinearize_set(monh->ctx, nls);
@@ -392,7 +392,7 @@ static int netlink_events_setelem_cb(const struct nlmsghdr *nlh, int type,
                goto out;
        }
 
-       if (set->flags & NFT_SET_ANONYMOUS)
+       if (set_is_anonymous(set->flags))
                goto out;
 
        /* we want to 'delinearize' the set_elem, but don't
index f701ebdf18581cfb3c40cd4c45c68809c160e04e..9add6f88d09ed2bc8c51135f1aba003e44c6c0cd 100644 (file)
@@ -3598,7 +3598,7 @@ static uint64_t handle_from_nlmsg(const struct nlmsghdr *nlh)
        case NFT_MSG_NEWSET:
                nls = netlink_set_alloc(nlh);
                flags = nftnl_set_get_u32(nls, NFTNL_SET_FLAGS);
-               if (!(flags & NFT_SET_ANONYMOUS))
+               if (!set_is_anonymous(flags))
                        handle = nftnl_set_get_u64(nls, NFTNL_SET_HANDLE);
                nftnl_set_free(nls);
                break;
index e04fc09b0a5b07d4e6a0be1a0650b97d04585da2..52d8181f0d9238aa17f57a85c92df76a5c01ed25 100644 (file)
@@ -388,7 +388,7 @@ struct set *set_lookup_fuzzy(const char *set_name,
 
        list_for_each_entry(table, &cache->list, list) {
                list_for_each_entry(set, &table->sets, list) {
-                       if (set->flags & NFT_SET_ANONYMOUS)
+                       if (set_is_anonymous(set->flags))
                                continue;
                        if (!strcmp(set->handle.set.name, set_name)) {
                                *t = table;
@@ -1272,7 +1272,7 @@ static void table_print(const struct table *table, struct output_ctx *octx)
                delim = "\n";
        }
        list_for_each_entry(set, &table->sets, list) {
-               if (set->flags & NFT_SET_ANONYMOUS)
+               if (set_is_anonymous(set->flags))
                        continue;
                nft_print(octx, "%s", delim);
                set_print(set, octx);
index a21270a08c46c8af042c9285d9a063b3870b1af2..eff0653a8dfb966633912e7eb553b031b40ccb5a 100644 (file)
@@ -440,7 +440,7 @@ static bool segtree_needs_first_segment(const struct set *set,
                 * 3) New empty set and, separately, new elements are added.
                 * 4) This set is created with a number of initial elements.
                 */
-               if ((set->flags & NFT_SET_ANONYMOUS) ||
+               if ((set_is_anonymous(set->flags)) ||
                    (set->init && set->init->size == 0) ||
                    (set->init == NULL && init) ||
                    (set->init == init)) {