Skip to contentSkip to conversation

execution context in netfilter hooks.

DISCUSSION Giacomo 1 participant 1 message Dec 13, 2005 netfilter

lore
Share & tools
lore

Giacomo

author
#0 lore raw

Thank you very much for the answer.
The thing that confused me was that i had some
functions that registered with netfilter hooks.
I thought that processing was serialized, as you said
'in a queue'...
One of those functions was consulting a linked list, each entry in such list had a timer attached. When timer expired, the entry was freed.
After millions of packets processed by my function, a
crash happened. I solved the problem putting 'read_lock/unlock_bh' around linked list search and around timer expiry handler function.
I thought it was not possible that my function was interrupted, while instead things revealed that probably
i was unsafely freeing an entry in list which still had been used by another function.

read_locks during list_for_each while consulting list, together with write_locks around timeout handlers and
list_add solved.

So i'm trying to understand the reason why this happened, and if i am right to use read/write locks (_bh)
or if i would better use spin_locks (_bh) or spin locks together with _rcu version of lists.

When i said 'is it concerned with tasklets' i meant: after hardirq when receiving a packet, is the packet processing (and netfilter hook functions) registered as a tasklet to run later?

As to software timers, i thought they were interrupting the other routine scanning the linked list, as it resulted in the crash. But probably this was due to 'kernel on behalf of process' context in local output packets, as you said. (->does this mean no softirq context -> routine interruptible?)

I read a lot of documents, but they talk a lot about bottom halves, softirqs and tasklets, but perhaps some things have changed in 2.6.x, and then i thought that new kernel preemption would have made processing resemble SMP processing also un UP systems.

Excuse my many questions, but i would like to clarify those important issues...

Thanks a lot!

Giacomo
--

Giacomo S.
http://www.giacomos.it

- - - - - - - - - - - - - - - - - - - - - -

Running IPFIRE-wall on debian GNU/Linux
http://www.giacomos.it/ipfire
http://www.debian.org

mailto:
[email protected]
[email protected]
[email protected]

- - - - - - - - - - - - - - - - - - - - - -