From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ed W Subject: Re: ipables and caching Date: Sun, 29 Jan 2012 23:28:01 +0000 Message-ID: <4F25D601.6010400@wildgooses.com> References: <6B9C7F3D35F2987D1BE7DB0B@Ximines.local> <9B90546135A9F09A0A6271DF@Ximines.local> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <9B90546135A9F09A0A6271DF@Ximines.local> Sender: netfilter-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii"; format="flowed" 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 > 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