<font face="courier new,monospace">Thanks Jeff for the reply. Yes; after changing the double pointer to a Normal Pointer., I can see that ., &quot;if&quot; block was skipped. <br><br>-Thnx,<br>VKS<br></font><br><div class="gmail_quote">
On Tue, Nov 22, 2011 at 12:50 AM, Jeff Haran <span dir="ltr">&lt;<a href="mailto:jharan@bytemobile.com">jharan@bytemobile.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div link="blue" vlink="purple" lang="EN-US"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt"><div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in"><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> <a href="mailto:kernelnewbies-bounces@kernelnewbies.org" target="_blank">kernelnewbies-bounces@kernelnewbies.org</a> [mailto:<a href="mailto:kernelnewbies-bounces@kernelnewbies.org" target="_blank">kernelnewbies-bounces@kernelnewbies.org</a>] <b>On Behalf Of </b>Kesava Srinivas<br>
<b>Sent:</b> Monday, November 21, 2011 11:03 AM<br><b>To:</b> <a href="mailto:kernelnewbies@kernelnewbies.org" target="_blank">kernelnewbies@kernelnewbies.org</a><br><b>Subject:</b> sock_buff is NULL !<u></u><u></u></span></p>
</div></div><div><div class="h5"><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">HI Team,</span><br><br><span style="font-family:&quot;Courier New&quot;">Trying to make this code work; but some how it is entering the if condition mentioned below.sock_buff is still a NULL Pointer.I can see that Function was registered with the Ipv4 Hooks. Any ideas/scenarios where the sock_buff remains as NULL Pointer??? Testing this code by trying to do ssh with this machine.<br>
<br>Any Help is really appreciated !!<br><br>#########<br>static struct nf_hook_ops netfilter_ops;<br>struct sk_buff *sock_buff;<br><br>unsigned int main_hook(unsigned int hooknum,struct sk_buff **skb,const struct net_device *in,const struct net_device *out,int (*okfn)(struct sk_buff*)) {<br>
 sock_buff = *skb;<br>        if(!sock_buff){<br>           printk(KERN_ERR &quot;Entered unexpected loop \n&quot;);<br>               return NF_ACCEPT;<br>         }/* Check for sk_buff NULL */<br>}<br>int init_module()<br>
{<br>        netfilter_ops.hook              =       (nf_hookfn *) main_hook;<br>        netfilter_ops.hooknum           =       NF_INET_PRE_ROUTING;<br>        <a href="http://netfilter_ops.pf" target="_blank">netfilter_ops.pf</a>                =       PF_INET;<br>
        netfilter_ops.priority          =       NF_IP_PRI_FIRST;<br>        nf_register_hook(&amp;netfilter_ops);<br>                                                                                                                                                      <br>
}<br>######################<br><br><br>-Thnx,<br>VKS<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p>
</div></div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Which kernel version are you using? The function prototype of a netfilter hook does vary from kernel version to kernel version, but in the kernels I’ve seen the skb parameter is a typed sk_buff *skb, not sk_buff **skb. In other words, you get passed a pointer to the sk_buff, not the address of a pointer to an sk_buff.<span class="HOEnZb"><font color="#888888"><u></u><u></u></font></span></span></p>
<span class="HOEnZb"><font color="#888888"><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Jeff Haran<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p></font></span></div></div><font face="monospace"></font></div></blockquote>
</div><br><br clear="all"><br>-- <br><font style="font-family:courier new,monospace" size="2">-VKS</font><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Masters,Computer Science&amp;Engineering.</span><br>
<br>