netfilter: nft_hash: fix symhash with modulus one
authorLaura Garcia Liebana <nevola@gmail.com>
Mon, 15 Jul 2019 11:23:37 +0000 (13:23 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 16 Jul 2019 11:17:03 +0000 (13:17 +0200)
The rule below doesn't work as the kernel raises -ERANGE.

nft add rule netdev nftlb lb01 ip daddr set \
symhash mod 1 map { 0 : 192.168.0.10 } fwd to "eth0"

This patch allows to use the symhash modulus with one
element, in the same way that the other types of hashes and
algorithms that uses the modulus parameter.

Signed-off-by: Laura Garcia Liebana <nevola@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_hash.c

index fe93e731dc7fb961a11841f6609d42a2ebde9d78..b836d550b9199513023055ce2fef752ac87cfd17 100644 (file)
@@ -129,7 +129,7 @@ static int nft_symhash_init(const struct nft_ctx *ctx,
        priv->dreg = nft_parse_register(tb[NFTA_HASH_DREG]);
 
        priv->modulus = ntohl(nla_get_be32(tb[NFTA_HASH_MODULUS]));
-       if (priv->modulus <= 1)
+       if (priv->modulus < 1)
                return -ERANGE;
 
        if (priv->offset + priv->modulus - 1 < priv->offset)