struct nfnl_nft_expr *nle;
nle = alloc_nft_expr(nfnl_nft_counter_init);
+ if (stmt->counter.packets)
+ nfnl_nft_counter_set_packets(nle, stmt->counter.packets);
+ if (stmt->counter.bytes)
+ nfnl_nft_counter_set_bytes(nle, stmt->counter.bytes);
nfnl_nft_rule_add_expr(ctx->nlr, nle);
}
%token PROTO_DST "proto-dst"
%token COUNTER "counter"
+%token PACKETS "packets"
+%token BYTES "bytes"
%token LOG "log"
%token PREFIX "prefix"
%destructor { stmt_list_free($$); xfree($$); } stmt_list
%type <stmt> stmt match_stmt verdict_stmt
%destructor { stmt_free($$); } stmt match_stmt verdict_stmt
-%type <stmt> counter_stmt
-%destructor { stmt_free($$); } counter_stmt
+%type <stmt> counter_stmt counter_stmt_alloc
+%destructor { stmt_free($$); } counter_stmt counter_stmt_alloc
%type <stmt> meta_stmt
%destructor { stmt_free($$); } meta_stmt
%type <stmt> log_stmt log_stmt_alloc
}
;
-counter_stmt : COUNTER
+counter_stmt : counter_stmt_alloc
+ | counter_stmt_alloc counter_args
+
+counter_stmt_alloc : COUNTER
{
$$ = counter_stmt_alloc(&@$);
}
;
+counter_args : counter_arg
+ {
+ $<stmt>$ = $<stmt>0;
+ }
+ | counter_args counter_arg
+ ;
+
+counter_arg : PACKETS NUM
+ {
+ $<stmt>0->counter.packets = $2;
+ }
+ | BYTES NUM
+ {
+ $<stmt>0->counter.bytes = $2;
+ }
+ ;
+
log_stmt : log_stmt_alloc
| log_stmt_alloc log_args
;
"rename" { return RENAME; }
"counter" { return COUNTER; }
+"packets" { return PACKETS; }
+"bytes" { return BYTES; }
"log" { return LOG; }
"prefix" { return PREFIX; }