Index: [Article Count Order] [Thread]

Date: Fri, 7 Nov 2008 02:43:28 -0800
From: "Pramendra Singh" <pramendra.singh@lntinfotech.com>
Subject: [users:00983] Reference Count Problem in IPv6?
Sender: pramendrasinghsomvanshi@gmail.com
To: users@tahi.org
Message-Id: <b24d89f60811070243qb04ca7q839995de61b58f45@mail.gmail.com>
X-Mail-Count: 00983

Hi,

while doing some testing on IPv6 code for 2.6 kernel, I found that the
default reference count
for IPv6 module is '6'.

When I went through the code I found that icmpv6_init(), ndisc_init() and
igmp6_init() all increment
IPv6 refrence count by 2 each. as they call __sock_create() in socket.c
which again calls
try_module_get() function twice and increment the count by 2. It also calls
sock->create (which
is ptr to inet6_create function ) and this also increment refrence count by
1(because it calls sk_set_owner
which again calls __module_get()). and just before returning from
__sock_create() it calls module_put so
derement refrence count by '1'.


please see this code in net/socet.c

static int __sock_create(int family, int type, int protocol, struct socket
**res, int kern)
{

---------------------------
--------------------------
 /*
  * We will call the ->create function, that possibly is in a loadable
  * module, so we have to bump that loadable module refcnt first.
  */
 i = -EAFNOSUPPORT;
 if (!try_module_get(net_families[family]->owner))
  goto out_release;
 if ((i = net_families[family]->create(sock, protocol)) < 0)
  goto out_module_put;
 /*
  * Now to bump the refcnt of the [loadable] module that owns this
  * socket at sock_release time we decrement its refcnt.
  */
 if (!try_module_get(sock->ops->owner)) {
  sock->ops = NULL;
  goto out_module_put;
 }
 /*
  * Now that we're done with the ->create function, the [loadable]
  * module can have its refcnt decremented
  */
 module_put(net_families[family]->owner);

----------------------------------
---------------------------------
}



so after the function returns, effective refrence count increment is 2 after
each functions. I tried to compare
it with 2.4 kernel there it increments count by only 1 and  so default
reference count for 2.4 kernel is '3'.

My doubt is that whether increment reference count by '2' when we are only
opening one INET6
socket is correct? While releasing socket it decrements the count by '2'.

but I am not sure whether incrementing the reference count by 2 itself is
correct or not. whether 2.4 kernel is
correct who increment refcount by 1 or kernel 2.6 is correct who increment
by 2.

Please comment if anyone have come across this.
Thanks in advance!

-- 
Thanks and Regards
Pramendra Singh
Larsen and Toubro Infotech Limited,

	

983_2.html (attatchment)(tag is disabled)