summaryrefslogtreecommitdiffstats
path: root/src/parser_bison.y
diff options
context:
space:
mode:
authorLiping Zhang <zlpnobody@gmail.com>2017-04-15 17:22:17 +0800
committerPablo Neira Ayuso <pablo@netfilter.org>2017-04-15 11:30:08 +0200
commite2b25ccc31b8262a0739b46337fbb354e00aa1d6 (patch)
tree05db8f700716c22ef19ff6153807a173d17a8821 /src/parser_bison.y
parentcd3877cd4a7c4943dc29c274366795f02c42feb0 (diff)
hash: generate a random seed if seed option is empty
Typing the "nft add rule x y ct mark set jhash ip saddr mod 2" will not generate a random seed, instead, the seed will always be zero. So if seed option is empty, we shoulde not set the NFTA_HASH_SEED attribute, then a random seed will be generated in the kernel. Signed-off-by: Liping Zhang <zlpnobody@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/parser_bison.y')
-rw-r--r--src/parser_bison.y17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/parser_bison.y b/src/parser_bison.y
index 9f993fd3..8db887a4 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -520,7 +520,7 @@ static void location_update(struct location *loc, struct location *rhs, int n)
%destructor { stmt_free($$); } reject_stmt reject_stmt_alloc
%type <stmt> nat_stmt nat_stmt_alloc masq_stmt masq_stmt_alloc redir_stmt redir_stmt_alloc
%destructor { stmt_free($$); } nat_stmt nat_stmt_alloc masq_stmt masq_stmt_alloc redir_stmt redir_stmt_alloc
-%type <val> nf_nat_flags nf_nat_flag offset_opt seed_opt
+%type <val> nf_nat_flags nf_nat_flag offset_opt
%type <stmt> queue_stmt queue_stmt_alloc
%destructor { stmt_free($$); } queue_stmt queue_stmt_alloc
%type <val> queue_stmt_flags queue_stmt_flag
@@ -3092,18 +3092,19 @@ numgen_expr : NUMGEN numgen_type MOD NUM offset_opt
}
;
-seed_opt : /* empty */ { $$ = 0; }
- | SEED NUM { $$ = $2; }
- ;
-
-hash_expr : JHASH expr MOD NUM seed_opt offset_opt
+hash_expr : JHASH expr MOD NUM SEED NUM offset_opt
+ {
+ $$ = hash_expr_alloc(&@$, $4, true, $6, $7, NFT_HASH_JENKINS);
+ $$->hash.expr = $2;
+ }
+ | JHASH expr MOD NUM offset_opt
{
- $$ = hash_expr_alloc(&@$, $4, $5, $6, NFT_HASH_JENKINS);
+ $$ = hash_expr_alloc(&@$, $4, false, 0, $5, NFT_HASH_JENKINS);
$$->hash.expr = $2;
}
| SYMHASH MOD NUM offset_opt
{
- $$ = hash_expr_alloc(&@$, $3, 0, $4, NFT_HASH_SYM);
+ $$ = hash_expr_alloc(&@$, $3, false, 0, $4, NFT_HASH_SYM);
}
;