path: root/tests
diff options
authorLaura Garcia Liebana <>2016-09-05 10:55:03 +0200
committerPablo Neira Ayuso <>2016-09-12 20:30:52 +0200
commit5877cc62d9bd1c7183992a2d05dd82d17ed12097 (patch)
tree97ba14e4c844bc7287d2115074be776c6a46cbeb /tests
parent3e885741cdc3498300419540333d9da43faa08f4 (diff)
expr: hash: Add offset to hash value
Add support to pass through an offset to the hash value. With this feature, the sysadmin is able to generate a hash with a given started value. Example: meta mark set jhash ip saddr mod 2 seed 0xabcd offset 100 This option generates marks according to the source address from 100 to 101. Signed-off-by: Laura Garcia Liebana <> Signed-off-by: Pablo Neira Ayuso <>
Diffstat (limited to 'tests')
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/nft-expr_hash-test.c b/tests/nft-expr_hash-test.c
index 699197c..d928234 100644
--- a/tests/nft-expr_hash-test.c
+++ b/tests/nft-expr_hash-test.c
@@ -42,6 +42,9 @@ static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_HASH_SEED) !=
nftnl_expr_get_u32(rule_b, NFTNL_EXPR_HASH_SEED))
print_err("Expr NFTNL_EXPR_HASH_SEED mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_HASH_OFFSET) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_HASH_OFFSET))
+ print_err("Expr NFTNL_EXPR_HASH_OFFSET mismatches");
int main(int argc, char *argv[])
@@ -65,6 +68,7 @@ int main(int argc, char *argv[])
nftnl_expr_set_u32(ex, NFTNL_EXPR_HASH_DREG, 0x78123456);
nftnl_expr_set_u32(ex, NFTNL_EXPR_HASH_MODULUS, 0x78123456);
nftnl_expr_set_u32(ex, NFTNL_EXPR_HASH_SEED, 0x78123456);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_HASH_OFFSET, 0x3612845);
nftnl_rule_add_expr(a, ex);