title: Whose responsibility is it to free sk_buff
body: <p>While creating a netlink socket using <code>netlink_kernel_create()</code> a function pointer is passed as argument to this function which is called when a message is received on this socket. This call back function receives an <code>sk_buff</code> as parameter which contains the message received.</p>
  
  <p>My question is that whose responsibility is it to free this <code>sk_buff</code>?</p>
  
  <h2>Example Code</h2>
  
  <blockquote>
    <p>#include &lt;linux/module.h><br>
    #include &lt;net/sock.h><br>
    #include &lt;linux/netlink.h><br>
    #include &lt;linux/skbuff.h>  </p>
    
    <p>#define NETLINK_USER 31</p>
    
    <p>struct sock *nl_sk = NULL;</p>
    
    <p>static void my_nl_recv_msg(struct sk_buff *skb)   {</p>
  
  <pre><code>struct nlmsghdr *nlh;  
  int pid;  
  
  printk(KERN_INFO "Entering: %s\n", __FUNCTION__);  
  
  nlh=(struct nlmsghdr*)skb-&gt;data;  
  printk(KERN_INFO "Netlink received msg payload: %s\n",  
      (char*)NLMSG_DATA(nlh));  
  pid = nlh-&gt;nlmsg_pid; /*pid of sending process */  
  NETLINK_CB(skb).dst_group = 0; /* not in mcast group */  
  NETLINK_CB(skb).pid = 0;      /* from kernel */  
  //printk("About to send msg bak:\n");  
  //netlink_unicast(nl_sk,skb,pid,MSG_DONTWAIT);
  </code></pre>
    
    <p>}</p>
    
    <p>static int __init hello_init(void)  {</p>
  
  <pre><code>printk("Entering: %s\n",__FUNCTION__);  
  nl_sk=netlink_kernel_create(&amp;init_net, NETLINK_USER, 0,  
          my_nl_recv_msg, NULL, THIS_MODULE);  
  if(!nl_sk)  
  {  
      printk(KERN_ALERT "Error creating socket.\n");  
      return -10;  
  }  
  return 0;
  </code></pre>
    
    <p>}</p>
  </blockquote>