Re: [PATCH] netfilter: remove modulo operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Changli Gao <xiaosuo@xxxxxxxxx> wrote:
> Signed-off-by: Changli Gao <xiaosuo@xxxxxxxxx>
> ---
>  net/netfilter/xt_NFQUEUE.c |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> diff --git a/net/netfilter/xt_NFQUEUE.c b/net/netfilter/xt_NFQUEUE.c
> index 039cce1..3962770 100644
> --- a/net/netfilter/xt_NFQUEUE.c
> +++ b/net/netfilter/xt_NFQUEUE.c
> @@ -72,10 +72,12 @@ nfqueue_tg_v1(struct sk_buff *skb, const struct xt_action_param *par)
>  
>  	if (info->queues_total > 1) {
>  		if (par->family == NFPROTO_IPV4)
> -			queue = hash_v4(skb) % info->queues_total + queue;
> +			queue = (((u64) hash_v4(skb) * info->queues_total) >>
> +				 32) + queue;

I'd imagine that the result of ((hash * total) >> 32) is (almost)
always zero, especially if total is small (which it is usually).

Did you test that this change does not affect distribution average?
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux