diff options
author | Eric Jallot <ejallot@gmail.com> | 2019-10-30 18:06:19 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2019-10-31 14:16:42 +0100 |
commit | 81c51fc1ab699fb6e417ada77221657ca34efd0b (patch) | |
tree | a0deb244f9e69ba8b6013162a1293cc2ec517de2 /src/evaluate.c | |
parent | 909e297ed430c3d7be0ad06bb002913e766115f1 (diff) |
src: flowtable: add support for named flowtable listing
This patch allows you to dump a named flowtable.
# nft list flowtable inet t f
table inet t {
flowtable f {
hook ingress priority filter + 10
devices = { eth0, eth1 }
}
}
Also:
libnftables-json.adoc: fix missing quotes.
Fixes: db0697ce7f60 ("src: support for flowtable listing")
Fixes: 872f373dc50f ("doc: Add JSON schema documentation")
Signed-off-by: Eric Jallot <ejallot@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/evaluate.c')
-rw-r--r-- | src/evaluate.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/evaluate.c b/src/evaluate.c index a56cd2a5..81230fc7 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -218,6 +218,23 @@ static int set_not_found(struct eval_ctx *ctx, const struct location *loc, table->handle.table.name); } +static int flowtable_not_found(struct eval_ctx *ctx, const struct location *loc, + const char *ft_name) +{ + const struct table *table; + struct flowtable *ft; + + ft = flowtable_lookup_fuzzy(ft_name, &ctx->nft->cache, &table); + if (ft == NULL) + return cmd_error(ctx, loc, "%s", strerror(ENOENT)); + + return cmd_error(ctx, loc, + "%s; did you mean flowtable ā%sā in table %s ā%sā?", + strerror(ENOENT), ft->handle.flowtable.name, + family2str(ft->handle.family), + table->handle.table.name); +} + /* * Symbol expression: parse symbol and evaluate resulting expression. */ @@ -3834,6 +3851,7 @@ static int cmd_evaluate_list_obj(struct eval_ctx *ctx, const struct cmd *cmd, static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd) { + struct flowtable *ft; struct table *table; struct set *set; @@ -3899,6 +3917,17 @@ static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd) return chain_not_found(ctx); return 0; + case CMD_OBJ_FLOWTABLE: + table = table_lookup(&cmd->handle, &ctx->nft->cache); + if (table == NULL) + return table_not_found(ctx); + + ft = flowtable_lookup(table, cmd->handle.flowtable.name); + if (ft == NULL) + return flowtable_not_found(ctx, &ctx->cmd->handle.flowtable.location, + ctx->cmd->handle.flowtable.name); + + return 0; case CMD_OBJ_QUOTA: return cmd_evaluate_list_obj(ctx, cmd, NFT_OBJECT_QUOTA); case CMD_OBJ_COUNTER: |