public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Nagendra Tomar <tomer_iisc@yahoo.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net
Subject: Re: [PATCH] net: Fix __inet_inherit_port() to correctly increment bsockets and num_owners
Date: Fri, 26 Nov 2010 08:20:31 +0100	[thread overview]
Message-ID: <1290756031.2678.15.camel@edumazet-laptop> (raw)
In-Reply-To: <801098.19711.qm@web53707.mail.re2.yahoo.com>

Le jeudi 25 novembre 2010 à 21:09 -0800, Nagendra Tomar a écrit :
> inet sockets corresponding to passive connections are added to the bind hash
> using ___inet_inherit_port(). These sockets are later removed from the bind 
> hash using __inet_put_port(). These two functions are not exactly symmetrical. 
> __inet_put_port() decrements hashinfo->bsockets and tb->num_owners, whereas 
> ___inet_inherit_port() does not increment them. This results in both of these 
> going to -ve values.
> 
> This patch fixes this by calling inet_bind_hash() from ___inet_inherit_port(),
> which does the right thing.
> 
> Signed-off-by: Nagendra Singh Tomar <tomer_iisc@yahoo.com>
> 
> ---
> --- linux-2.6.36.1/net/ipv4/inet_hashtables.c.orig	2010-11-25 14:56:37.902456597 -0500
> +++ linux-2.6.36.1/net/ipv4/inet_hashtables.c	2010-11-25 15:44:15.038403317 -0500
> @@ -107,12 +107,10 @@ void __inet_inherit_port(struct sock *sk
>  	const int bhash = inet_bhashfn(sock_net(sk), inet_sk(child)->inet_num,
>  			table->bhash_size);
>  	struct inet_bind_hashbucket *head = &table->bhash[bhash];
> -	struct inet_bind_bucket *tb;
>  
>  	spin_lock(&head->lock);
> -	tb = inet_csk(sk)->icsk_bind_hash;
> -	sk_add_bind_node(child, &tb->owners);
> -	inet_csk(child)->icsk_bind_hash = tb;
> +	inet_bind_hash(child, inet_csk(sk)->icsk_bind_hash, 
> +			inet_sk(child)->inet_num);
>  	spin_unlock(&head->lock);
>  }
>  EXPORT_SYMBOL_GPL(__inet_inherit_port);
> ---
> 

Interesting, how did you notice it is wrong ?




  reply	other threads:[~2010-11-26  7:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-26  5:09 [PATCH] net: Fix __inet_inherit_port() to correctly increment bsockets and num_owners Nagendra Tomar
2010-11-26  7:20 ` Eric Dumazet [this message]
2010-11-26  7:49   ` Nagendra Tomar
2010-11-26  8:23     ` Eric Dumazet
2010-11-26  9:40       ` Nagendra Tomar
2010-11-26 10:47         ` Eric Dumazet
2010-11-26 11:01           ` Nagendra Tomar
2010-11-26 11:07           ` Evgeniy Polyakov
2010-11-26 11:20             ` Nagendra Tomar
2010-11-26 15:56               ` Evgeniy Polyakov
2010-11-27  0:01           ` [PATCH] net-next: " Nagendra Tomar

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=1290756031.2678.15.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=tomer_iisc@yahoo.com \
    /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