From owner-freebsd-ipfw@FreeBSD.ORG Wed Oct 26 03:53:04 2011 Return-Path: Delivered-To: freebsd-ipfw@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 48BD1106564A; Wed, 26 Oct 2011 03:53:04 +0000 (UTC) (envelope-from kudzu@tenebras.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id AFBF38FC0C; Wed, 26 Oct 2011 03:53:03 +0000 (UTC) Received: by wwi18 with SMTP id 18so1732134wwi.31 for ; Tue, 25 Oct 2011 20:53:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.206.211 with SMTP id fv19mr7010705wbb.27.1319599813953; Tue, 25 Oct 2011 20:30:13 -0700 (PDT) Received: by 10.180.81.193 with HTTP; Tue, 25 Oct 2011 20:30:13 -0700 (PDT) In-Reply-To: <4EA73BAB.70607@freebsd.org> References: <4EA6D78F.6010607@gmail.com> <4EA73BAB.70607@freebsd.org> Date: Tue, 25 Oct 2011 23:30:13 -0400 Message-ID: From: Michael Sierchio To: Julian Elischer Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Karim , freebsd-ipfw@freebsd.org Subject: Re: ipfw rule processing performances X-BeenThere: freebsd-ipfw@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: IPFW Technical Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Oct 2011 03:53:04 -0000 On Tue, Oct 25, 2011 at 6:43 PM, Julian Elischer wrote= : > I find that the structure of teh ruleset has a huge affect on the cpu usa= ge. > > for example I immediately split incoming and outgoing packets apart and s= end > them to different groups of rules. > I also have different groups of rules for internal and external rules. > so my rulesets usually start with: > > skipto 1000 =A0all from any to any in recv ${OUTSIDE_INTERFACE} > skipto 2000 all from any to any in recv ${INSIDE_INTERFACE} > skipto 3000 all from any to any out xmit ${OUTSIDE_INTERFACE} > skipto 4000 all from any to any out xmit ${INSIDE_INTERFACE} > allow all from any to any via lo0 > drop all from any to any > > I also try use tables whenever possible. I've found the same to be true, and use a scheme similar to what Julian describes - I have rules grouped based on interface and direction. Having larger tables and fewer table lookups is faster, in my experience - such that I have a big block list (~20,000 nets) and a small whitelist (~20 nets) ... - M