]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: deprecate "flow table" syntax, replace it by "meter"
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 23 Nov 2017 14:14:01 +0000 (15:14 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 24 Nov 2017 14:03:28 +0000 (15:03 +0100)
According to bugzilla 1137: "flow tables" should not be syntactically
unique.

"Flow tables are always named, but they don't conform to the way sets,
maps, and dictionaries work in terms of "add" and "delete" and all that.

They are also "flow tables" instead of one word like "flows" or
"throttle" or something.

It seems weird to just have these break the syntactic expectations."

Personally, I never liked the reference to "table" since we have very
specific semantics in terms of what a "table" is netfilter for long
time.

This patch promotes "meter" as the new keyword. The former syntax is
still accepted for a while, just to reduce chances of breaking things.
At some point the former syntax will just be removed.

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1137
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Acked-by: Arturo Borrero Gonzalez <arturo@netfilter.org>
15 files changed:
include/rule.h
include/statement.h
src/evaluate.c
src/expression.c
src/netlink_delinearize.c
src/netlink_linearize.c
src/parser_bison.y
src/rule.c
src/scanner.l
src/statement.c
tests/py/ip/flowtable.t
tests/py/ip/flowtable.t.payload
tests/py/ip6/flowtable.t
tests/py/ip6/flowtable.t.payload
tests/shell/testcases/sets/0022type_selective_flush_0

index c59bcea7521053ba3d0de3808d24e4d25328ded3..4912aa16835765112af81b4a967e14abf9d79fb8 100644 (file)
@@ -361,6 +361,8 @@ enum cmd_ops {
  * @CMD_OBJ_EXPR:      expression
  * @CMD_OBJ_MONITOR:   monitor
  * @CMD_OBJ_EXPORT:    export
+ * @CMD_OBJ_METER:     meter
+ * @CMD_OBJ_METERS:    meters
  * @CMD_OBJ_COUNTER:   counter
  * @CMD_OBJ_COUNTERS:  multiple counters
  * @CMD_OBJ_QUOTA:     quota
@@ -381,8 +383,8 @@ enum cmd_obj {
        CMD_OBJ_EXPR,
        CMD_OBJ_MONITOR,
        CMD_OBJ_EXPORT,
-       CMD_OBJ_FLOWTABLE,
-       CMD_OBJ_FLOWTABLES,
+       CMD_OBJ_METER,
+       CMD_OBJ_METERS,
        CMD_OBJ_MAP,
        CMD_OBJ_MAPS,
        CMD_OBJ_COUNTER,
index 2f702c3c5d362cb607053183eda1471e194ded0f..23a551b67f2b9c857c3a4f5ea38f90c0f9e725f9 100644 (file)
@@ -165,14 +165,14 @@ struct set_stmt {
 
 extern struct stmt *set_stmt_alloc(const struct location *loc);
 
-struct flow_stmt {
+struct meter_stmt {
        struct expr             *set;
        struct expr             *key;
        struct stmt             *stmt;
-       const char              *table;
+       const char              *name;
 };
 
-extern struct stmt *flow_stmt_alloc(const struct location *loc);
+extern struct stmt *meter_stmt_alloc(const struct location *loc);
 
 /**
  * enum nft_xt_type - xtables statement types
@@ -209,7 +209,7 @@ struct xt_stmt {
  * @STMT_INVALID:      uninitialised
  * @STMT_EXPRESSION:   expression statement (relational)
  * @STMT_VERDICT:      verdict statement
- * @STMT_FLOW:         flow statement
+ * @STMT_METER:                meter statement
  * @STMT_COUNTER:      counters
  * @STMT_PAYLOAD:      payload statement
  * @STMT_META:         meta statement
@@ -234,7 +234,7 @@ enum stmt_types {
        STMT_INVALID,
        STMT_EXPRESSION,
        STMT_VERDICT,
-       STMT_FLOW,
+       STMT_METER,
        STMT_COUNTER,
        STMT_PAYLOAD,
        STMT_META,
@@ -296,7 +296,7 @@ struct stmt {
        union {
                struct expr             *expr;
                struct exthdr_stmt      exthdr;
-               struct flow_stmt        flow;
+               struct meter_stmt       meter;
                struct counter_stmt     counter;
                struct payload_stmt     payload;
                struct meta_stmt        meta;
index fd61e7530d2ec77a092291e55658a7d0a3c633e6..f30543f822e064e19ae4a297218413174e95c5c4 100644 (file)
@@ -2021,37 +2021,37 @@ static int stmt_evaluate_payload(struct eval_ctx *ctx, struct stmt *stmt)
        return expr_evaluate(ctx, &stmt->payload.val);
 }
 
-static int stmt_evaluate_flow(struct eval_ctx *ctx, struct stmt *stmt)
+static int stmt_evaluate_meter(struct eval_ctx *ctx, struct stmt *stmt)
 {
        struct expr *key, *set, *setref;
 
        expr_set_context(&ctx->ectx, NULL, 0);
-       if (expr_evaluate(ctx, &stmt->flow.key) < 0)
+       if (expr_evaluate(ctx, &stmt->meter.key) < 0)
                return -1;
-       if (expr_is_constant(stmt->flow.key))
-               return expr_error(ctx->msgs, stmt->flow.key,
-                                 "Flow key expression can not be constant");
-       if (stmt->flow.key->comment)
-               return expr_error(ctx->msgs, stmt->flow.key,
-                                 "Flow key expression can not contain comments");
+       if (expr_is_constant(stmt->meter.key))
+               return expr_error(ctx->msgs, stmt->meter.key,
+                                 "Meter key expression can not be constant");
+       if (stmt->meter.key->comment)
+               return expr_error(ctx->msgs, stmt->meter.key,
+                                 "Meter key expression can not contain comments");
 
        /* Declare an empty set */
-       key = stmt->flow.key;
+       key = stmt->meter.key;
        set = set_expr_alloc(&key->location, NULL);
        set->set_flags |= NFT_SET_EVAL;
        if (key->timeout)
                set->set_flags |= NFT_SET_TIMEOUT;
 
-       setref = implicit_set_declaration(ctx, stmt->flow.table ?: "__ft%d",
+       setref = implicit_set_declaration(ctx, stmt->meter.name ?: "__mt%d",
                                          key, set);
 
-       stmt->flow.set = setref;
+       stmt->meter.set = setref;
 
-       if (stmt_evaluate(ctx, stmt->flow.stmt) < 0)
+       if (stmt_evaluate(ctx, stmt->meter.stmt) < 0)
                return -1;
-       if (!(stmt->flow.stmt->flags & STMT_F_STATEFUL))
-               return stmt_binary_error(ctx, stmt->flow.stmt, stmt,
-                                        "Per-flow statement must be stateful");
+       if (!(stmt->meter.stmt->flags & STMT_F_STATEFUL))
+               return stmt_binary_error(ctx, stmt->meter.stmt, stmt,
+                                        "meter statement must be stateful");
 
        return 0;
 }
@@ -2782,8 +2782,8 @@ int stmt_evaluate(struct eval_ctx *ctx, struct stmt *stmt)
                return stmt_evaluate_payload(ctx, stmt);
        case STMT_EXTHDR:
                return stmt_evaluate_exthdr(ctx, stmt);
-       case STMT_FLOW:
-               return stmt_evaluate_flow(ctx, stmt);
+       case STMT_METER:
+               return stmt_evaluate_meter(ctx, stmt);
        case STMT_META:
                return stmt_evaluate_meta(ctx, stmt);
        case STMT_CT:
@@ -3151,14 +3151,14 @@ static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd)
                        return cmd_error(ctx, "Could not process rule: Set '%s' does not exist",
                                         cmd->handle.set);
                return 0;
-       case CMD_OBJ_FLOWTABLE:
+       case CMD_OBJ_METER:
                table = table_lookup(&cmd->handle, ctx->cache);
                if (table == NULL)
                        return cmd_error(ctx, "Could not process rule: Table '%s' does not exist",
                                         cmd->handle.table);
                set = set_lookup(table, cmd->handle.set);
                if (set == NULL || !(set->flags & NFT_SET_EVAL))
-                       return cmd_error(ctx, "Could not process rule: Flow table '%s' does not exist",
+                       return cmd_error(ctx, "Could not process rule: Meter '%s' does not exist",
                                         cmd->handle.set);
                return 0;
        case CMD_OBJ_MAP:
@@ -3201,7 +3201,7 @@ static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd)
                return 0;
        case CMD_OBJ_CHAINS:
        case CMD_OBJ_RULESET:
-       case CMD_OBJ_FLOWTABLES:
+       case CMD_OBJ_METERS:
        case CMD_OBJ_MAPS:
                return 0;
        default:
@@ -3276,14 +3276,14 @@ static int cmd_evaluate_flush(struct eval_ctx *ctx, struct cmd *cmd)
                        return cmd_error(ctx, "Could not process rule: Map '%s' does not exist",
                                         cmd->handle.set);
                return 0;
-       case CMD_OBJ_FLOWTABLE:
+       case CMD_OBJ_METER:
                table = table_lookup(&cmd->handle, ctx->cache);
                if (table == NULL)
                        return cmd_error(ctx, "Could not process rule: Table '%s' does not exist",
                                         cmd->handle.table);
                set = set_lookup(table, cmd->handle.set);
                if (set == NULL || !(set->flags & NFT_SET_EVAL))
-                       return cmd_error(ctx, "Could not process rule: Flow table '%s' does not exist",
+                       return cmd_error(ctx, "Could not process rule: Meter '%s' does not exist",
                                         cmd->handle.set);
                return 0;
        default:
index 64ac724a2ae59d6bf74af7a5d637f14ac6b54342..273038e62d2e9d534c2d104abae10247c24d8ff6 100644 (file)
@@ -932,7 +932,7 @@ static void set_ref_expr_print(const struct expr *expr, struct output_ctx *octx)
 {
        if (expr->set->flags & NFT_SET_ANONYMOUS) {
                if (expr->set->flags & NFT_SET_EVAL)
-                       nft_print(octx, "table %s", expr->set->handle.set);
+                       nft_print(octx, "%s", expr->set->handle.set);
                else
                        expr_print(expr->set->init, octx);
        } else {
index 44328879ebb8c88f8e4443da0095425f3a23dc9f..67dbd27dd7a7079dc78e2d64bd113d13ad7554a0 100644 (file)
@@ -1143,10 +1143,10 @@ static void netlink_parse_dynset(struct netlink_parse_ctx *ctx,
        }
 
        if (dstmt != NULL) {
-               stmt = flow_stmt_alloc(loc);
-               stmt->flow.set  = set_ref_expr_alloc(loc, set);
-               stmt->flow.key  = expr;
-               stmt->flow.stmt = dstmt;
+               stmt = meter_stmt_alloc(loc);
+               stmt->meter.set  = set_ref_expr_alloc(loc, set);
+               stmt->meter.key  = expr;
+               stmt->meter.stmt = dstmt;
        } else {
                stmt = set_stmt_alloc(loc);
                stmt->set.set   = set_ref_expr_alloc(loc, set);
@@ -2209,8 +2209,8 @@ static void rule_parse_postprocess(struct netlink_parse_ctx *ctx, struct rule *r
                case STMT_PAYLOAD:
                        stmt_payload_postprocess(&rctx);
                        break;
-               case STMT_FLOW:
-                       expr_postprocess(&rctx, &stmt->flow.key);
+               case STMT_METER:
+                       expr_postprocess(&rctx, &stmt->meter.key);
                        break;
                case STMT_META:
                        if (stmt->meta.expr != NULL)
index fb2d2501ce9bb8913f2dd43b7052eecf72fa4b3e..cf6ffdb05ebf196e3b15221237bb047a658e309a 100644 (file)
@@ -1204,7 +1204,7 @@ static void netlink_gen_notrack_stmt(struct netlink_linearize_ctx *ctx,
 static void netlink_gen_set_stmt(struct netlink_linearize_ctx *ctx,
                                 const struct stmt *stmt)
 {
-       struct set *set = stmt->flow.set->set;
+       struct set *set = stmt->meter.set->set;
        struct nftnl_expr *nle;
        enum nft_registers sreg_key;
 
@@ -1223,34 +1223,34 @@ static void netlink_gen_set_stmt(struct netlink_linearize_ctx *ctx,
        nftnl_rule_add_expr(ctx->nlr, nle);
 }
 
-static void netlink_gen_flow_stmt(struct netlink_linearize_ctx *ctx,
-                                 const struct stmt *stmt)
+static void netlink_gen_meter_stmt(struct netlink_linearize_ctx *ctx,
+                                  const struct stmt *stmt)
 {
        struct nftnl_expr *nle;
        enum nft_registers sreg_key;
        enum nft_dynset_ops op;
        struct set *set;
 
-       sreg_key = get_register(ctx, stmt->flow.key->key);
-       netlink_gen_expr(ctx, stmt->flow.key->key, sreg_key);
-       release_register(ctx, stmt->flow.key->key);
+       sreg_key = get_register(ctx, stmt->meter.key->key);
+       netlink_gen_expr(ctx, stmt->meter.key->key, sreg_key);
+       release_register(ctx, stmt->meter.key->key);
 
-       set = stmt->flow.set->set;
-       if (stmt->flow.key->timeout)
+       set = stmt->meter.set->set;
+       if (stmt->meter.key->timeout)
                op = NFT_DYNSET_OP_UPDATE;
        else
                op = NFT_DYNSET_OP_ADD;
 
        nle = alloc_nft_expr("dynset");
        netlink_put_register(nle, NFTNL_EXPR_DYNSET_SREG_KEY, sreg_key);
-       if (stmt->flow.key->timeout)
+       if (stmt->meter.key->timeout)
                nftnl_expr_set_u64(nle, NFTNL_EXPR_DYNSET_TIMEOUT,
-                                  stmt->flow.key->timeout);
+                                  stmt->meter.key->timeout);
        nftnl_expr_set_u32(nle, NFTNL_EXPR_DYNSET_OP, op);
        nftnl_expr_set_str(nle, NFTNL_EXPR_DYNSET_SET_NAME, set->handle.set);
        nftnl_expr_set_u32(nle, NFTNL_EXPR_DYNSET_SET_ID, set->handle.set_id);
        nftnl_expr_set(nle, NFTNL_EXPR_DYNSET_EXPR,
-                      netlink_gen_stmt_stateful(ctx, stmt->flow.stmt), 0);
+                      netlink_gen_stmt_stateful(ctx, stmt->meter.stmt), 0);
        nftnl_rule_add_expr(ctx->nlr, nle);
 }
 
@@ -1264,8 +1264,8 @@ static void netlink_gen_stmt(struct netlink_linearize_ctx *ctx,
                return netlink_gen_expr(ctx, stmt->expr, NFT_REG_VERDICT);
        case STMT_VERDICT:
                return netlink_gen_verdict_stmt(ctx, stmt);
-       case STMT_FLOW:
-               return netlink_gen_flow_stmt(ctx, stmt);
+       case STMT_METER:
+               return netlink_gen_meter_stmt(ctx, stmt);
        case STMT_EXTHDR:
                return netlink_gen_exthdr_stmt(ctx, stmt);
        case STMT_PAYLOAD:
index c64c3979eb04155941a37311dbe00932615c3c97..6610b9dccc3c9f92e4319eec164ebceb0a394e5d 100644 (file)
@@ -243,6 +243,8 @@ int nft_lex(void *, void *, void *);
 %token SIZE                    "size"
 
 %token FLOW                    "flow"
+%token METER                   "meter"
+%token METERS                  "meters"
 
 %token <val> NUM               "number"
 %token <string> STRING         "string"
@@ -555,8 +557,8 @@ int nft_lex(void *, void *, void *);
 %type <stmt>                   set_stmt
 %destructor { stmt_free($$); } set_stmt
 %type <val>                    set_stmt_op
-%type <stmt>                   flow_stmt flow_stmt_alloc
-%destructor { stmt_free($$); } flow_stmt flow_stmt_alloc
+%type <stmt>                   meter_stmt meter_stmt_alloc
+%destructor { stmt_free($$); } meter_stmt meter_stmt_alloc
 
 %type <expr>                   symbol_expr verdict_expr integer_expr variable_expr
 %destructor { expr_free($$); } symbol_expr verdict_expr integer_expr variable_expr
@@ -606,8 +608,8 @@ int nft_lex(void *, void *, void *);
 %type <expr>                   set_elem_expr_stmt set_elem_expr_stmt_alloc
 %destructor { expr_free($$); } set_elem_expr_stmt set_elem_expr_stmt_alloc
 
-%type <expr>                   flow_key_expr flow_key_expr_alloc
-%destructor { expr_free($$); } flow_key_expr flow_key_expr_alloc
+%type <expr>                   meter_key_expr meter_key_expr_alloc
+%destructor { expr_free($$); } meter_key_expr meter_key_expr_alloc
 
 %type <expr>                   expr initializer_expr keyword_expr
 %destructor { expr_free($$); } expr initializer_expr keyword_expr
@@ -1084,11 +1086,19 @@ list_cmd                :       TABLE           table_spec
                        }
                        |       FLOW TABLES     ruleset_spec
                        {
-                               $$ = cmd_alloc(CMD_LIST, CMD_OBJ_FLOWTABLES, &$3, &@$, NULL);
+                               $$ = cmd_alloc(CMD_LIST, CMD_OBJ_METERS, &$3, &@$, NULL);
                        }
                        |       FLOW TABLE      set_spec
                        {
-                               $$ = cmd_alloc(CMD_LIST, CMD_OBJ_FLOWTABLE, &$3, &@$, NULL);
+                               $$ = cmd_alloc(CMD_LIST, CMD_OBJ_METER, &$3, &@$, NULL);
+                       }
+                       |       METERS          ruleset_spec
+                       {
+                               $$ = cmd_alloc(CMD_LIST, CMD_OBJ_METERS, &$2, &@$, NULL);
+                       }
+                       |       METER           set_spec
+                       {
+                               $$ = cmd_alloc(CMD_LIST, CMD_OBJ_METER, &$2, &@$, NULL);
                        }
                        |       MAPS            ruleset_spec
                        {
@@ -1152,7 +1162,11 @@ flush_cmd                :       TABLE           table_spec
                        }
                        |       FLOW TABLE      set_spec
                        {
-                               $$ = cmd_alloc(CMD_FLUSH, CMD_OBJ_FLOWTABLE, &$3, &@$, NULL);
+                               $$ = cmd_alloc(CMD_FLUSH, CMD_OBJ_METER, &$3, &@$, NULL);
+                       }
+                       |       METER           set_spec
+                       {
+                               $$ = cmd_alloc(CMD_FLUSH, CMD_OBJ_METER, &$2, &@$, NULL);
                        }
                        |       RULESET         ruleset_spec
                        {
@@ -1782,7 +1796,7 @@ stmt_list         :       stmt
 
 stmt                   :       verdict_stmt
                        |       match_stmt
-                       |       flow_stmt
+                       |       meter_stmt
                        |       counter_stmt
                        |       payload_stmt
                        |       meta_stmt
@@ -2468,38 +2482,46 @@ set_stmt_op             :       ADD     { $$ = NFT_DYNSET_OP_ADD; }
                        |       UPDATE  { $$ = NFT_DYNSET_OP_UPDATE; }
                        ;
 
-flow_stmt              :       flow_stmt_alloc         flow_stmt_opts  '{' flow_key_expr stmt '}'
+meter_stmt             :       meter_stmt_alloc                meter_stmt_opts '{' meter_key_expr stmt '}'
                        {
-                               $1->flow.key  = $4;
-                               $1->flow.stmt = $5;
+                               $1->meter.key  = $4;
+                               $1->meter.stmt = $5;
                                $$->location  = @$;
                                $$ = $1;
                        }
-                       |       flow_stmt_alloc         '{' flow_key_expr stmt '}'
+                       |       meter_stmt_alloc                '{' meter_key_expr stmt '}'
                        {
-                               $1->flow.key  = $3;
-                               $1->flow.stmt = $4;
+                               $1->meter.key  = $3;
+                               $1->meter.stmt = $4;
                                $$->location  = @$;
                                $$ = $1;
                        }
                        ;
 
-flow_stmt_alloc                :       FLOW
+meter_stmt_alloc       :       FLOW
+                       {
+                               $$ = meter_stmt_alloc(&@$);
+                       }
+                       |       METER
                        {
-                               $$ = flow_stmt_alloc(&@$);
+                               $$ = meter_stmt_alloc(&@$);
                        }
                        ;
 
-flow_stmt_opts         :       flow_stmt_opt
+meter_stmt_opts                :       meter_stmt_opt
                        {
                                $<stmt>$        = $<stmt>0;
                        }
-                       |       flow_stmt_opts          flow_stmt_opt
+                       |       meter_stmt_opts         meter_stmt_opt
                        ;
 
-flow_stmt_opt          :       TABLE                   identifier
+meter_stmt_opt         :       TABLE                   identifier
+                       {
+                               $<stmt>0->meter.name = $2;
+                       }
+                       |       NAME                    identifier
                        {
-                               $<stmt>0->flow.table = $2;
+                               $<stmt>0->meter.name = $2;
                        }
                        ;
 
@@ -2738,15 +2760,15 @@ set_list_member_expr    :       opt_newline     set_expr        opt_newline
                        }
                        ;
 
-flow_key_expr          :       flow_key_expr_alloc
-                       |       flow_key_expr_alloc             set_elem_options
+meter_key_expr         :       meter_key_expr_alloc
+                       |       meter_key_expr_alloc            set_elem_options
                        {
                                $$->location = @$;
                                $$ = $1;
                        }
                        ;
 
-flow_key_expr_alloc    :       concat_expr
+meter_key_expr_alloc   :       concat_expr
                        {
                                $$ = set_elem_expr_alloc(&@1, $1);
                        }
index 37d99c22004713c7134e76aa46cc4ef734d7891c..cbc40e2d101c1e93eeff236cc5d20a1472084860 100644 (file)
@@ -284,7 +284,7 @@ static void set_print_declaration(const struct set *set,
        if (set->flags & (NFT_SET_MAP | NFT_SET_OBJECT))
                type = "map";
        else if (set->flags & NFT_SET_EVAL)
-               type = "flow table";
+               type = "meter";
        else
                type = "set";
 
@@ -1197,7 +1197,7 @@ static int do_list_sets(struct netlink_ctx *ctx, struct cmd *cmd)
                            (set->flags & NFT_SET_ANONYMOUS ||
                            set->flags & NFT_SET_MAP))
                                continue;
-                       if (cmd->obj == CMD_OBJ_FLOWTABLES &&
+                       if (cmd->obj == CMD_OBJ_METERS &&
                            !(set->flags & NFT_SET_EVAL))
                                continue;
                        if (cmd->obj == CMD_OBJ_MAPS &&
@@ -1580,9 +1580,9 @@ static int do_command_list(struct netlink_ctx *ctx, struct cmd *cmd)
                return do_list_set(ctx, cmd, table);
        case CMD_OBJ_RULESET:
                return do_list_ruleset(ctx, cmd);
-       case CMD_OBJ_FLOWTABLES:
+       case CMD_OBJ_METERS:
                return do_list_sets(ctx, cmd);
-       case CMD_OBJ_FLOWTABLE:
+       case CMD_OBJ_METER:
                return do_list_set(ctx, cmd, table);
        case CMD_OBJ_MAPS:
                return do_list_sets(ctx, cmd);
@@ -1650,7 +1650,7 @@ static int do_command_flush(struct netlink_ctx *ctx, struct cmd *cmd)
                return netlink_flush_chain(ctx, &cmd->handle, &cmd->location);
        case CMD_OBJ_SET:
        case CMD_OBJ_MAP:
-       case CMD_OBJ_FLOWTABLE:
+       case CMD_OBJ_METER:
                return netlink_flush_setelems(ctx, &cmd->handle,
                                              &cmd->location);
        case CMD_OBJ_RULESET:
index ee09775ebf1d98959098a81033ae67d7cc759046..6f19eec9c11b8e450790918e88f78a6aad7a3d4a 100644 (file)
@@ -292,6 +292,8 @@ addrstring  ({macaddr}|{ip4addr}|{ip6addr})
 "memory"               { return MEMORY; }
 
 "flow"                 { return FLOW; }
+"meter"                        { return METER; }
+"meters"               { return METERS; }
 
 "counter"              { return COUNTER; }
 "name"                 { return NAME; }
index 11d067f82e7751a752517c95622bbd2059c2c050..1f93260bd3d5fb4c8f0991f48c282483a92ab53d 100644 (file)
@@ -107,42 +107,42 @@ struct stmt *verdict_stmt_alloc(const struct location *loc, struct expr *expr)
        return stmt;
 }
 
-static void flow_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
+static void meter_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
 {
-       nft_print(octx, "flow ");
-       if (stmt->flow.set) {
-               expr_print(stmt->flow.set, octx);
+       nft_print(octx, "meter ");
+       if (stmt->meter.set) {
+               expr_print(stmt->meter.set, octx);
                nft_print(octx, " ");
        }
        nft_print(octx, "{ ");
-       expr_print(stmt->flow.key, octx);
+       expr_print(stmt->meter.key, octx);
        nft_print(octx, " ");
 
        octx->stateless++;
-       stmt_print(stmt->flow.stmt, octx);
+       stmt_print(stmt->meter.stmt, octx);
        octx->stateless--;
 
        nft_print(octx, "} ");
 
 }
 
-static void flow_stmt_destroy(struct stmt *stmt)
+static void meter_stmt_destroy(struct stmt *stmt)
 {
-       expr_free(stmt->flow.key);
-       expr_free(stmt->flow.set);
-       stmt_free(stmt->flow.stmt);
+       expr_free(stmt->meter.key);
+       expr_free(stmt->meter.set);
+       stmt_free(stmt->meter.stmt);
 }
 
-static const struct stmt_ops flow_stmt_ops = {
-       .type           = STMT_FLOW,
-       .name           = "flow",
-       .print          = flow_stmt_print,
-       .destroy        = flow_stmt_destroy,
+static const struct stmt_ops meter_stmt_ops = {
+       .type           = STMT_METER,
+       .name           = "meter",
+       .print          = meter_stmt_print,
+       .destroy        = meter_stmt_destroy,
 };
 
-struct stmt *flow_stmt_alloc(const struct location *loc)
+struct stmt *meter_stmt_alloc(const struct location *loc)
 {
-       return stmt_alloc(loc, &flow_stmt_ops);
+       return stmt_alloc(loc, &meter_stmt_ops);
 }
 
 static void counter_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
index 41d5d3bb034346dfbae5f2f0e10b0fe1a69d488b..7eaf5731ea221a5102a8845ab48ed4efdfcc6953 100644 (file)
@@ -2,4 +2,4 @@
 
 *ip;test-ip;input
 
-flow table xyz { ip saddr timeout 30s counter};ok
+meter name xyz { ip saddr timeout 30s counter};ok
index 591abf2bd06e9b2508ef627b34d7ddfce9490a77..4dbd03d019262d396b0bc5012755485c52f1f43e 100644 (file)
@@ -1,4 +1,4 @@
-# flow table xyz { ip saddr timeout 30s counter}
+# meter name xyz { ip saddr timeout 30s counter}
 xyz test-ip 31
 xyz test-ip 0
 ip test-ip input 
index cf0a6068f9c893a38da31b15eee184139d94e4eb..7a53f31aa67ea086b9be235f01336659fe705fe5 100644 (file)
@@ -2,5 +2,5 @@
 
 *ip6;test-ip6;input
 
-flow table acct_out { meta iif . ip6 saddr timeout 600s counter };ok;flow table acct_out { iif . ip6 saddr timeout 10m counter}
-flow table acct_out { ip6 saddr . meta iif timeout 600s counter };ok;flow table acct_out { ip6 saddr . iif timeout 10m counter}
+meter name acct_out { meta iif . ip6 saddr timeout 600s counter };ok;meter name acct_out { iif . ip6 saddr timeout 10m counter}
+meter name acct_out { ip6 saddr . meta iif timeout 600s counter };ok;meter name acct_out { ip6 saddr . iif timeout 10m counter}
index d3da5bad633307e3c8ecb6db14882a566d7d4970..cf2de733ca42e563993279d362533a2ede442906 100644 (file)
@@ -1,4 +1,4 @@
-# flow table acct_out { meta iif . ip6 saddr timeout 600s counter }
+# meter name acct_out { meta iif . ip6 saddr timeout 600s counter }
 acct_out test-ip6 31
 acct_out test-ip6 0
 ip6 test-ip6 input
@@ -6,7 +6,7 @@ ip6 test-ip6 input
   [ payload load 16b @ network header + 8 => reg 9 ]
   [ dynset update reg_key 1 set acct_out timeout 600000ms expr [ counter pkts 0 bytes 0 ] ]
 
-# flow table acct_out { ip6 saddr . meta iif timeout 600s counter }
+# meter name acct_out { ip6 saddr . meta iif timeout 600s counter }
 acct_out test-ip6 31
 acct_out test-ip6 0
 ip6 test-ip6 input
index f8878f7001a6d350b4e5f2f3925d492474e54967..87a4c7bc4393d0e982c3093aba570839c5a1f59a 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 # This tests the selectiveness of flush command on structures that use the
-# generic set infrastructure (sets, maps and flow tables).
+# generic set infrastructure (sets, maps and meters).
 
 tmpfile=$(mktemp)
 if [ ! -w $tmpfile ] ; then
@@ -16,7 +16,7 @@ add table t
 add chain t c
 add set t s {type ipv4_addr;}
 add map t m {type ipv4_addr : inet_service;}
-add rule t c tcp dport 80 flow table f {ip saddr limit rate 10/second}
+add rule t c tcp dport 80 meter name f {ip saddr limit rate 10/second}
 " >$tmpfile
 
 $NFT -f $tmpfile
@@ -26,7 +26,7 @@ $NFT -f $tmpfile
 declare -a cmds=(
                "flush set t m" "flush set t f"
                "flush map t s" "flush map t f"
-               "flush flow table t s" "flush flow table t m"
+               "flush meter name t s" "flush meter name t m"
                )
 
 for i in "${cmds[@]}"