<div>Hi,</div>
<div>&nbsp;</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 &#39;6&#39;. </div>
<div>&nbsp;</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-&gt;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 &#39;1&#39;.</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>please see this code in net/socet.c </div>
<div>&nbsp;</div>
<div>static int __sock_create(int family, int type, int protocol, struct socket **res, int kern)<br>{</div>
<div>&nbsp;</div>
<div>---------------------------</div>
<div>--------------------------</div>
<div>&nbsp;/*<br>&nbsp; * We will call the -&gt;create function, that possibly is in a loadable<br>&nbsp; * module, so we have to bump that loadable module refcnt first.<br>&nbsp; */<br>&nbsp;i = -EAFNOSUPPORT;<br>&nbsp;if (!try_module_get(net_families[family]-&gt;owner))<br>
&nbsp;&nbsp;goto out_release;</div>
<div>&nbsp;if ((i = net_families[family]-&gt;create(sock, protocol)) &lt; 0)<br>&nbsp;&nbsp;goto out_module_put;<br>&nbsp;/*<br>&nbsp; * Now to bump the refcnt of the [loadable] module that owns this<br>&nbsp; * socket at sock_release time we decrement its refcnt.<br>
&nbsp; */<br>&nbsp;if (!try_module_get(sock-&gt;ops-&gt;owner)) {<br>&nbsp;&nbsp;sock-&gt;ops = NULL;<br>&nbsp;&nbsp;goto out_module_put;<br>&nbsp;}<br>&nbsp;/*<br>&nbsp; * Now that we&#39;re done with the -&gt;create function, the [loadable]<br>&nbsp; * module can have its refcnt decremented<br>
&nbsp; */<br>&nbsp;module_put(net_families[family]-&gt;owner);</div>
<div>&nbsp;</div>
<div>----------------------------------</div>
<div>---------------------------------</div>
<div>}</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</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&nbsp; so default reference count for 2.4 kernel is &#39;3&#39;.</div>
<div>&nbsp;</div>
<div>My doubt is that whether increment reference count by &#39;2&#39; when we are only opening one INET6 </div>
<div>socket is correct? While releasing socket it decrements the count by &#39;2&#39;.</div>
<div>&nbsp;</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>&nbsp;</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>