summaryrefslogtreecommitdiffstats
path: root/src/rule.c
diff options
context:
space:
mode:
authorJeremy Sowden <jeremy@azazel.net>2019-11-05 21:40:26 +0000
committerFlorian Westphal <fw@strlen.de>2019-11-06 15:36:09 +0100
commit9ddd1b7fadfa6973fe1ddd6ac0e07a1759294a96 (patch)
tree3eed5ed278113431673a1906bba68f668df3155b /src/rule.c
parent91487a80551ea91714082da41aa49ba52dd6e9bb (diff)
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 <jeremy@azazel.net> Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'src/rule.c')
-rw-r--r--src/rule.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/rule.c b/src/rule.c
index ff9e8e6c..552b3c6b 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -446,8 +446,7 @@ static void set_print_declaration(const struct set *set,
const char *type;
uint32_t flags;
- if ((set->flags & (NFT_SET_EVAL | NFT_SET_ANONYMOUS)) ==
- (NFT_SET_EVAL | NFT_SET_ANONYMOUS))
+ if (set_is_meter(set->flags))
type = "meter";
else if (set_is_map(set->flags))
type = "map";
@@ -534,11 +533,11 @@ static void set_print_declaration(const struct set *set,
}
static void do_set_print(const struct set *set, struct print_fmt_options *opts,
- struct output_ctx *octx)
+ struct output_ctx *octx)
{
set_print_declaration(set, opts, octx);
- if ((set->flags & NFT_SET_EVAL && nft_output_stateless(octx)) ||
+ if ((set_is_meter(set->flags) && nft_output_stateless(octx)) ||
nft_output_terse(octx)) {
nft_print(octx, "%s}%s", opts->tab, opts->nl);
return;
@@ -1691,7 +1690,7 @@ static int do_list_sets(struct netlink_ctx *ctx, struct cmd *cmd)
!set_is_literal(set->flags))
continue;
if (cmd->obj == CMD_OBJ_METERS &&
- !(set->flags & NFT_SET_EVAL))
+ !set_is_meter(set->flags))
continue;
if (cmd->obj == CMD_OBJ_MAPS &&
!map_is_literal(set->flags))