Skip to contentSkip to conversation

evaluate: misleading error reporting

PATCH In review Pablo Neira Ayuso 2 participants 2 messages Mar 6, 2019 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 evaluate: misleading error reporting

When trying to list a map content, if set is used, error reporting 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")
---
 src/evaluate.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
src/evaluate.c +6 -4
index 29c436cd3cff..54afc3340186 100644
@@ -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);
 }
 
 /*
Signature · 1 line
2.11.0
maintainer
#1 lore raw
Quoted 6 lines · Pablo Neira Ayuso

When trying to list a map content, if set is used, error reporting 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
                 ^^^^^^^^^^

Thanks for fixing this, I hit this myself too while looking at this bug report.