Thread (32 messages) 32 messages, 6 authors, 2007-03-29

Re: RFC: Established connections hash function

From: Evgeniy Polyakov <hidden>
Date: 2007-03-22 15:52:34

On Thu, Mar 22, 2007 at 08:39:04AM -0700, Nikolaos D. Bougalis (nikb@webmaster.com) wrote:
   This particular hash seems to be the odd-man out, since most other
network related hashes in the kernel seem to be Jenkins-based, and some use
tagged hashing to defeat algorithmic complexity attacks. For example, the
route hash uses this:
It seems you do not know a history...
It is the fastest and actually the best hash for that workloads where it
is used, but unfortunately it is too simple for attacker to predict end
result.
static unsigned int rt_hash_rnd;

static unsigned int rt_hash_code(u32 daddr, u32 saddr)
{
       return (jhash_2words(daddr, saddr, rt_hash_rnd)
               & rt_hash_mask);
}

   With this in mind, I propose the following replacement for inet_ehashfn,
which defeats algorithmic complexity attacks and achieves excellent
distribution:

unsigned int inet_ehashfn(const __be32 laddr, const __u16 lport,
                         const __be32 faddr, const __be16 fport)
{
   return jhash_3words((__force __u32)faddr, (__force __u32)laddr,
                       (((__force __u32)fport) << 16) + lport,
                       inet_ehash_rnd);
}
And this is utterly broken. For more details please read netdev@
archives and trivial analysis of jhash_3words().

We can use jhash_2words(laddr, faddr, portpair^inet_ehash_rnd) though.

-- 
	Evgeniy Polyakov
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help