Sending UDP packet in Linux Kernel

前端 未结 4 1452
礼貌的吻别
礼貌的吻别 2020-12-21 22:50

For a project, I\'m trying to send UDP packets from Linux kernel-space. I\'m currently \'hard-coding\' my code into the kernel (which I appreciate isn\'t the best/neatest wa

相关标签:
4条回答
  • 2020-12-21 23:27

    Run your code when you're in a text mode console (i.e. press Ctrl+Alt+F1 to go to the text console). This way a kernel panic will print out the stack trace and any extra information about what went wrong.

    If that doesn't help you, update your question with the stack trace.

    0 讨论(0)
  • 2020-12-21 23:28

    You may find it easier to use the netpoll API for UDP. Take a look at netconsole for an example of how it's used. The APIs you're using are more intended for userspace (you should never have to play with segment descriptors to send network data!)

    0 讨论(0)
  • 2020-12-21 23:38

    I'm not much of a Linux Kernel developer, but can you throw some printk's in there and watch dmesg before it goes down? Or have you thought about hooking up with a kernel debugger?

    0 讨论(0)
  • 2020-12-21 23:40

    I think you should try to put all variables outside mymethod() function and make them static. Remember, that the size of kernel stack is limited do 8KiB, so to much of/too big local variables may cause stack overflow and system hangup.

    0 讨论(0)
提交回复
热议问题