LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-09-2008, 06:05 PM   #1
ttthdl
LQ Newbie
 
Registered: Jun 2003
Posts: 3

Rep: Reputation: 0
Netfilter module help


Hi all,
I am writing a kernel module that hooks into netfilter.
netfilter_ops.hook = main_hook;
netfilter_ops.pf = PF_INET;
netfilter_ops.hooknum = NF_IP_PRE_ROUTING;
netfilter_ops.priority = NF_IP_PRI_FIRST;
nf_register_hook(&netfilter_ops);

In the main_hook function, I needs to put the process to sleep and
will be woken up by another process because the decision to Accept or
Deny a packet depends on a process running in the user space. However,
all sleeping mechanisms I tried cause the kernel hang. I tried msleep,
wait_event_interrupt,wait_event_interrupt_timeout,... (of course I
have a process to wake up the main_hook process). I tested these
sleeping machenisms in different modules and they worked fine. My
question is can we make the process sleep in the main_hook function
without causing the kernel hang and how to do it?
Thank you very much.
Tung.
 
Old 07-12-2008, 05:10 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
From what I know you can't do this this way. I'd rather place the packet on some list and continue the main loop. Then, after you receive the decision, you can find the right packet and perform the desired action.

Also, note that packets can be received very fast and your application may be simply too slow to pass decision in real-time!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I create the netfilter ip-strings module for a linux linux-2.6.18.2-34 kernel? jeffn Linux - Security 1 01-30-2008 06:39 AM
questions about register myself module onto netfilter linwenyuan Linux - Kernel 1 03-12-2007 06:29 PM
howto load netfilter module..? minike Slackware 2 08-13-2006 08:14 PM
netfilter/iptables in kernel: module vs static -Nw- neX Linux - Security 5 03-25-2005 06:44 PM
Help installing custom netfilter module TySoft Linux - Networking 3 08-04-2003 04:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration