Re: Creating and sending a packet from a kernel module

Nalin gupta (nalin_gupta@lycos.com)
Fri, 21 Mar 2003 01:07:13 -0500


Joshua Stewart,

I saw that you are trying something similar, to me. I also found
Mr. Gary too is trying something similar. Though I do not have
proper solution for your problem, but it may be worth if you go
through few of these recent postings:

http://www.uwsg.iu.edu/hypermail/linux/kernel/0303.2/0437.html
http://www.uwsg.iu.edu/hypermail/linux/kernel/0303.2/0971.html
http://www.uwsg.iu.edu/hypermail/linux/kernel/0303.2/0974.html
http://www.uwsg.iu.edu/hypermail/linux/kernel/0303.2/0984.html

http://www.uwsg.iu.edu/hypermail/linux/net/0303.2/0043.html
http://www.uwsg.iu.edu/hypermail/linux/net/0303.1/0061.html

The above posting will tell you few problem which one faces,
while invoking sock_sendmsg from kernel module, in particular
when it is either in interrupt context or BH (net_bh) context.

I still wonder why ?

Only possibility I see to send / recv TCP/IP packet from kernel
module is using kernel thread.

Important API / structures are:

a. sock_create - to create socket (like socket syscall)
b. struct socket * sock
c. sock->ops->bind to bind to local address
d. sock->ops->listen like listen syscall
e. sock_sendmsg (never succeed in interrupt or BH context,
always fail in alloc_skb, I wonder why ?)
f. sock_recvmsg - Ordinary kernel module logically can not use
it. As you need some running thread context to
wait/block to receive on socket.

I've tried answering as per my limited know-how.
Some one may like to add.

you may like to refer some example like khttpd under
/usr/src/linux/net

regards,
- nalin

--

On Thu, 20 Mar 2003 20:46:00 Joshua Stewart wrote: >I'd like to create and send a brand new TCP SYN packet from a module. >Does anybody have an example of how to do this. > >I've tried doing alloc_skb, filling in all the information I could >imagine needing in skb->data, but what is the minimal amount of stuff >needed by the other parts of the skb to get this packet moving? > >Is there an easy way to create and own a TCP socket from a module that I >could send and receive on? > >Thanks, > Josh > >-- >Joshua Stewart <joshua.stewart@comcast.net> >

_____________________________________________________________ Get 25MB, POP3, Spam Filtering with LYCOS MAIL PLUS for $19.95/year. http://login.mail.lycos.com/brandPage.shtml?pageId=plus&ref=lmtplus - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/