Skip to contentSkip to conversation

Creating and sending a packet from a kernel module

DISCUSSION Nalin gupta 1 participant 1 message Mar 21, 2003

lore
Share & tools
lore
#0 lore raw

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

--

Quoted 7 lines · 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?

Quoted 9 lines

Is there an easy way to create and own a TCP socket from a module that I could send and receive on?

Thanks,
Josh

Signature · 1 line
Joshua Stewart <[email protected]>

_____________________________________________________________
Get 25MB, POP3, Spam Filtering with LYCOS MAIL PLUS for $19.95/year.
http://login.mail.lycos.com/brandPage.shtml?pageId=plus&ref=lmtplus