From patchwork Fri Nov 26 10:47:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 73164 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 A1758B70A9 for ; Fri, 26 Nov 2010 21:48:09 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754586Ab0KZKsD (ORCPT ); Fri, 26 Nov 2010 05:48:03 -0500 Received: from mail-fx0-f46.google.com ([209.85.161.46]:43827 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754430Ab0KZKsC (ORCPT ); Fri, 26 Nov 2010 05:48:02 -0500 Received: by fxm15 with SMTP id 15so587721fxm.19 for ; Fri, 26 Nov 2010 02:48:00 -0800 (PST) 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=iHE/cFczJ9dOrkyXZhxl5FEnZTQ8KF8cCFWX/ee7B1Q=; b=cJu4Kqyt4Mc6RoqSvBSByvSAXse710dc1ajTGtohBApnW7ix1wnPFH0nA1Sw9v3jpo GmglYMCw2pmrctZlrbG9ErTzVNE1WuQqAA8uD0DL+idWe9Y+xaiYa9ko5XdN18hwy2wD ADFpAsrSqRNaicDSLibjW8yin1Ov1S9FC/KTM= 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=nkRokjTUwm6V+phBsffTt6u/upPvGW3Rs6Y4NPEJ7jrsDnkVvSGuYCyPqUsK1jR78R URbHil/PUo0q29yIJWYDDPFkiLbYMSwbPRNFj/0ylXtvEY+xtWW5SPWCCWj8BUMXXv3L wYsT1HtUmzr5fv72WP//zqEsAd95KIjA8i4KU= Received: by 10.223.123.142 with SMTP id p14mr1872233far.122.1290768480580; Fri, 26 Nov 2010 02:48:00 -0800 (PST) Received: from [10.150.51.211] (gw0.net.jmsp.net [212.23.165.14]) by mx.google.com with ESMTPS id e17sm433851fak.34.2010.11.26.02.47.58 (version=SSLv3 cipher=RC4-MD5); Fri, 26 Nov 2010 02:47:59 -0800 (PST) Subject: Re: [PATCH] net: Fix __inet_inherit_port() to correctly increment bsockets and num_owners From: Eric Dumazet To: Nagendra Tomar Cc: netdev@vger.kernel.org, davem@davemloft.net, Evgeniy Polyakov In-Reply-To: <751926.73238.qm@web53707.mail.re2.yahoo.com> References: <751926.73238.qm@web53707.mail.re2.yahoo.com> Date: Fri, 26 Nov 2010 11:47:57 +0100 Message-ID: <1290768477.2855.97.camel@edumazet-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Nagendra Tomar Le vendredi 26 novembre 2010 à 01:40 -0800, Nagendra Tomar a écrit : > > --- On Fri, 26/11/10, Eric Dumazet wrote: > > > > > OK so you'll have to make a proof, because current code > > seems to work ;) > > > > > > ok, so I printed hashinfo->bsockets and tb->num_owners inside > __inet_put_port() and I could see both of them to be -ve. All we need > to do is establish and terminate a connection. I used netcat for that. > > The only place 'bsockets' and 'num_owners' are used is > inet_csk_get_port() and the only effect that they might have is on the > choice of the port to be used for binding. > 'bsockets' is used as a hint to stop searching for a free port (and > instead share an already used port) when we know that all the ports > could be used up. > 'num_owners' is used to find the port which is least shared (to > balance the 'owners' list) in case we need to share a port. > > Since both of these are used as optimizations (in the bind path), they > do not affect correctness and hence the code works even with these > values not being updated correctly. Hmm, thanks for clarification. bsockets / mnum_owners iscount is indeed an 'optimization' problem. Problem is your patch is not applicable to current tree. In order to submit it to stable team, you should first post a patch for next/current kernel (net-next-2.6 tree). David will decide if its net-2.6 material or not. You could add in your changelog the problem comes from commit a9d8f9110d7e953c (inet: Allowing more than 64k connections and heavily optimize bind(0)), included in 2.6.30, to ease stable team work. On current tree your patch would be : --- 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/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index 1b344f3..3c0369a 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -133,8 +133,7 @@ int __inet_inherit_port(struct sock *sk, struct sock *child) } } } - sk_add_bind_node(child, &tb->owners); - inet_csk(child)->icsk_bind_hash = tb; + inet_bind_hash(child, tb, port); spin_unlock(&head->lock); return 0;