Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3433278
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:33:15+00:00 2026-05-18T07:33:15+00:00

While creating a netlink socket using netlink_kernel_create() a function pointer is passed as argument

  • 0

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?

Example Code

#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 my_nl_recv_msg(struct sk_buff *skb) {

struct nlmsghdr *nlh;  
int pid;  

printk(KERN_INFO "Entering: %s\n", __FUNCTION__);  

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 */  
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);

}

static int __init hello_init(void) {

printk("Entering: %s\n",__FUNCTION__);  
nl_sk=netlink_kernel_create(&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;

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T07:33:16+00:00Added an answer on May 18, 2026 at 7:33 am

    net/netlink/af_netlink.c:netlink_unicast_kernel, the caller of your my_nl_recv_msg function will take care of freeing it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While creating an online shop application using play-1.2.4 ,I ran into some problems with
While creating my horizontal menu using the <ul><li>....</li></ul> I came across a few behaviors
While creating complex procedures the whole function is treated as a transaction or If
I am facing a problem while creating a static cursor in DB2. This is
I am getting these error while creating bean id , Im using spring :
I am getting this error while creating a public method on a class for
I have run into an issue while creating a data service and using Autofac
While creating the sample, I noticed very strange behavior and due to which I
This relates somewhat to: InvalidOperationException while creating wcf web service instance I have a
I am using database in one of my application while creating database. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.