Using netlink for kernel -> userspace communication

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

 



Hi all,
	I have problems using netlink to send messages to my user
application.
When I use skb = skb_recv_datagram(), initially, to receive a message from
the 
userspace, and send it (netlink_unicast) back using the same skb pointer,
then 
I have no problem.
	However, the second time when I send the second time the kernel 
freezes. Below is the code:

	struct sk_buff *skb_nl = NULL;
	struct nlmsghdr *nlh = NULL;
	int err;

	// Netlink queue is my new netlink type
	nl_sk = netlink_kernel_create(NETLINK_QUEUE, nl_data_ready);
	
	skb_nl = skb_recv_datagram(nl_sk, 0, 0, &err);
	nlh = (struct nlmsghdr *)skb_nl->data;
	nlq_pid = nlh->nlmsg_pid;	
		
	NETLINK_CB(skb_nl).groups = 0;
	NETLINK_CB(skb_nl).pid = 0;	/* from kernel */
	NETLINK_CB(skb_nl).dst_pid = nlq_pid;
	NETLINK_CB(skb_nl).dst_groups = 0;
	
	err = netlink_unicast(nl_sk, skb_nl, nlq_pid, MSG_DONTWAIT);
	
	err = netlink_unicast(nl_sk, skb_nl, nlq_pid, MSG_DONTWAIT);

	Hope somebody can explain what happens.

cheers
Chiang   

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[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