Using netlink for kernel -> userspace communication

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

 



Hi all,
	Actually I have this problem, which is more fundamental really. I 
wanted to create a new message to send to the userspace. However everytime
I try to do so, using netlink_unicast, 0 bytes is sent. The listening
userspace application (using recvmsg) confirms that 0 bytes is received,
so I think a message IS sent from the kernel, but I don't understand why
I'm unable to send the entire message properly. Below is the code
	
	skb_nl = alloc_skb(NLMSG_SPACE(MAX_PAYLOAD), GFP_ATOMIC);
		
	if (skb_nl == NULL) {
		printk("%s: skb allocation fails!\n", __FUNCTION__);
		goto out;
	}
	
	nlh = (struct nlmsghdr *)skb_nl->data;
	
	/* Fill in the netlink message header */
	nlh->nlmsg_len = NLMSG_SPACE(MAX_PAYLOAD);
	nlh->nlmsg_pid = 0;
	nlh->nlmsg_flags = 0;
	/* Fill in the netlink message payload */
	strcpy(NLMSG_DATA(nlh), "Greeting from kernel!");
	
	NETLINK_CB(skb_nl).groups = 0;	/* not in mcast group */
	NETLINK_CB(skb_nl).pid = 0;	/* from kernel */
	NETLINK_CB(skb_nl).dst_pid = nlq_pid; /* pid of userspace process */
	NETLINK_CB(skb_nl).dst_groups = 0;	/* unicast */
	
	err = netlink_unicast(nl_sk, skb_nl, nlq_pid, MSG_DONTWAIT);

	I really do hope someone can shed some light from this problem.
	Thank you in advanced.

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