return table;
}
+static int table_not_found(struct eval_ctx *ctx)
+{
+ struct table *table;
+
+ table = table_lookup_fuzzy(&ctx->cmd->handle, &ctx->nft->cache);
+ if (table == NULL)
+ return cmd_error(ctx, &ctx->cmd->handle.table.location,
+ "%s", strerror(ENOENT));
+
+ return cmd_error(ctx, &ctx->cmd->handle.table.location,
+ "%s; did you mean table ā%sā in family %s?",
+ strerror(ENOENT), table->handle.table.name,
+ family2str(table->handle.family));
+}
+
/*
* Symbol expression: parse symbol and evaluate resulting expression.
*/
table = table_lookup_global(ctx);
if (table == NULL)
- return cmd_error(ctx, &ctx->cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
set = set_lookup(table, (*expr)->identifier);
if (set == NULL)
return expr_error(ctx->msgs, *expr,
"Set '%s' does not exist",
(*expr)->identifier);
+
new = set_ref_expr_alloc(&(*expr)->location, set);
break;
}
table = table_lookup_global(ctx);
if (table == NULL)
- return cmd_error(ctx, &ctx->cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
set = set_lookup(table, ctx->cmd->handle.set.name);
if (set == NULL)
table = table_lookup_global(ctx);
if (table == NULL)
- return cmd_error(ctx, &ctx->cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
if (!(set->flags & NFT_SET_INTERVAL) && set->automerge)
return set_error(ctx, set, "auto-merge only works with interval sets");
table = table_lookup_global(ctx);
if (table == NULL)
- return cmd_error(ctx, &ctx->cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
ft->hooknum = str2hooknum(NFPROTO_NETDEV, ft->hookstr);
if (ft->hooknum == NF_INET_NUMHOOKS)
table = table_lookup(&rule->handle, &ctx->nft->cache);
if (!table)
- return cmd_error(ctx, &rule->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
chain = chain_lookup(table, &rule->handle);
if (!chain)
table = table_lookup_global(ctx);
if (table == NULL)
- return cmd_error(ctx, &ctx->cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
if (chain == NULL) {
if (chain_lookup(table, &ctx->cmd->handle) == NULL) {
case CMD_OBJ_SETELEM:
table = table_lookup(&cmd->handle, &ctx->nft->cache);
if (table == NULL)
- return cmd_error(ctx, &ctx->cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
+
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,
table = table_lookup(&cmd->handle, &ctx->nft->cache);
if (table == NULL)
- return cmd_error(ctx, &cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
+
if (obj_lookup(table, cmd->handle.obj.name, obj_type) == NULL)
return cmd_error(ctx, &cmd->handle.obj.location,
"Could not process rule: %s",
table = table_lookup(&cmd->handle, &ctx->nft->cache);
if (table == NULL)
- return cmd_error(ctx, &cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
+
return 0;
case CMD_OBJ_SET:
table = table_lookup(&cmd->handle, &ctx->nft->cache);
if (table == NULL)
- return cmd_error(ctx, &cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
+
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,
case CMD_OBJ_METER:
table = table_lookup(&cmd->handle, &ctx->nft->cache);
if (table == NULL)
- return cmd_error(ctx, &cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
+
set = set_lookup(table, cmd->handle.set.name);
if (set == NULL || !(set->flags & NFT_SET_EVAL))
return cmd_error(ctx, &cmd->handle.set.location,
case CMD_OBJ_MAP:
table = table_lookup(&cmd->handle, &ctx->nft->cache);
if (table == NULL)
- return cmd_error(ctx, &cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
+
set = set_lookup(table, cmd->handle.set.name);
if (set == NULL || !(set->flags & NFT_SET_MAP))
return cmd_error(ctx, &cmd->handle.set.location,
case CMD_OBJ_CHAIN:
table = table_lookup(&cmd->handle, &ctx->nft->cache);
if (table == NULL)
- return cmd_error(ctx, &cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
+
if (chain_lookup(table, &cmd->handle) == NULL)
return cmd_error(ctx, &cmd->handle.chain.location,
"Could not process rule: %s",
if (cmd->handle.table.name == NULL)
return 0;
if (table_lookup(&cmd->handle, &ctx->nft->cache) == NULL)
- return cmd_error(ctx, &cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
+
return 0;
case CMD_OBJ_CHAINS:
case CMD_OBJ_RULESET:
if (cmd->handle.table.name == NULL)
return 0;
if (table_lookup(&cmd->handle, &ctx->nft->cache) == NULL)
- return cmd_error(ctx, &cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
+
return 0;
default:
BUG("invalid command object type %u\n", cmd->obj);
table = table_lookup(&cmd->handle, &ctx->nft->cache);
if (table == NULL)
- return cmd_error(ctx, &cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
+
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,
table = table_lookup(&cmd->handle, &ctx->nft->cache);
if (table == NULL)
- return cmd_error(ctx, &ctx->cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
+
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,
table = table_lookup(&cmd->handle, &ctx->nft->cache);
if (table == NULL)
- return cmd_error(ctx, &ctx->cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
+
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,
table = table_lookup(&ctx->cmd->handle, &ctx->nft->cache);
if (table == NULL)
- return cmd_error(ctx, &ctx->cmd->handle.table.location,
- "Could not process rule: %s",
- strerror(ENOENT));
+ return table_not_found(ctx);
+
if (chain_lookup(table, &ctx->cmd->handle) == NULL)
return cmd_error(ctx, &ctx->cmd->handle.chain.location,
"Could not process rule: %s",