From patchwork Tue Nov 11 11:08:47 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 8106 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.176.167]) by ozlabs.org (Postfix) with ESMTP id 0EE19DDE1C for ; Tue, 11 Nov 2008 22:05:30 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755403AbYKKLFZ (ORCPT ); Tue, 11 Nov 2008 06:05:25 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755385AbYKKLFZ (ORCPT ); Tue, 11 Nov 2008 06:05:25 -0500 Received: from ug-out-1314.google.com ([66.249.92.175]:45802 "EHLO ug-out-1314.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755371AbYKKLFY (ORCPT ); Tue, 11 Nov 2008 06:05:24 -0500 Received: by ug-out-1314.google.com with SMTP id 39so694547ugf.37 for ; Tue, 11 Nov 2008 03:05:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=5ujeX500C8sT+J4hDWK2eIo71ndrhouHikLJXhms48M=; b=DXjUfe+HAtWdHJtv400Vb1TCdiNmpl/czWqBq71T9EnmXmNpO9hII3zREnuYsNaNru 11aA+IwVorCpOcEptkGZEuhfgagpKDIa9JM1lVU9c+T6aKZwhZqArxNPgP+FMAk/uxF4 jjGqGeEmNAkgR7COv/OWogMFs7pJTpQPJTroc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=YetQPatX32E+I76Nb5F+A5fXIQ6AuigGCcA5ycMGzJF5oCcaAqUChf+/liNG4/+XRO 6Cam9lPjKnE68zH7jjOBTcWqyjnnFjEvFNH57EBrgbEgubiDwzM3fW7lpwEniGAsP8uz plBkVc2Wd/1sgWR+TmTJ0ZIxlCYL0KP0aenZU= Received: by 10.67.115.12 with SMTP id s12mr2800738ugm.40.1226401522092; Tue, 11 Nov 2008 03:05:22 -0800 (PST) Received: from localhost (gw.zunet.ru [217.67.117.64]) by mx.google.com with ESMTPS id 30sm10547511ugf.13.2008.11.11.03.05.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 11 Nov 2008 03:05:21 -0800 (PST) Date: Tue, 11 Nov 2008 14:08:47 +0300 From: Alexey Dobriyan To: David Miller Cc: dada1@cosmosbay.com, netdev@vger.kernel.org Subject: [PATCH] net: #ifdef inet_bind_bucket::ib_net Message-ID: <20081111110847.GC3665@x200.localdomain> References: <20081107174100.GA3469@x200.localdomain> <49147FAC.8070306@cosmosbay.com> <20081107180738.GA3657@x200.localdomain> <20081110.164424.167225199.davem@davemloft.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20081110.164424.167225199.davem@davemloft.net> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Signed-off-by: Alexey Dobriyan --- include/net/inet_hashtables.h | 11 +++++++++++ net/ipv4/inet_connection_sock.c | 4 ++-- net/ipv4/inet_hashtables.c | 6 +++++- 3 files changed, 18 insertions(+), 3 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 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h @@ -77,13 +77,24 @@ struct inet_ehash_bucket { * ports are created in O(1) time? I thought so. ;-) -DaveM */ struct inet_bind_bucket { +#ifdef CONFIG_NET_NS struct net *ib_net; +#endif unsigned short port; signed short fastreuse; struct hlist_node node; struct hlist_head owners; }; +static inline struct net *ib_net(struct inet_bind_bucket *ib) +{ +#ifdef CONFIG_NET_NS + return ib->ib_net; +#else + return &init_net; +#endif +} + #define inet_bind_bucket_for_each(tb, node, head) \ hlist_for_each_entry(tb, node, head, node) --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -109,7 +109,7 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum) hashinfo->bhash_size)]; spin_lock(&head->lock); inet_bind_bucket_for_each(tb, node, &head->chain) - if (tb->ib_net == net && tb->port == rover) + if (ib_net(tb) == net && tb->port == rover) goto next; break; next: @@ -137,7 +137,7 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum) hashinfo->bhash_size)]; spin_lock(&head->lock); inet_bind_bucket_for_each(tb, node, &head->chain) - if (tb->ib_net == net && tb->port == snum) + if (ib_net(tb) == net && tb->port == snum) goto tb_found; } tb = NULL; --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -35,7 +35,9 @@ struct inet_bind_bucket *inet_bind_bucket_create(struct kmem_cache *cachep, struct inet_bind_bucket *tb = kmem_cache_alloc(cachep, GFP_ATOMIC); if (tb != NULL) { +#ifdef CONFIG_NET_NS tb->ib_net = hold_net(net); +#endif tb->port = snum; tb->fastreuse = 0; INIT_HLIST_HEAD(&tb->owners); @@ -51,7 +53,9 @@ void inet_bind_bucket_destroy(struct kmem_cache *cachep, struct inet_bind_bucket { if (hlist_empty(&tb->owners)) { __hlist_del(&tb->node); +#ifdef CONFIG_NET_NS release_net(tb->ib_net); +#endif kmem_cache_free(cachep, tb); } } @@ -449,7 +453,7 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row, * unique enough. */ inet_bind_bucket_for_each(tb, node, &head->chain) { - if (tb->ib_net == net && tb->port == port) { + if (ib_net(tb) == net && tb->port == port) { WARN_ON(hlist_empty(&tb->owners)); if (tb->fastreuse >= 0) goto next_port;