From: "Nikolaos D. Bougalis" <nikb@webmaster.com>
To: <netdev@vger.kernel.org>
Subject: Re: RFC: Established connections hash function
Date: Fri, 23 Mar 2007 05:45:30 -0700 [thread overview]
Message-ID: <EED139046EA84B0095BFB0ECB17BA288@XEON> (raw)
In-Reply-To: <20070323080715.GB29991@2ka.mipt.ru>
Let me start off by saying that I hope I didn't come across as
condenscending in my previous posts. If I did, then it wasn't intended. Now,
on to more important things :)
> jhash_2words(const, const, ((const << 16) | $sport) ^ $random)
>
> where $sport is 1-65535 in a loop, and $random is pseudo-random number
> obtained on start.
If you are correct that jhash_3words doesn't properly distribute the
bits in 'c' (which I don't believe you are, but let's assume it for a
second) then this function will also be broken: jhash_2words calls
jhash_3words; jhash_3words adds (a linear operation) initval and c before
calling __jhash_mix. So, if there is a problem with passing values under the
direct control of the attacker into 'c' both jhash_2words and jhash_3words
are affected; in other words, this variant would also be flawed.
> Which is exactly the case of web server and attacker connects to 80 port
> from the same IP address and different source ports.
>
> Result with jenkins:
> 1 23880
> 2 12108
> 3 4040
> 4 1019
> 5 200
> 6 30
> 7 8
> 8 1
>
> Xor:
> 1 65536
I believe that the XOR results, if generated by your test above, are
somewhat meaningless because you're feeding what is ideal input into the XOR
hash. Which means that you'll get a perfect distribution. With your input,
one might as well suggest that using the remote port will give a perfect
distribution, and it will, but only for that specific input.
Just for kicks, I went to one of our servers, and did "netstat -n | grep
ESTABLISHED" and ended up with 31072 distinct ip:port/ip:port 4-tuples which
I then hashed into a 65536 bucket table. There are the results; feel free to
draw your own conclusions:
[ I think this should come out looking good; sorry if whitespace is screwy ]
+---+-------+-------+-------+-------+
| | xor | j2w 1 | j2w 2 | j3w 1 |
+---+-------+---------------+-------+
| 0 | 40868 | 40930 | 40767 | 40750 |
| 1 | 19208 | 19119 | 19382 | 19413 |
| 2 | 4636 | 4618 | 4576 | 4554 |
| 3 | 716 | 769 | 715 | 734 |
| 4 | 99 | 91 | 87 | 76 |
| 5 | 7 | 8 | 9 | 9 |
| 6 | 1 | 1 | 0 | 0 |
| 7 | 1 | 0 | 0 | 0 |
| 8 | 0 | 0 | 0 | 0 |
+---+-------+-------+-------+-------+
xor: the vanilla linux function
j2w 1 is my variant: jhash_2words(laddr + rport, raddr + lport, seed)
j2w 2 is your variant: jhash_2words(laddr, raddr, (rport << 16) ^ lport) ^
seed)
j3w: jhash_3words(laddr, raddr, (rport << 12) + lport, seed)
The seed used for all the Jenkins hashes came from the low-order 32-bits
returned by RDTSC, executed when the program started. It remained constant
throughout the run. 8 runs where made, to ensure that the seed wasn't
causing weirdness, all runs giving almost identical results. The Jenkins
hashes did not use the extra 2 right-shifts to fold high-order bits into the
low-order bits, that is employed by the XOR hash.
-n
next prev parent reply other threads:[~2007-03-23 12:45 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-22 15:39 RFC: Established connections hash function Nikolaos D. Bougalis
2007-03-22 15:52 ` Evgeniy Polyakov
2007-03-22 17:32 ` Nikolaos D. Bougalis
2007-03-22 18:21 ` Evgeniy Polyakov
2007-03-22 19:44 ` Nikolaos D. Bougalis
2007-03-22 19:56 ` Evgeniy Polyakov
2007-03-22 20:53 ` Nikolaos D. Bougalis
2007-03-23 7:52 ` Evgeniy Polyakov
2007-03-22 20:58 ` David Miller
2007-03-22 22:03 ` Eric Dumazet
2007-03-23 7:11 ` David Miller
2007-03-23 8:00 ` Eric Dumazet
2007-03-23 18:46 ` David Miller
2007-03-23 8:07 ` Evgeniy Polyakov
2007-03-23 8:17 ` Eric Dumazet
2007-03-23 8:33 ` Evgeniy Polyakov
2007-03-23 9:10 ` Evgeniy Polyakov
2007-03-23 11:58 ` XOR hash beauty solved [Was: RFC: Established connections hash function] Evgeniy Polyakov
2007-03-23 12:51 ` Nikolaos D. Bougalis
2007-03-23 12:45 ` Nikolaos D. Bougalis [this message]
2007-03-27 14:11 ` RFC: Established connections hash function Andi Kleen
2007-03-28 5:01 ` Nikolaos D. Bougalis
2007-03-28 6:29 ` David Miller
2007-03-28 9:29 ` Andi Kleen
2007-03-28 10:45 ` Evgeniy Polyakov
2007-03-28 14:14 ` Andi Kleen
2007-03-28 13:50 ` Eric Dumazet
2007-03-28 14:52 ` Andi Kleen
2007-03-29 9:18 ` Evgeniy Polyakov
2007-03-28 14:17 ` RFC: Established connections hash function II Andi Kleen
2007-03-28 19:04 ` RFC: Established connections hash function David Miller
2007-03-28 20:12 ` Andi Kleen
-- strict thread matches above, loose matches on Subject: below --
2007-03-24 12:26 linux
2007-03-24 13:29 ` Evgeniy Polyakov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=EED139046EA84B0095BFB0ECB17BA288@XEON \
--to=nikb@webmaster.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).