diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2018-11-19 12:22:06 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2018-11-19 13:52:37 +0100 |
commit | 9f7817a4e0223c5e285a3f4a4dccbf1dafa7fc4e (patch) | |
tree | a5de2f735820df6eee1ef41b81b178ee6065ad44 /src/rule.c | |
parent | d7476ddd5f7de35cbc1b5b13d52733f788172ada (diff) |
src: introduce simple hints on incorrect chain
# nft list chain x y
Error: No such file or directory; did you mean chain ‘y’ in table inet ‘x’?
list chain x y
^
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/rule.c')
-rw-r--r-- | src/rule.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -762,6 +762,24 @@ struct chain *chain_lookup(const struct table *table, const struct handle *h) return NULL; } +struct chain *chain_lookup_fuzzy(const struct handle *h, + const struct nft_cache *cache, + const struct table **t) +{ + struct table *table; + struct chain *chain; + + list_for_each_entry(table, &cache->list, list) { + list_for_each_entry(chain, &table->chains, list) { + if (!strcmp(chain->handle.chain.name, h->chain.name)) { + *t = table; + return chain; + } + } + } + return NULL; +} + const char *family2str(unsigned int family) { switch (family) { |