<div>Hi,</div>
<div> </div>
<div>while doing some testing on IPv6 code for 2.6 kernel, I found that the default reference count</div>
<div>for IPv6 module is '6'. </div>
<div> </div>
<div>When I went through the code I found that icmpv6_init(), ndisc_init() and igmp6_init() all increment</div>
<div>IPv6 refrence count by 2 each. as they call __sock_create() in socket.c which again calls </div>
<div>try_module_get() function twice and increment the count by 2. It also calls sock->create (which</div>
<div>is ptr to inet6_create function ) and this also increment refrence count by 1(because it calls sk_set_owner</div>
<div>which again calls __module_get()). and just before returning from __sock_create() it calls module_put so</div>
<div>derement refrence count by '1'.</div>
<div> </div>
<div> </div>
<div>please see this code in net/socet.c </div>
<div> </div>
<div>static int __sock_create(int family, int type, int protocol, struct socket **res, int kern)<br>{</div>
<div> </div>
<div>---------------------------</div>
<div>--------------------------</div>
<div> /*<br> * We will call the ->create function, that possibly is in a loadable<br> * module, so we have to bump that loadable module refcnt first.<br> */<br> i = -EAFNOSUPPORT;<br> if (!try_module_get(net_families[family]->owner))<br>
goto out_release;</div>
<div> if ((i = net_families[family]->create(sock, protocol)) < 0)<br> goto out_module_put;<br> /*<br> * Now to bump the refcnt of the [loadable] module that owns this<br> * socket at sock_release time we decrement its refcnt.<br>
*/<br> if (!try_module_get(sock->ops->owner)) {<br> sock->ops = NULL;<br> goto out_module_put;<br> }<br> /*<br> * Now that we're done with the ->create function, the [loadable]<br> * module can have its refcnt decremented<br>
*/<br> module_put(net_families[family]->owner);</div>
<div> </div>
<div>----------------------------------</div>
<div>---------------------------------</div>
<div>}</div>
<div> </div>
<div> </div>
<div> </div>
<div>so after the function returns, effective refrence count increment is 2 after each functions. I tried to compare </div>
<div>it with 2.4 kernel there it increments count by only 1 and so default reference count for 2.4 kernel is '3'.</div>
<div> </div>
<div>My doubt is that whether increment reference count by '2' when we are only opening one INET6 </div>
<div>socket is correct? While releasing socket it decrements the count by '2'.</div>
<div> </div>
<div>but I am not sure whether incrementing the reference count by 2 itself is correct or not. whether 2.4 kernel is </div>
<div>correct who increment refcount by 1 or kernel 2.6 is correct who increment by 2.</div>
<div> </div>
<div>Please comment if anyone have come across this.</div>
<div>Thanks in advance!<br clear="all"><br>-- <br>Thanks and Regards<br>Pramendra Singh<br>Larsen and Toubro Infotech Limited, <br></div>