public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay•com>
To: David Miller <davem@davemloft•net>, nikb@webmaster•com
Cc: netdev@vger•kernel.org
Subject: Re: RFC: Established connections hash function
Date: Thu, 22 Mar 2007 23:03:04 +0100	[thread overview]
Message-ID: <4602FD18.7060902@cosmosbay.com> (raw)
In-Reply-To: <20070322.135834.74723088.davem@davemloft.net>

David Miller a écrit :
> From: "Nikolaos D. Bougalis" <nikb@webmaster•com>
> Date: Thu, 22 Mar 2007 12:44:09 -0700
> 
>>     People _have_ had problems. _I_ have had problems. And when
>> someone with a few thousand drones under his control hoses your
>> servers because he can do math and he leaves you with 20000-item
>> long chains, _you_ will have problems.
> 
> No need to further argue this point, the people that matter
> (ie. me :-) understand it, don't worry..

Yes, I recall having one big server hit two years ago by an attack on tcp hash 
function. David sent me the patch to use jhash. It's performing well :)

Welcome to the club :)

===== net/ipv4/tcp_ipv4.c 1.114 vs edited =====
--- 1.114/net/ipv4/tcp_ipv4.c    2005-03-26 15:04:35 -08:00
+++ edited/net/ipv4/tcp_ipv4.c    2005-04-05 13:39:52 -07:00
@@ -103,14 +103,15 @@
   */
  int sysctl_local_port_range[2] = { 1024, 4999 };
  int tcp_port_rover = 1024 - 1;
+static u32 tcp_v4_hash_rand;

  static __inline__ int tcp_hashfn(__u32 laddr, __u16 lport,
                   __u32 faddr, __u16 fport)
  {
-    int h = (laddr ^ lport) ^ (faddr ^ fport);
-    h ^= h >> 16;
-    h ^= h >> 8;
-    return h & (tcp_ehash_size - 1);
+    return jhash_2words(laddr ^ faddr,
+                (lport << 16) | fport,
+                tcp_v4_hash_rand) &
+        (tcp_ehash_size - 1);
  }

 >  static __inline__ int tcp_sk_hashfn(struct sock *sk)
 > @@ -2626,6 +2627,9 @@
 >          panic("Failed to create the TCP control socket.\n");
 >      tcp_socket->sk->sk_allocation   = GFP_ATOMIC;
 >      inet_sk(tcp_socket->sk)->uc_ttl = -1;
 > +
 > +    get_random_bytes(&tcp_v4_hash_rand, 4);
 > +    tcp_v4_hash_rand ^= jiffies;
 >
 >      /* Unhash it so that IP input processing does not even
 >       * see it, we do not wish this socket to see incoming
 >
 >



  reply	other threads:[~2007-03-22 22:03 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 [this message]
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             ` RFC: Established connections hash function Nikolaos D. Bougalis
2007-03-27 14:11 ` 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=4602FD18.7060902@cosmosbay.com \
    --to=dada1@cosmosbay$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=nikb@webmaster$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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