Netfilter: Ensuring serial packet delivery to the hooks ?
Hello Netfilter Team !
I have a question related to the kind of packet delivery in Netfilter.
I want to make some packet checks on hook PREROUTING and LOCALOUT. (That is the combination where I get all packets without doing the
same checks on the same packet multiple times, because a packet may pass several hooks on one host.)
May problem is, that the result of these checks must be known and applicable on all other hooks like FORWARD, where my program does other packet mangling things.
So, can I set a global flag when a packet passes PREROUTING or LOCALOUT, and then use this flag on hook FORWARD ?
May be, that at the time between the hooks PREROUTING (or LOCALOUT) and FORWARD another packet could come from the network (or process). This second packet will be handled regularly by my check routine on PREROUTING (or LOCALOUT). This would change the global flag and I will loose my first result related to the first packet, which will pass FORWARD soon.
My direct question: Does Netfilter ensure that each packet passes all hooks for which it is directed, before the next packet enters the hook chain ?
Mic
Quoted 8 lines · Michael Jung
So, can I set a global flag when a packet passes PREROUTING or LOCALOUT, and then use this flag on hook FORWARD ?
May be, that at the time between the hooks PREROUTING (or LOCALOUT) and FORWARD another packet could come from the network (or process). This second packet will be handled regularly by my check routine on PREROUTING (or LOCALOUT). This would change the global flag and I will loose my first result related to the first packet, which will pass FORWARD soon.
no, you would need to associate your flag with the packet (skb).
Quoted 3 lines
My direct question: Does Netfilter ensure that each packet passes all hooks for which it is directed, before the next packet enters the hook chain ?
no, luckily it doesn't. Imagine how scalability and SMP performance would suck if we did. You can have any number of packets even traversing the hooks simultaneously on a SMP system.
Quoted 1 line
Mic
Signature · 5 lines
- Harald Welte <[email protected]> http://www.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