Netlink Socket in Linux Kernel

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

 



Hi,

I am experimenting netlink socket for kernel space to user space communication in linux 2.6.32 kernel.

My intension is to perform,

kernel space --------------> user space
kernel space <------------- user space

i have few questions,

1) how to determine the pid of the userspace process, if kernel is going to initiate the communication by sending the data.
Because, i have seen examples of netlink program where only user space process initiates the data flow by requesting.

2) When netlink receives the data from user space, it invokes the handler which runs in separate context, like below,

         driver_init()
          {
         netlink_kernel_create(&init_net, KNETLINK_UNIT, 0, knetlink_input, NULL, THIS_MODULE);
          }

       void knetlink_input( struct sk_buff * skb)
       {
        mutex_lock(&mut);
        netlink_rcv_skb(skb, &knetlink_process);
        mutex_unlock(&mut);
        }
  
       int knetlink_process( struct sk_buff * skb, struct nlmsghdr *nlh ) //receive data from userspace
       {
               //receive data .........
              //data is only available here
       }

         while (some condition) {
        my_function() //driver
        {
              get_data(data); -> where i get data
              netlink_unicast(data); ---------> send data to userspace
             // i have to process data here, and i do not have data availabe here...
            
         }
        }

can this way possible to implement , if possible, how it can be done,
              
               while (some condition) {  
                my_function () // driver
                {
                          get_data(data); -> where i get data
                          netlink_unicast(data); ---------> send data to userspace
                          netlink_receive(data); -----------> receive data from userspace
                          process data(data); //some processing on data
                          printk ("data");
                 }
               }
        
--
Thanks and Regards,
Harish Kumar. V

[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