table->handle.table.name);
}
+static int set_not_found(struct eval_ctx *ctx, const struct location *loc,
+ const char *set_name)
+{
+ const struct table *table;
+ struct set *set;
+
+ set = set_lookup_fuzzy(set_name, &ctx->nft->cache, &table);
+ if (set == NULL)
+ return cmd_error(ctx, loc, "%s", strerror(ENOENT));
+
+ return cmd_error(ctx, loc,
+ "%s; did you mean set ‘%s’ in table %s ‘%s’?",
+ strerror(ENOENT), set->handle.set.name,
+ family2str(set->handle.family),
+ table->handle.table.name);
+}
+
/*
* Symbol expression: parse symbol and evaluate resulting expression.
*/
set = set_lookup(table, (*expr)->identifier);
if (set == NULL)
- return expr_error(ctx->msgs, *expr,
- "Set '%s' does not exist",
- (*expr)->identifier);
+ return set_not_found(ctx, &(*expr)->location,
+ (*expr)->identifier);
new = set_ref_expr_alloc(&(*expr)->location, set);
break;
set = set_lookup(table, ctx->cmd->handle.set.name);
if (set == NULL)
- return cmd_error(ctx, &ctx->cmd->handle.set.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return set_not_found(ctx, &ctx->cmd->handle.set.location,
+ ctx->cmd->handle.set.name);
ctx->set = set;
expr_set_context(&ctx->ectx, set->key->dtype, set->key->len);
set = set_lookup(table, cmd->handle.set.name);
if (set == NULL || set->flags & (NFT_SET_MAP | NFT_SET_EVAL))
- return cmd_error(ctx, &ctx->cmd->handle.set.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return set_not_found(ctx, &ctx->cmd->handle.set.location,
+ ctx->cmd->handle.set.name);
return setelem_evaluate(ctx, &cmd->expr);
default:
set = set_lookup(table, cmd->handle.set.name);
if (set == NULL || set->flags & (NFT_SET_MAP | NFT_SET_EVAL))
- return cmd_error(ctx, &cmd->handle.set.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return set_not_found(ctx, &ctx->cmd->handle.set.location,
+ ctx->cmd->handle.set.name);
+
return 0;
case CMD_OBJ_METER:
table = table_lookup(&cmd->handle, &ctx->nft->cache);
set = set_lookup(table, cmd->handle.set.name);
if (set == NULL || !(set->flags & NFT_SET_EVAL))
- return cmd_error(ctx, &cmd->handle.set.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return set_not_found(ctx, &ctx->cmd->handle.set.location,
+ ctx->cmd->handle.set.name);
+
return 0;
case CMD_OBJ_MAP:
table = table_lookup(&cmd->handle, &ctx->nft->cache);
set = set_lookup(table, cmd->handle.set.name);
if (set == NULL || !(set->flags & NFT_SET_MAP))
- return cmd_error(ctx, &cmd->handle.set.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return set_not_found(ctx, &ctx->cmd->handle.set.location,
+ ctx->cmd->handle.set.name);
+
return 0;
case CMD_OBJ_CHAIN:
table = table_lookup(&cmd->handle, &ctx->nft->cache);
set = set_lookup(table, cmd->handle.set.name);
if (set == NULL || set->flags & (NFT_SET_MAP | NFT_SET_EVAL))
- return cmd_error(ctx, &cmd->handle.set.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return set_not_found(ctx, &ctx->cmd->handle.set.location,
+ ctx->cmd->handle.set.name);
+
return 0;
case CMD_OBJ_MAP:
ret = cache_update(ctx->nft, cmd->op, ctx->msgs);
set = set_lookup(table, cmd->handle.set.name);
if (set == NULL || !(set->flags & NFT_SET_MAP))
- return cmd_error(ctx, &ctx->cmd->handle.set.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return set_not_found(ctx, &ctx->cmd->handle.set.location,
+ ctx->cmd->handle.set.name);
+
return 0;
case CMD_OBJ_METER:
ret = cache_update(ctx->nft, cmd->op, ctx->msgs);
set = set_lookup(table, cmd->handle.set.name);
if (set == NULL || !(set->flags & NFT_SET_EVAL))
- return cmd_error(ctx, &ctx->cmd->handle.set.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return set_not_found(ctx, &ctx->cmd->handle.set.location,
+ ctx->cmd->handle.set.name);
+
return 0;
default:
BUG("invalid command object type %u\n", cmd->obj);