All of lore.kernel.org
 help / color / mirror / Atom feed
* Is a match-all rule with jump to empty chain processed?
@ 2010-09-14 15:14 Data Shock
  2010-09-14 17:57 ` Jan Engelhardt
  0 siblings, 1 reply; 3+ messages in thread
From: Data Shock @ 2010-09-14 15:14 UTC (permalink / raw)
  To: netfilter


I have an optimization question regarding iptables:  Will a rule that matches all packets and jumps to a defined but empty table be processed? And if so, how much overhead is involved with jumping to an empty table?

For example, assume that I am starting with a totally empty set of rules.  Then I add these rules:

-t filter -N empty_chain
-t filter -A INPUT -j empty_chain


I tested this myself and used "iptables -t filter -L -n -v" and could see that the number of packets and bytes were increasing on the "INPUT -j empty_chain" rule, so I assume that means it is being processed.  The empty_chain chain has no rules, so there was no packet/data information.  What kind of overhead is involved here? Is there any optimization performed internally when a chain is known to be empty?


Some of you may be curious why in the world I would want to do this.  Here is the (way simplified) scenario:

I have a process that manages the iptables rules.  It generates a file that can be loaded with iptables-restore.  Under normal circumstances, this process is the authority for iptables rules.  But, there may be some situations where a cron job needs to add a temporary override.  I had originally planned to have an empty chain named "overrides" along with a corresponding rule at the top of the filter/INPUT chain that would jump to the overrides chain. All other regular rules would follow the "overrides" jump rule. *Please ignore any security issues you might imagine for now. I'm over simplifying the situation for this example.

When an override is required, like "allow all UDP destined for port 1234", the cron job could run a simple "iptables -t filter -A overrides -p udp -m udp --dport 1234 -j ACCEPT".  When the override was no longer needed, it could simply flush the overrides chain.


Under normal operation the overrides chain would be empty.  I hate to spend overhead processing the "match all jump to overrides" rule.  I know the optimal way is really to add and remove the "-j overrides" rule as needed, but the simplicity of the cron job working with just the overrides chain is appealing.


So, does anyone with knowledge of the inner workings have an idea about overhead and possible optimization?
 		 	   		  

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-09-14 20:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-14 15:14 Is a match-all rule with jump to empty chain processed? Data Shock
2010-09-14 17:57 ` Jan Engelhardt
2010-09-14 20:34   ` Data Shock

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.