From 3a86406729782ee2671ec7161c76529c2e4a44e4 Mon Sep 17 00:00:00 2001 From: Laura Garcia Liebana Date: Tue, 28 Feb 2017 18:42:50 +0100 Subject: src: hash: support of symmetric hash This patch provides symmetric hash support according to source ip address and port, and destination ip address and port. The new attribute NFTA_HASH_TYPE has been included to support different types of hashing functions. Currently supported NFT_HASH_JENKINS through jhash and NFT_HASH_SYM through symhash. The main difference between both types are: - jhash requires an expression with sreg, symhash doesn't. - symhash supports modulus and offset, but not seed. Examples: nft add rule ip nat prerouting ct mark set jhash ip saddr mod 2 nft add rule ip nat prerouting ct mark set symhash mod 2 Signed-off-by: Laura Garcia Liebana Signed-off-by: Pablo Neira Ayuso --- tests/py/ip/hash.t | 1 + tests/py/ip/hash.t.payload | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'tests') diff --git a/tests/py/ip/hash.t b/tests/py/ip/hash.t index 0d01a11d..2becef62 100644 --- a/tests/py/ip/hash.t +++ b/tests/py/ip/hash.t @@ -6,3 +6,4 @@ ct mark set jhash ip saddr . ip daddr mod 2;ok ct mark set jhash ip saddr . ip daddr mod 2 seed 0xdeadbeef offset 100;ok ct mark set jhash ip saddr . ip daddr mod 2 offset 100;ok dnat to jhash ip saddr mod 2 seed 0xdeadbeef map { 0 : 192.168.20.100, 1 : 192.168.30.100 };ok +ct mark set symhash mod 2 offset 100;ok diff --git a/tests/py/ip/hash.t.payload b/tests/py/ip/hash.t.payload index 8c28ad98..21227e91 100644 --- a/tests/py/ip/hash.t.payload +++ b/tests/py/ip/hash.t.payload @@ -36,3 +36,7 @@ ip test-ip4 pre [ lookup reg 1 set __map%d dreg 1 ] [ nat dnat ip addr_min reg 1 addr_max reg 0 ] +# ct mark set symhash mod 2 offset 100 +ip test-ip4 pre + [ hash reg 1 = symhash() % mod 2 offset 100 ] + [ ct set mark with reg 1 ] -- cgit v1.2.3