Hi All,
I am new babie kernel programming. I am create kernel module use
netlink to communicate to user space program. And the code is shown
bellow. When I debug: the result of netlink_kernel_create is not null,
but when i debug by printk out all the attribute is zero.
And, My user space program try to connect my kernel then my computer
was hang, debug by printing out the sk->receive_queue.qlen is a nagative
number ex: -797845. Could someone help me to solve this probelem, thank
you very much and appreciate for help.
struct sock *g_mntr_sock
g_mntr_sock=netlink_kernel_create(NETLINK_MONITOR,rc_input);;
if ( g_mntr_sock != NULL)
{
printk("Create socket netlink successfull \n");
printk("daddr %i, rcv_saddr %i, dport %i, local port %i
\n",g_mntr_sock->daddr,g_mntr_sock->rcv_saddr,g_mntr_sock->dport,g_mntr_sock->num);
printk("state %i, sport %i, family %i, rcvbuf %i
\n",g_mntr_sock->state,g_mntr_sock->sport,g_mntr_sock->family,g_mntr_sock->rcvbuf);
return 0;
}
return -1;
void rc_input(void){
printk("Number length %i \n",sk->receive_queue.qlen);
while((skb=skb_dequeue(&sk->receive_queue)) != NULL)
{
mntr_rcv_skb(skb);
nlh = (struct nlmsghdr *)skb->data;
//printk("%s: message received: %s n",__FUNCTION__,NLMSG_DATA(nlh));
send_to_user(skb);
//kfree_skb(skb);
}
}
Thanks
Nhanle
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/