From 9ddd1b7fadfa6973fe1ddd6ac0e07a1759294a96 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Tue, 5 Nov 2019 21:40:26 +0000 Subject: src: add and use `set_is_meter` helper The sets constructed for meters are flagged as anonymous and dynamic. However, in some places there are only checks that they are dynamic, which can lead to normal sets being classified as meters. For example: # nft add table t # nft add set t s { type ipv4_addr; size 256; flags dynamic,timeout; } # nft add chain t c # nft add rule t c tcp dport 80 meter m size 128 { ip saddr limit rate 10/second } # nft list meters table ip t { set s { type ipv4_addr size 256 flags dynamic,timeout } meter m { type ipv4_addr size 128 flags dynamic } } # nft list meter t m table ip t { meter m { type ipv4_addr size 128 flags dynamic } } # nft list meter t s Error: No such file or directory list meter t s ^ Add a new helper `set_is_meter` and use it wherever there are checks for meters. Signed-off-by: Jeremy Sowden Signed-off-by: Florian Westphal --- src/evaluate.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/evaluate.c') diff --git a/src/evaluate.c b/src/evaluate.c index 81230fc7..e54eaf1a 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -3888,8 +3888,7 @@ static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd) if (set == NULL) return set_not_found(ctx, &ctx->cmd->handle.set.location, ctx->cmd->handle.set.name); - else if (!(set->flags & NFT_SET_EVAL) || - !(set->flags & NFT_SET_ANONYMOUS)) + else if (!set_is_meter(set->flags)) return cmd_error(ctx, &ctx->cmd->handle.set.location, "%s", strerror(ENOENT)); @@ -4037,8 +4036,7 @@ static int cmd_evaluate_flush(struct eval_ctx *ctx, struct cmd *cmd) if (set == NULL) return set_not_found(ctx, &ctx->cmd->handle.set.location, ctx->cmd->handle.set.name); - else if (!(set->flags & NFT_SET_EVAL) || - !(set->flags & NFT_SET_ANONYMOUS)) + else if (!set_is_meter(set->flags)) return cmd_error(ctx, &ctx->cmd->handle.set.location, "%s", strerror(ENOENT)); -- cgit v1.2.3