From d34a6bacc6be36388a72350fe3c9e0d9ce81ac5a Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Wed, 6 Mar 2019 11:56:59 +0100 Subject: evaluate: misleading error reporting with sets and maps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When trying to list a map content, if set is used, nft reports: # nft list set filter group_7933 Error: No such file or directory; did you mean set ‘group_7933’ in table ip ‘filter’? list set filter group_7933 ^^^^^^^^^^ Which is confusing in case user wants to list an existing map: # nft list map filter group_7933 table ip filter { map group_7933 { type ipv4_addr : classid flags interval elements = { 10.4.22.0/24 : 1:c7cb } } } Instead, give a hint to user that probably wants to list a map, not a set: # nft list set filter group_7933 Error: No such file or directory; did you mean map ‘group_7933’ in table ip ‘filter’? list set filter group_7933 ^^^^^^^^^^ Fixes: 285bb67a11ad ("src: introduce simple hints on incorrect set") Signed-off-by: Pablo Neira Ayuso --- src/evaluate.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/evaluate.c') diff --git a/src/evaluate.c b/src/evaluate.c index 29c436cd..54afc334 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -209,10 +209,12 @@ static int set_not_found(struct eval_ctx *ctx, const struct location *loc, 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); + "%s; did you mean %s ‘%s’ in table %s ‘%s’?", + strerror(ENOENT), + set->flags & NFT_SET_MAP ? "map" : "set", + set->handle.set.name, + family2str(set->handle.family), + table->handle.table.name); } /* -- cgit v1.2.3