From patchwork Wed Apr 21 00:05:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 50605 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id AB49DB7D11 for ; Wed, 21 Apr 2010 10:05:26 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753849Ab0DUAFW (ORCPT ); Tue, 20 Apr 2010 20:05:22 -0400 Received: from mail-bw0-f225.google.com ([209.85.218.225]:38103 "EHLO mail-bw0-f225.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753633Ab0DUAFV (ORCPT ); Tue, 20 Apr 2010 20:05:21 -0400 Received: by bwz25 with SMTP id 25so7464008bwz.28 for ; Tue, 20 Apr 2010 17:05:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :in-reply-to:references:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=ulPOMMzyyEue+DnPk4/GR7+dXV775UkO0EFS+wxbjpQ=; b=K/aaEWhplWk9wlD/hjvTeVAxpURYN6T9qbyGlO6zJIZQ95iwGXhqeHLrtCJLsqo4KT uTnujeaINsGIBv4kn01Qyo6sxftC1fonfohpcpe+eAvF0txl/VtXIlzpadHyl7lvHxeB QZBaGO9z1EqMPOzJFMXb6Kyrv9a57jmYx6kV4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; b=BQ6Mz97suLL/RARez2KTfbqv3BTeDxO/sx8PMoL5FYBO+7mVNAafw0Be+7oFwVZhI2 X6ixRCAM6hJVcHeul+NXNY6cva6Rz9EoPcZ9KZfcWdxYqwmMtTh3FCMAV3YayErqmQ/0 s7z2AZJFcdYCiNDiPpJXAT8EWfJrfldhTt7xU= Received: by 10.204.132.194 with SMTP id c2mr6181623bkt.167.1271808319808; Tue, 20 Apr 2010 17:05:19 -0700 (PDT) Received: from [127.0.0.1] (gw1.cosmosbay.com [212.99.114.194]) by mx.google.com with ESMTPS id 13sm3919975bwz.7.2010.04.20.17.05.18 (version=SSLv3 cipher=RC4-MD5); Tue, 20 Apr 2010 17:05:19 -0700 (PDT) Subject: Re: PROBLEM: Linux kernel 2.6.31 IPv4 TCP fails to open huge amount of outgoing connections (unable to bind ... ) From: Eric Dumazet To: Ben Greear , David Miller Cc: Gaspar Chilingarov , netdev In-Reply-To: <4BCE3D8D.3030500@candelatech.com> References: <4BCE33B9.8050101@candelatech.com> <4BCE392F.60104@candelatech.com> <4BCE3D8D.3030500@candelatech.com> Date: Wed, 21 Apr 2010 02:05:14 +0200 Message-ID: <1271808314.7895.614.camel@edumazet-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Le mardi 20 avril 2010 à 16:49 -0700, Ben Greear a écrit : > On 04/20/2010 04:35 PM, Gaspar Chilingarov wrote: > > sysctl -a | grep local_port_range > > [root@ct503-10G-09 ~]# sysctl -a | grep local_port_range > net.ipv4.ip_local_port_range = 10000 61000 > > I'm explicitly binding to local ports as well as local IPs, btw. > I believe the bsockets 'optimization' is a bug, we should remove it. This is a stable candidate (2.6.30+) [PATCH net-next-2.6] tcp: remove bsockets count Counting number of bound sockets to avoid a loop is buggy, since we cant know how many IP addresses are in use. When threshold is reached, we try 5 random slots and can fail while there are plenty available ports. Signed-off-by: Eric Dumazet --- include/net/inet_hashtables.h | 2 -- net/ipv4/inet_connection_sock.c | 5 ----- net/ipv4/inet_hashtables.c | 5 ----- 3 files changed, 12 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index 74358d1..e0f3a05 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h @@ -150,8 +150,6 @@ struct inet_hashinfo { */ struct inet_listen_hashbucket listening_hash[INET_LHTABLE_SIZE] ____cacheline_aligned_in_smp; - - atomic_t bsockets; }; static inline struct inet_ehash_bucket *inet_ehash_bucket( diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 8da6429..0bbfd00 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -119,11 +119,6 @@ again: (tb->num_owners < smallest_size || smallest_size == -1)) { smallest_size = tb->num_owners; smallest_rover = rover; - if (atomic_read(&hashinfo->bsockets) > (high - low) + 1) { - spin_unlock(&head->lock); - snum = smallest_rover; - goto have_snum; - } } goto next; } diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index 2b79377..4bc921f 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -62,8 +62,6 @@ void inet_bind_hash(struct sock *sk, struct inet_bind_bucket *tb, { struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; - atomic_inc(&hashinfo->bsockets); - inet_sk(sk)->inet_num = snum; sk_add_bind_node(sk, &tb->owners); tb->num_owners++; @@ -81,8 +79,6 @@ static void __inet_put_port(struct sock *sk) struct inet_bind_hashbucket *head = &hashinfo->bhash[bhash]; struct inet_bind_bucket *tb; - atomic_dec(&hashinfo->bsockets); - spin_lock(&head->lock); tb = inet_csk(sk)->icsk_bind_hash; __sk_del_bind_node(sk); @@ -551,7 +547,6 @@ void inet_hashinfo_init(struct inet_hashinfo *h) { int i; - atomic_set(&h->bsockets, 0); for (i = 0; i < INET_LHTABLE_SIZE; i++) { spin_lock_init(&h->listening_hash[i].lock); INIT_HLIST_NULLS_HEAD(&h->listening_hash[i].head,