Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 07-23-2010, 03:24 AM   #1
LQ Newbie
Registered: Jul 2010
Posts: 1

Rep: Reputation: 0
Post Whose responsibility is it to free sk_buff

While creating a netlink socket using netlink_kernel_create() 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 sk_buff as parameter which contains the message received.

My question is that whose responsibility is it to free this sk_buff?

Also plz take a look at the following code. Here i get a new skb to send reply to user program but when i call nlmsg_free() on it, my machine hangs and I hav to restart

#include <linux/module.h>
#include <net/sock.h>
#include <linux/netlink.h>
#include <linux/skbuff.h>

#define NETLINK_USER 31

struct sock *nl_sk = NULL;

static void hello_nl_recv_msg(struct sk_buff *skb)
struct nlmsghdr *nlh;
int pid;
struct sk_buff *skb_out;
int msg_size,real_size;
char *msg="Hello from kernel";
int res;
skb_out = nlmsg_new(msg_size,0);

nlh=(struct nlmsghdr*)skb->data;
printk(KERN_INFO "Netlink received msg payload: %s\n",(char*)nlmsg_data(nlh));
pid = nlh->nlmsg_pid; /*pid of sending process */

printk(KERN_ERR "Failed to allocate new skb\n");

NETLINK_CB(skb_out).dst_group = 0; /* not in mcast group */
//NETLINK_CB(skb_out).pid = 0; /* from kernel */
printk("About to send msg bak:\n");
printk(KERN_INFO "Error while sending bak to user\n");

static int __init hello_init(void)
printk("Entering: %s\n",__FUNCTION__);
nl_sk=netlink_kernel_create(&init_net, NETLINK_USER, 0, hello_nl_recv_msg, NULL, THIS_MODULE);
printk(KERN_ALERT "Error creating socket.\n");
return -10;
return 0;

static void __exit hello_exit(void){
printk(KERN_INFO "exiting hello module\n");


Thank you and I highly appreciate your help
Old 07-23-2010, 02:16 PM   #2
Senior Member
Registered: Apr 2009
Posts: 1,507

Rep: Reputation: 137Reputation: 137
Network device driver will free sk_buff.


kernel, netlink

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is my responsibility for being a tor relay? pielas General 4 07-23-2010 11:22 AM
LXer: Computer Take Back Campaign places recycling responsibility on manufacturers LXer Syndicated Linux News 0 09-27-2007 02:00 AM
LXer: Computer Take Back Campaign places recycling responsibility on manufacturers LXer Syndicated Linux News 0 09-27-2007 01:21 AM
LXer: W3C, Accessibility and the Web: A Shared Responsibility LXer Syndicated Linux News 0 04-14-2007 07:02 PM
Firefox 1.0.7 root administrator responsibility Fedora 4 landonmkelsey Linux - General 2 11-03-2005 10:45 AM > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07:24 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration