LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to add kernel module to kernel source? (https://www.linuxquestions.org/questions/programming-9/how-to-add-kernel-module-to-kernel-source-322743/)

cranium2004 05-12-2005 09:56 AM

How to add kernel module to kernel source?
 
hello,
I have written a C code that i want to execute at each NF_IP_POST_ROUTING Netfilter hook?
How to add that C file to kernel source code? I dont want to load it from user space as code require to start its working with first outgoing packet send by computer.
regards,
cranium.

Matir 05-12-2005 10:06 AM

Just look at the way other modules are hooked in and follow that.

cranium2004 05-12-2005 11:02 AM

Other modules are located in /lib/modules/2.4.20-8/kernel/ and they are loaded automatically by kernel. what changes i have to do to add kernel module to /usr/src/linux/net/ipv4/netfilter directory?

Matir 05-12-2005 01:45 PM

You'll need to change up the Makefiles, kernel build tree, and many other sections. Config scripts too. Why add it to the kernel tree?

cranium2004 05-12-2005 09:04 PM

Quote:

Why add it to the kernel tree?
As already said module has code that is to be used by kernel network stack. once packets starts transmitting from linux machine they will have to go throgh my code.

Matir 05-12-2005 09:44 PM

If you are writing kernel-level code, you should have sufficient experience with the kernel to be able to simply add a file. If not, read the kernel documentation. If something seems unclear in the docs, I'd be happy to help clear it up.

syg00 05-12-2005 10:14 PM

Quote:

Originally posted by Matir
If you are writing kernel-level code, you should have sufficient experience with the kernel to be able to simply add a file. If not, read the kernel documentation.
That ought to keep a body off the streets for a night or two ... :study:
Quote:

If something seems unclear in the docs, I'd be happy to help clear it up.
Now, there's an offer too good to refuse.
I'll keep you in mind, Matir ... :p

Matir 05-12-2005 10:34 PM

Quote:

Originally posted by syg00
That ought to keep a body off the streets for a night or two ... :study:
Now, there's an offer too good to refuse.
I'll keep you in mind, Matir ... :p

LOL, keep in mind I said 'help'. I'm not Linus, or Andrew, or anything like that. :)

But really, adding another file to the kernel source is, I believe, well documented... somewhere. :)


All times are GMT -5. The time now is 01:09 PM.