ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I could not figure out how to set the iptables rules from the kernel module itself.
As far as I am aware Linux does not use a pull but a push model. That is, the kernel does not (and should not ever) read userland data or exec arbitrary userland apps. Look at how iptables rule management or sysctls are handled for instance: userland reads from and supplies data to the kernel via /proc. Not the other way around. Linux Kernel Modules do not (and should not ever) muck with Netfilter Framework data the way you propose they should. That would be a grave violation.
Actually, now I am trying to write the rules into some file and reading the rules from user space and set the ip tables rules.
However, I am getting problem in writing and reading from the file. In my code, I am not getting any error and but not able to read and write into the file.
Could you please let me know where I am going wrong in my code?
...and to support arguments I submit http://www.linuxjournal.com/article/8110. Since you managed to crosspost your questions you would have seen that anyway. Note that crossposting (or necroposting for that matter) your questions, regardless of the motivation or reason, is considered unwanted at LQ. Please don't.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.