From owner-freebsd-net@FreeBSD.ORG Thu Apr 24 17:43:00 2003 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C5F2737B401 for ; Thu, 24 Apr 2003 17:43:00 -0700 (PDT) Received: from cultdeadsheep.org (charon.cultdeadsheep.org [80.65.226.72]) by mx1.FreeBSD.org (Postfix) with ESMTP id 02F4E43F85 for ; Thu, 24 Apr 2003 17:42:59 -0700 (PDT) (envelope-from sheepkiller@cultdeadsheep.org) Received: (qmail 45761 invoked from network); 25 Apr 2003 00:42:56 -0000 Received: from unknown (HELO lucifer.cultdeadsheep.org) (192.168.0.2) by goofy.cultdeadsheep.org with SMTP; 25 Apr 2003 00:42:56 -0000 Date: Fri, 25 Apr 2003 02:44:03 +0200 From: Clement Laforet To: freebsd-net@freebsd.org Message-Id: <20030425024403.6d727b2a.sheepkiller@cultdeadsheep.org> Organization: tH3 cUlt 0f tH3 d3@d sH33p X-Mailer: Sylpheed version 0.8.11 (GTK+ 1.2.10; i386-portbld-freebsd4.8) X-Face: ._cVVRDn#-2((lnfi^P7CoD4htI$4+#G/G)!w|,}H5yK~%(3-C.JlEYbOjJGFwJkt*7N^%z jYeu[;}]}F"3}l5R'l"X0HbvT^D\Q&%deCo)MayY`);TO Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: minor libalias/natd improvements (first snapshot) X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Apr 2003 00:43:01 -0000 Hi guys, I've been working on extending the libalias LSNAT features, and as most of you surely know, incoming redirections have **REALLY** poor performance, due to links management (_FindLinkIn loop eats CPU cycles). So, I dug into libalias and try my best to make it work better :) Here's the stuff : - Add Redirections list + new hash for incoming packets (based on client address). This little workaround considerably improves natd incoming redirections/forwards speed (specially on heavy loaded servers), and uses less CPU time (ex: for _FindLinkIn 47% => 0.9% CPU time (according to gprof)) - Add two weighted round robin scheduling types, and prepare for more. Ex: A=1,B=2,C=3 rr: A,B,C,A,B,C,A,... wrr: A,B,C,B,C,C,A,... wsrr: A,B,B,C,C,C,A,... (useless, for testing only) - now, natd can be reloaded (killall -HUP natd) "All-in-one" tarball can be found here (natd-libalias.tar.gz): (I'll make a patch soon, after cleaning up the code) http://www.cultdeadsheep.org/sheepkiller/FreeBSD/patch-libalias/ Quick Howto ;-) #fetch http://www.cultdeadsheep.org/sheepkiller/FreeBSD/patch-libalias/natd-libalias.tar.gz # tar zxf natd-libalias.tar.gz # cd natd-libalias # make # $EDITOR To play with scheduling: redirect_port proto IP:port[@weight,IP:port[@weight]] [IP:]port ex : redirect_port tcp wrr 192.168.0.1:80@2,192.168.0.2:80,192.168.0.3@5 10.0.0.1:80 #./natd -f # $EDITOR # killall -HUP natd can be : rr,wrr,wsrr KNOWN BUGS: - wrr scheduling take second server for its first redirection. - Others are hidden ;-) TODO: 1. Add *RR to RedirectAddress and fix it [done] 2. Add more efficient load sharing/balancing scheduling types 3. Clean some dirty code (famous "FIX ME") 4. Separate natd/libalias 5. Patch ppp 6. Writing docs 8-) 7. a lot of tests 8. and more... BENCHMARKS: In progress... Advices are welcome :-) Feedback, comments, benchmarks, questions, insults, patches are welcome :-) regards, clem