From 9bee0c86f1794c6c5418f256420758dc15d91f77 Mon Sep 17 00:00:00 2001 From: Laura Garcia Liebana Date: Fri, 4 Nov 2016 14:01:12 +0100 Subject: src: add offset attribute for hash expression Add support to add an offset to the hash generator, eg. ct mark set hash ip saddr mod 10 offset 100 This will generate marks with series between 100-109. Signed-off-by: Laura Garcia Liebana Signed-off-by: Pablo Neira Ayuso --- include/expression.h | 1 + include/hash.h | 3 ++- include/linux/netfilter/nf_tables.h | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/expression.h b/include/expression.h index 3a52a45c..71e9c43e 100644 --- a/include/expression.h +++ b/include/expression.h @@ -307,6 +307,7 @@ struct expr { struct expr *expr; uint32_t mod; uint32_t seed; + uint32_t offset; } hash; struct { /* EXPR_FIB */ diff --git a/include/hash.h b/include/hash.h index bc8c86af..8bf53e2e 100644 --- a/include/hash.h +++ b/include/hash.h @@ -2,6 +2,7 @@ #define NFTABLES_HASH_H extern struct expr *hash_expr_alloc(const struct location *loc, - uint32_t modulus, uint32_t seed); + uint32_t modulus, uint32_t seed, + uint32_t offset); #endif /* NFTABLES_HASH_H */ diff --git a/include/linux/netfilter/nf_tables.h b/include/linux/netfilter/nf_tables.h index c6567ace..0fb63fe0 100644 --- a/include/linux/netfilter/nf_tables.h +++ b/include/linux/netfilter/nf_tables.h @@ -773,6 +773,7 @@ enum nft_rt_keys { * @NFTA_HASH_LEN: source data length (NLA_U32) * @NFTA_HASH_MODULUS: modulus value (NLA_U32) * @NFTA_HASH_SEED: seed value (NLA_U32) + * @NFTA_HASH_OFFSET: offset value (NLA_U32) */ enum nft_hash_attributes { NFTA_HASH_UNSPEC, @@ -781,6 +782,7 @@ enum nft_hash_attributes { NFTA_HASH_LEN, NFTA_HASH_MODULUS, NFTA_HASH_SEED, + NFTA_HASH_OFFSET, __NFTA_HASH_MAX, }; #define NFTA_HASH_MAX (__NFTA_HASH_MAX - 1) -- cgit v1.2.3