@@ -211,7 +211,7 @@ static int set_not_found(struct eval_ctx *ctx, const struct location *loc,
return cmd_error(ctx, loc,
"%s; did you mean %s ‘%s’ in table %s ‘%s’?",
strerror(ENOENT),
- set->flags & NFT_SET_MAP ? "map" : "set",
+ set_is_map(set->flags) ? "map" : "set",
set->handle.set.name,
family2str(set->handle.family),
table->handle.table.name);
@@ -3129,7 +3129,7 @@ static int set_evaluate(struct eval_ctx *ctx, struct set *set)
if (!(set->flags & NFT_SET_INTERVAL) && set->automerge)
return set_error(ctx, set, "auto-merge only works with interval sets");
- type = set->flags & NFT_SET_MAP ? "map" : "set";
+ type = set_is_map(set->flags) ? "map" : "set";
if (set->key == NULL)
return set_error(ctx, set, "%s definition does not specify key",
@@ -3560,7 +3560,7 @@ static int cmd_evaluate_get(struct eval_ctx *ctx, struct cmd *cmd)
return table_not_found(ctx);
set = set_lookup(table, cmd->handle.set.name);
- if (set == NULL || set->flags & NFT_SET_MAP)
+ if (set == NULL || set_is_map(set->flags))
return set_not_found(ctx, &ctx->cmd->handle.set.location,
ctx->cmd->handle.set.name);
@@ -1605,14 +1605,13 @@ static json_t *do_list_sets_json(struct netlink_ctx *ctx, struct cmd *cmd)
list_for_each_entry(set, &table->sets, list) {
if (cmd->obj == CMD_OBJ_SETS &&
- (set->flags & NFT_SET_ANONYMOUS ||
- set->flags & NFT_SET_MAP))
+ !set_is_literal(set->flags))
continue;
if (cmd->obj == CMD_OBJ_METERS &&
!(set->flags & NFT_SET_EVAL))
continue;
if (cmd->obj == CMD_OBJ_MAPS &&
- !(set->flags & NFT_SET_MAP))
+ !map_is_literal(set->flags))
continue;
json_array_append_new(root, set_print_json(octx, set));
}
@@ -1652,14 +1652,13 @@ static int do_list_sets(struct netlink_ctx *ctx, struct cmd *cmd)
list_for_each_entry(set, &table->sets, list) {
if (cmd->obj == CMD_OBJ_SETS &&
- (set->flags & NFT_SET_ANONYMOUS ||
- set->flags & NFT_SET_MAP))
+ !set_is_literal(set->flags))
continue;
if (cmd->obj == CMD_OBJ_METERS &&
!(set->flags & NFT_SET_EVAL))
continue;
if (cmd->obj == CMD_OBJ_MAPS &&
- !(set->flags & NFT_SET_MAP))
+ !map_is_literal(set->flags))
continue;
set_print_declaration(set, &opts, &ctx->nft->output);
nft_print(&ctx->nft->output, "%s}%s", opts.tab, opts.nl);
This is noticeable when displaying mispelling errors, however, there are also few spots not checking for the object map flag. Before: # nft flush set inet filter countermxx Error: No such file or directory; did you mean set ‘countermap’ in table inet ‘filter’? flush set inet filter countermxx ^^^^^^^^^^ After: # nft flush set inet filter countermxx Error: No such file or directory; did you mean map ‘countermap’ in table inet ‘filter’? flush set inet filter countermxx ^^^^^^^^^^ Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> --- src/evaluate.c | 6 +++--- src/json.c | 5 ++--- src/rule.c | 5 ++--- 3 files changed, 7 insertions(+), 9 deletions(-)