netfilter: nft_numgen: start round robin from zero
authorLiping Zhang <liping.zhang@spreadtrum.com>
Wed, 19 Oct 2016 15:29:53 +0000 (23:29 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 26 Oct 2016 14:35:16 +0000 (16:35 +0200)
Currently we start round robin from 1, but it's better to start round
robin from 0. This is to keep consistent with xt_statistic in iptables.

Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_numgen.c

index 55bc5ab78d4a292b6326e57f2a12f0ee25232b20..a66b36097b8f4f3cc1d230d9943be852866fcfbd 100644 (file)
@@ -65,7 +65,7 @@ static int nft_ng_inc_init(const struct nft_ctx *ctx,
                return -EOVERFLOW;
 
        priv->dreg = nft_parse_register(tb[NFTA_NG_DREG]);
-       atomic_set(&priv->counter, 0);
+       atomic_set(&priv->counter, priv->modulus - 1);
 
        return nft_validate_register_store(ctx, priv->dreg, NULL,
                                           NFT_DATA_VALUE, sizeof(u32));