Hello,

Sorry; I did not completed my message; here is the full one:

 Thanks a lot for your answer !

Following your answer I did some reading in LDD3 and
"Undersatnding the linux kernel" and I want to
verify if I may that I understood the interrupts mechanism right
regarding my nethooks question:

Suppose I will add another hook , of type NF_IP_FORWARD, with a callback
method named fw_hook(), to my exsiting NF_IP_PRE_ROUTING hook in my module.

As I understand, I can be sure that my_hook() and also fw_hook()
will not be called a second time when an
interrupt on the NIC arrives (when working on a single  CPU)
because they both are run under the same context (softirq context probably).

So in fact, I do not have to worry about shared data structures
which may appear in both hook methods (my_hook() and fw_hook())

Am i right ?
John

On 10/30/05, Harald Welte <[EMAIL PROTECTED]> wrote:
> On Sat, Oct 29, 2005 at 03:39:30PM +0200, John Que wrote:
> > Hello,
> >   I have written a module which uses NF_HOOKS for diverting packets to
> > a different destination.
> >
> >   My hook uses NF_IP_PRE_ROUTING.
> >
> >       I call nf_register_hook() where the hook method is called my_hook().
> >
> >   I see that indeed packets are reaching my hook method , my_hook().
> >
> >   My question is :
> >
> >   As I understand, the packets are reaching this method every
> > interrupt of the Network Card for receiving
>
> netfilter hooks are not related to interrupts.  they're called from
> whatever context they're called from, mostly network receive softirq,
> sometimes process context (LOCAL_OUT).
> >
> >   Or to be more accurate:
> >
> >   My question is : let's say that a packet sent to my machine reaches
> > my_hook() method,
> >
> >    and let's say that another packets are received on the NIC at the
> > same time while
> >
> >    the my_hook() method did not finished to process the previous
> > packet. (there is a very high
> >
> >    rate of sending packets to my machine).
> >
> >    Is there a possiblility that my_hook() will be called on a second
> > and third packets while still
>
> I suggest you do some basic reading on linux kernel development and the
> related contexts.  What you're looking for is "what happens when a
> hardirq interrupts softirq context".
>
> Short reply: my_hook() will not be called a second time on the same cpu,
> ubt will be called any number of times in parallel on multiple cpus.
>
> --
> - Harald Welte <[EMAIL PROTECTED]>                 http://netfilter.org/
> ============================================================================
>   "Fragmentation is like classful addressing -- an interesting early
>    architectural error that shows how much experimentation was going
>    on while IP was being designed."                    -- Paul Vixie
>
>
>
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to