Re: Allocating struct sock from kernel module

2010-06-29 Thread Peter Teoh
Well.all that u are trying to do is not really allowed, as inside af_inet.c the variable inetsw_array is defined as static: /* Upon startup we insert all the elements in inetsw_array[] into * the linked list inetsw. */ static struct inet_protosw inetsw_array[] = and so only those functions

Re: Allocating struct sock from kernel module

2010-06-29 Thread Jim Sansing
This is what I suspected, but thanks for the confirmation. I have come up with a work around by opening a raw socket in user space, intercepting it using netfilter, and grabbing the 'struct sock'. I think it is a kludge, but it is working and probably safer than sticking my nose where it

Allocating struct sock from kernel module

2010-06-28 Thread Jim Sansing
I am trying to send a Raw packet from my kernel module. I found what I hoped was a good example, but it came with the warning that allocating the 'struct sock' was the tricky part, which is where I am now. I want to use sk_alloc, which is defined as: struct sock *sk_alloc(struct net *net,