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 7627639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:29:10+00:00 2026-05-31T05:29:10+00:00

I am trying to write a module which is similar to ping. The problem

  • 0

I am trying to write a module which is similar to ping. The problem is coming in receiving the packet. The code is shown below:

#include<asm/uaccess.h>
#include<linux/sched.h>
#include<linux/wait.h>
#include<linux/netfilter.h>
#include<linux/netfilter_ipv4.h>

struct net_device *dev;
struct sk_buff *skb;
struct napi_struct *rnapi;

int rrpoll(struct napi_struct *napi,int budget)
{
   printk(KERN_ALERT"we are HEARRR%s,%d\n",__func__,__LINE__);
   skb = (struct sk_buff *)kmalloc(sizeof(struct sk_buff *),GFP_KERNEL);
   netif_receive_skb(skb);
   kfree(skb);
   return 0;
  }

static int rec_init(void)
{
  dev =  __dev_get_by_name(&init_net,"wlan0");
  rnapi = (struct napi_struct *)kmalloc(sizeof(struct napi_struct *),GFP_KERNEL);
  netif_napi_add(dev,rnapi,&rrpoll,100);
  napi_schedule(rnapi);
  return 0;
  }

static void rec_exit(void)
{
  //napi_complete(rnapi);
    netif_napi_del(rnapi);
}

The modules compiles and runs without any error, but the whole system hangs after some time.

  • 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-31T05:29:11+00:00Added an answer on May 31, 2026 at 5:29 am

    I see a couple of problems with your sample code:

    1. the skb should be allocated by alloc_skb() not kmalloc
    2. after you call netif_receive_skb, you should not free the skb. Your code is no longer the owner of that skb since you’ve given it to the network stack.
    3. I don’t see you filling in the skb in any way. Maybe you are just simplifying the code. But as it is now, you are sending up an uninitialized (or if you use alloc_skb, initialized but empty) skb to the networking stack.

    Michael

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

Sidebar

Related Questions

I am trying to write a MSBuild logger module which logs information when receiving
I'm trying to write a small Python module which contain some mathematical functions. For
I'm trying to write a kernel module, which prints some information about the objects
I am trying to write a generic module to extend the World class. I
I'm trying to write a unit test for a module that will give me
currently I am trying to write to an 20x4 LCD Dot-Matrix Module using Perle's
I'm trying write a query to find records which don't have a matching record
What I'm trying to do is to write some Maven plugin which scans application
I'm trying to work with sockets and I have such problem In code example:
I am trying to write a module with some c and some python parts.

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.