Hash Function to Seperate Flows
Vincent
cs83152 at csie.chu.edu.tw
Thu May 4 07:02:10 CEST 2006
I suggest to refer the net/ipv4/netfilter/ip_conntrack_core.c
Thehe is a example using jhash for reference.
static u_int32_t __hash_conntrack(const struct ip_conntrack_tuple
*tuple,
unsigned int size, unsigned int rnd)
{
return (jhash_3words(tuple->src.ip,
(tuple->dst.ip ^ tuple->dst.protonum),
(tuple->src.u.all | (tuple->dst.u.all <<
16)),
rnd) % size);
}
Vincent
>-----Original Message-----
>From: netfilter-devel-bounces at lists.netfilter.org
>[mailto:netfilter-devel-bounces at lists.netfilter.org] On Behalf
>Of Amin Azez
>Sent: Wednesday, May 03, 2006 5:35 PM
>To: netfilter-devel at lists.netfilter.org
>Subject: Re: Hash Function to Seperate Flows
>
>
>Srinivas Krishnan wrote:
>> hi,
>>
>> i am trying to separate different flows, and was wondering
>if there is
>> a standard hash function with low collisions i can use to hash based
>> on src ip, dest ip, src port, dest port and protocol.
>>
>> there seems to be as hash fn in freeBSD's dummynet code but I do not
>> know if it can be directly applied, as it does some bit
>fiddling with
>> flow_mask.
>>
>> any help/thoughts would be greatly appreciated
>
>I suggest you read a few times through all kernel source files
>with "conntrack" in the name.
>
>I did, and it did me a world of good.
>
>jhash is probably the hash function you want. Look out for it,
>and happy reading.
>
>Sam
>
More information about the netfilter-devel
mailing list