Netlink question

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

 




Hi,
 
I have a question upon some netlink api's.
What I want is to create a small packet in kernel space, then send it to userland where a program is listening and display's what it received.
Upon initializing I open up a socket:
 
#define NETLINK_TEST 17
DEFINE_MUTEX(mutex);
static struct sock * nl_sk = NULL;
 
 
void nl_input( struct sk_buff * skb)
{
 mutex_lock(&mutex);
 netlink_rcv_skb(skb, &knetlink_process);
 mutex_unlock(&mutex);
}

 
int nlmodule_init( void ) {

nl_sk = netlink_kernel_create(&init_net, NETLINK_TEST, nl_input, NULL, THIS_MODULE);
 if ( nl_sk == NULL ) {
  printk(KERN_INFO "netlink module initialization failed\n");
  return 1;
 }
 
 prinkt(KERN_INFO "Netlink socket created\n");
 return 0;
}
 
void nlmodule_exit( void )
{
 if ( nl_sk != NULL ) {
    sock_release( nl_sk->sk_socket );
 } else {
  printk("The socket is already NULL for some reason, don't release it\n");
 }
}
module_init( nlmodule_init );
module_exit( nlmodule_exit );
MODULE_LICENSE("GPL");

The initialization seems to go well, even though I do not give an skb as argument when calling nl_input.
So a socket is being created, that is, when I add a printk(KERN_INFO "pointer to socket: %p\n", (void*)knetlink_sk); I see a value, hence it must have succeeded. Am I doing anything wrong here?
This is not exactly what I want, because i just want to create a small packet and send it to the userland process listing. But I do need an input function like nl_input, otherwise I cannot create a socket.
Any advice on this one?
Thanks,
 
Reinoud.
  		 	   		  
_________________________________________________________________
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1--
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux