Re: Getting netlink socket creation returns NULL in the kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



My actual goal is to develop kernel space and user space programs to establish communication in which kernel should initiate the communication. The kernel will send information (e.g., guest physical address from handle_ept_violation() in vmx.c, finding the corresponding page of that address, owner process (or if possible the application, i.e., VLC, open office) of the page, process/application releasing the page) at run time to the user space application.
I have written code  consists of three file i.e., netlink_kernel_module.c, netlink_kernel_space.h, netlink_user_module.c.  "netlink_kernel_module.c" contains just kernel loading/ unloading module functions i.e., __init hello_init(), and _exit hello_exit().  "netlink_kernel_space.h" contains all the rest of the kernel space code for sending/ receiving data while   "netlink_user_module.c" contains the user space application code for sending/receiving data. 

During development and testing I use  "netlink_kernel_module.c" to load and unload kernel module, in which the "__init hello_init()" just call the "create_socket(int data)" defined in  "netlink_kernel_space.h" with the data which I want to pass to the user space program. And my code works perfectly in this way. 

But, To get the required data from the kernel in real time, I include  " netlink_kernel_space.h " in kernel file i.e., vmx.c and call the  "create_socket(int data)"  from the handle_ept_voilation() defined in vmx.c after line#5098. I compile, and install the kernel, and reboot the system (and thus I don't need  "netlink_kernel_module.c"  because I don't load/unload the kernel module but include  "netlink_kernel_space.h"  in the vmx.c by using #include "netlink_kernel_space.h").  But, I am getting “NULL” while creating socket (nl_sk = NULL in nl_sk = netlink_kernel_create(&init_net, NETLINK_USER, &cfg);). Here code also shows weird behaviour. If I put 1-3 seconds sleep just before the socket creating statement, then it works just during booting of the virtual machine, after successful boot I get the same socket NULL error. Please find the code in the attachment..
Thank you very much.

On Wed, Oct 16, 2019 at 11:29 PM Valdis Klētnieks <valdis.kletnieks@xxxxxx> wrote:
On Wed, 16 Oct 2019 13:54:08 +0900, Irfan Ullah said:

> developed kernel space, and user space programs.  Kernel and user space
> programs working perfectly when I load and run these modules from the
> terminal using “sudo insmod kernelmodule.ko”, and “./userspaceApp”
> respectively.  But, when I try to use kernel program  (directly as a header
> file #include "kernelmodule.h") with the kernel original file that is
> “vmx.c” then it returns “NULL” while creating socket (nl_sk = NULL in nl_sk

You're going to have to explain in more detail what you're doing, and possibly
share your code.  "when I try to use kernel program directly" doesn't make sense....



--
Best Regards,


Mr. Irfan Ullah
PhD Candidate
Data and Knowledge Engineering(DKE) Lab
Department of Computer Science and Engineering
Kyung Hee University, South Korea.
 +82-010-591-51651
 sahibzada_irfanullah

Attachment: Kernel_User_comm.zip
Description: Zip archive

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux