From owner-freebsd-current@FreeBSD.ORG Sat Jan 26 19:30:33 2008 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B5C5916A41B for ; Sat, 26 Jan 2008 19:30:33 +0000 (UTC) (envelope-from max@love2party.net) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.187]) by mx1.freebsd.org (Postfix) with ESMTP id 62CB713C4E7 for ; Sat, 26 Jan 2008 19:30:33 +0000 (UTC) (envelope-from max@love2party.net) Received: from amd64.laiers.local (dslb-088-067-244-178.pools.arcor-ip.net [88.67.244.178]) by mrelayeu.kundenserver.de (node=mrelayeu8) with ESMTP (Nemesis) id 0ML31I-1JIqXJ1yrP-0002go; Sat, 26 Jan 2008 20:17:53 +0100 From: Max Laier Organization: FreeBSD To: freebsd-current@freebsd.org Date: Sat, 26 Jan 2008 20:17:45 +0100 User-Agent: KMail/1.9.7 References: <479A2389.2000802@moneybookers.com> In-Reply-To: <479A2389.2000802@moneybookers.com> X-Face: ,,8R(x[kmU]tKN@>gtH1yQE4aslGdu+2]; R]*pL,U>^H?)gW@49@wdJ`H<=?utf-8?q?=25=7D*=5FBD=0A=09U=5For=3D=5CmOZf764=26nYj=3DJYbR1PW0ud?=>|!~,,CPC.1-D$FG@0h3#'5"k{V]a~.<=?utf-8?q?mZ=7D44=23Se=7Em=0A=09Fe=7E=5C=5DX5B=5D=5Fxj?=(ykz9QKMw_l0C2AQ]}Ym8)fU MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2896453.v3WcQ0IqKx"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200801262017.52091.max@love2party.net> X-Provags-ID: V01U2FsdGVkX1/j2+fKqN1e40MJzOhKxjtgsVw+Il9Mfkvyxym SQEM7Ro3+wi8DBS1NuXmwz/KryCcILNTkb3VhFKohi4T8xCuDA v+j6i1ISEIguxE0Ocqppj9Yn/R5Hw1rLdclNy8aLWM= Cc: Stefan Lambrev Subject: Re: FreeBSD 7, bridge, PF and syn flood = very bad performance X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Jan 2008 19:30:33 -0000 --nextPart2896453.v3WcQ0IqKx Content-Type: text/plain; charset="windows-1251" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Friday 25 January 2008, Stefan Lambrev wrote: > Greetings, > > Does anyone try to see PF with "keep state" in action when under syn > flood attack? > I tried to get some help in freebsd-pf@, because the test firewall, > that I build hardly can handle 2-5MB/s syn flood. > Unfortunately I do not saw useful advice. > The problem is that a quad core bridge firewall running freebsd 7 amd64 > with PF is near useless and can't handle "small" SYN ddos. > > Here is the schema that I'm testing: > web server (freebsd) - freebsd (bridged interfaces) - gigabit switch - > clients + flooders > In this configuration ~25MB/s syn flood (and I think this limit is > because of my switch) is not a problem and the web server responds > without a problem. > With this configuration netperf -l 610 -p 10303 -H 10.3.3.1 shows > 116MB/s stable speed , so I guess there are no problems with cables, > hardware and etc :) > > But when I start pf (see below the config file) the traffic drops to > 2-3MB/s and the web server is hardly accessible. > It seems that device polling helps a lot in this situation, and at > least the bridge firewall is accessible. Without "polling" the firewall > is so heavily loaded > that even commands like "date" take few seconds to finish, with 2 cores > at ~100% idle at same time. > > I have "flat profiles" from hwpmc, and I think it indicates a problem: > > (bridge, pf enabled, polling enabled, sched_ule - I have profiles and > for other combinations too if needed) > % cumulative self self total > time seconds seconds calls ms/call ms/call name > 24.0 268416.00 268416.00 0 100.00% _mtx_lock_sleep Can you build a kernel with LOCK_PROFILING and try to figure out which=20 lock is causing this? > [1] 6.7 343572.50 75156.50 0 100.00% > pf_state_compare_ext_gwy [2] > 6.7 418405.50 74833.00 0 100.00% pf_src_compare > [3] 3.9 462298.50 43893.00 0 100.00% > pf_state_compare_lan_ext [4] > 3.6 503019.50 40721.00 0 100.00% pf_test [5] > 3.2 538671.50 35652.00 0 100.00% pf_test_tcp [6] > 3.1 573743.50 35072.00 0 100.00% bcopy [7] > 2.3 599406.50 25663.00 0 100.00% bridge_pfil [8] > 2.0 622096.50 22690.00 0 100.00% > pf_state_compare_id [9] > 2.0 644331.50 22235.00 0 100.00% pfsync_pack_state > [10] 1.5 661563.50 17232.00 0 100.00% uma_zalloc_arg > [11] 1.3 676296.50 14733.00 0 100.00% bzero [12] 1.3 > 690842.00 14545.50 0 100.00% > bus_dmamap_load_mbuf_sg [13] > 1.2 704521.50 13679.50 0 100.00% uma_zfree_arg > [14] 1.2 717554.50 13033.00 0 100.00% > bridge_rtnode_lookup [15] > 1.2 730575.50 13021.00 0 100.00% _rw_rlock [16] > 1.1 743076.50 12501.00 0 100.00% rn_match [17] > 1.0 754016.50 10940.00 0 100.00% bridge_forward > [18] 1.0 764766.00 10749.50 0 100.00% em_encap [19] > 0.9 775400.00 10634.00 0 100.00% _rw_runlock [20] > ........ > > Also when running without polling top -S shows that external em0 > interface's taskq takes 100% CPU > The situation is even worse when running with SCHED_BSD. > > Here is my test pf.conf > quick > #macros > ext_if=3D"em0" > int_if=3D"em1" > br_if=3D"bridge0" > > www=3D"10.3.3.1" > > #sets > set skip on lo0 > set skip on $int_if > set skip on $br_if > set limit states 20000000 > set limit src-nodes 19000000 > set optimization aggressive > > table persist file "/etc/abusive_hosts" > > block log quick from to any > block log quick from any to > > pass in on $ext_if proto tcp from any to $www port { 80, 443 } flags > S/SA keep state \ > (source-track rule, max-src-conn-rate 150/10, max-src-states 500, > max-src-nodes 4000000, overload flush global) =2D-=20 /"\ Best regards, | mlaier@freebsd.org \ / Max Laier | ICQ #67774661 X http://pf4freebsd.love2party.net/ | mlaier@EFnet / \ ASCII Ribbon Campaign | Against HTML Mail and News --nextPart2896453.v3WcQ0IqKx Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) iD8DBQBHm4dgXyyEoT62BG0RAtFyAJ94+Y6hqzfnenbDZ9xzrrER9Nf8twCfVxXk VkPVOOSTLssI1OFEarjK4vg= =Lo31 -----END PGP SIGNATURE----- --nextPart2896453.v3WcQ0IqKx--