Linux Netfilter discussions
 help / color / mirror / Atom feed
* ipables and caching
@ 2012-01-24 14:28 Alex Bligh
  2012-01-24 16:29 ` Jan Engelhardt
  0 siblings, 1 reply; 5+ messages in thread
From: Alex Bligh @ 2012-01-24 14:28 UTC (permalink / raw)
  To: Mail List - Netfilter; +Cc: Alex Bligh

I have a legacy application which forwards lots of packets (router,
essentially) and uses a lot of sometimes badly written autogenerated
iptables rules (about 3,000 of them).

I am seeing on a good day high route cache efficiency. Do packets
which do not follow the slow path (i.e. cache hits) also cache
what iptables rules they hit? Nothing fancy in use bar conn_track.
If not, is there some magic wand I can use (other than a rewrite,
which has already been done but can't be used in some circumstances)
to speed up rule processing?

-- 
Alex Bligh

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

* Re: ipables and caching
  2012-01-24 14:28 ipables and caching Alex Bligh
@ 2012-01-24 16:29 ` Jan Engelhardt
  2012-01-27 13:11   ` Alex Bligh
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Engelhardt @ 2012-01-24 16:29 UTC (permalink / raw)
  To: Alex Bligh; +Cc: Mail List - Netfilter

On Tuesday 2012-01-24 15:28, Alex Bligh wrote:

> I have a legacy application which forwards lots of packets (router,
> essentially) and uses a lot of sometimes badly written autogenerated
> iptables rules (about 3,000 of them).
>
> I am seeing on a good day high route cache efficiency. Do packets
> which do not follow the slow path (i.e. cache hits) also cache
> what iptables rules they hit? Nothing fancy in use bar conn_track.

Whether the route lookup was satisfied by cache or not  plays no role 
for Xtables execution.

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

* Re: ipables and caching
  2012-01-24 16:29 ` Jan Engelhardt
@ 2012-01-27 13:11   ` Alex Bligh
  2012-01-29 23:28     ` Ed W
  2012-01-30  0:00     ` Jan Engelhardt
  0 siblings, 2 replies; 5+ messages in thread
From: Alex Bligh @ 2012-01-27 13:11 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: Mail List - Netfilter, Alex Bligh

Jan,

--On 24 January 2012 17:29:35 +0100 Jan Engelhardt <jengelh@medozas.de> 
wrote:

>> I have a legacy application which forwards lots of packets (router,
>> essentially) and uses a lot of sometimes badly written autogenerated
>> iptables rules (about 3,000 of them).
>>
>> I am seeing on a good day high route cache efficiency. Do packets
>> which do not follow the slow path (i.e. cache hits) also cache
>> what iptables rules they hit? Nothing fancy in use bar conn_track.
>
> Whether the route lookup was satisfied by cache or not  plays no role
> for Xtables execution.

Thanks. I don't suppose you know of any work on caching iptables lookups
(which I appreciate is non-trivial to impossible in the general case) or
non-linearising lookups? I am thinking of rules in the FORWARD chain which
either select by source prefix or interface (or the destination equivalent)
and if the criterion is met, jump to another rule. Currently that search in
linear (i.e. through every rule) which with a large number of
prefixes/interfaces is problematic, but with a btree or similar could be
O(log(n)), and with a hash O(1).

-- 
Alex Bligh

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

* Re: ipables and caching
  2012-01-27 13:11   ` Alex Bligh
@ 2012-01-29 23:28     ` Ed W
  2012-01-30  0:00     ` Jan Engelhardt
  1 sibling, 0 replies; 5+ messages in thread
From: Ed W @ 2012-01-29 23:28 UTC (permalink / raw)
  To: Alex Bligh; +Cc: Jan Engelhardt, Mail List - Netfilter

On 27/01/2012 13:11, Alex Bligh wrote:
> Jan,
>
> --On 24 January 2012 17:29:35 +0100 Jan Engelhardt 
> <jengelh@medozas.de> wrote:
>
>>> I have a legacy application which forwards lots of packets (router,
>>> essentially) and uses a lot of sometimes badly written autogenerated
>>> iptables rules (about 3,000 of them).
>>>
>>> I am seeing on a good day high route cache efficiency. Do packets
>>> which do not follow the slow path (i.e. cache hits) also cache
>>> what iptables rules they hit? Nothing fancy in use bar conn_track.
>>
>> Whether the route lookup was satisfied by cache or not  plays no role
>> for Xtables execution.
>
> Thanks. I don't suppose you know of any work on caching iptables lookups
> (which I appreciate is non-trivial to impossible in the general case) or
> non-linearising lookups? I am thinking of rules in the FORWARD chain 
> which
> either select by source prefix or interface (or the destination 
> equivalent)
> and if the criterion is met, jump to another rule. Currently that 
> search in
> linear (i.e. through every rule) which with a large number of
> prefixes/interfaces is problematic, but with a btree or similar could be
> O(log(n)), and with a hash O(1).
>

I don't think so, but have you considered adding some optimisation into 
the auto generated rules? With so many rules there must surely be some 
low hanging fruit to add some conditional chains to reduce the number of 
rules hit?  ipsets are also a very useful option to collapse certain 
types of problem into fewer rules?

Good luck

Ed W

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

* Re: ipables and caching
  2012-01-27 13:11   ` Alex Bligh
  2012-01-29 23:28     ` Ed W
@ 2012-01-30  0:00     ` Jan Engelhardt
  1 sibling, 0 replies; 5+ messages in thread
From: Jan Engelhardt @ 2012-01-30  0:00 UTC (permalink / raw)
  To: Alex Bligh; +Cc: Mail List - Netfilter


On Friday 2012-01-27 14:11, Alex Bligh wrote:
>
>>> I have a legacy application which forwards lots of packets (router,
>>> essentially) and uses a lot of sometimes badly written autogenerated
>>> iptables rules (about 3,000 of them).
>>>
>>> I am seeing on a good day high route cache efficiency. Do packets
>>> which do not follow the slow path (i.e. cache hits) also cache
>>> what iptables rules they hit? Nothing fancy in use bar conn_track.
>>
>> Whether the route lookup was satisfied by cache or not  plays no role
>> for Xtables execution.
>
>Thanks. I don't suppose you know of any work on caching iptables lookups

That would not quite work with e.g. matches that change depending on the
moonphase, such as -m statistic --mode nth.

>or non-linearising lookups? I am thinking of rules in the FORWARD chain which
>either select by source prefix or interface (or the destination equivalent)
>and if the criterion is met, jump to another rule.

Partly by use of ipset.


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

end of thread, other threads:[~2012-01-30  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-24 14:28 ipables and caching Alex Bligh
2012-01-24 16:29 ` Jan Engelhardt
2012-01-27 13:11   ` Alex Bligh
2012-01-29 23:28     ` Ed W
2012-01-30  0:00     ` Jan Engelhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox