Sending small UDP packets from the Linux Kernel to LOOPBACK

前端 未结 1 337
耶瑟儿~
耶瑟儿~ 2021-01-20 20:46

Situation: My code is basically hacked into a driver of the Linux Kernel. I want to notify an application in user space about noteworthy raw events before they get fired off

相关标签:
1条回答
  • 2021-01-20 21:19

    Since it sometimes works and sometimes doesn't I'd suggest the problem is that you are looking at memory which has been free()d. Thus the contents are sometimes correct and sometimes they are mangled. Since your local buffer is fine this must be occurring in the kernel before it is copied to local memory.

    Indeed is the unsigned char testmsg[] declared as a local variable?

    Since the message isn't sent straight away the testmsg address that you pass is on the stack. If there are subsequent functional calls then they will over write the contents of the message before it is sent. Then you will sometimes see the correct message and sometimes not. Depending on the scheduling of the work.

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