From owner-freebsd-bugs@FreeBSD.ORG Thu Dec 18 07:20:20 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 954D316A4CE for ; Thu, 18 Dec 2003 07:20:20 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id AAD2C43D2D for ; Thu, 18 Dec 2003 07:20:15 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) hBIFKFFR033961 for ; Thu, 18 Dec 2003 07:20:15 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id hBIFKFKt033960; Thu, 18 Dec 2003 07:20:15 -0800 (PST) (envelope-from gnats) Resent-Date: Thu, 18 Dec 2003 07:20:15 -0800 (PST) Resent-Message-Id: <200312181520.hBIFKFKt033960@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "D. Rock" Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BD12116A4CE for ; Thu, 18 Dec 2003 07:17:47 -0800 (PST) Received: from mailout05.sul.t-online.com (mailout05.sul.t-online.com [194.25.134.82]) by mx1.FreeBSD.org (Postfix) with ESMTP id 26CB643D1F for ; Thu, 18 Dec 2003 07:17:45 -0800 (PST) (envelope-from D.Rock@t-online.de) Received: from fwd09.aul.t-online.de by mailout05.aul.t-online.de with smtp id 1AW1xK-0005SR-00; Tue, 16 Dec 2003 00:16:50 +0100 Received: from dialin.t-online.de (VyF24+Z1Ye3sztsHrD06I0KGyoYwu3oEp5L+BVnCjJ5sf9ZaB3EJU+@[217.234.85.129]) by fwd09.sul.t-online.com with esmtp id 1AW1x6-1MMiJc0; Tue, 16 Dec 2003 00:16:36 +0100 Received: from gate.rock.net (gate [172.23.7.126])hBFNGG8f000849 for ; Tue, 16 Dec 2003 00:16:16 +0100 (CET) Received: from gate.rock.net (localhost [127.0.0.1]) by gate.rock.net (8.12.10/8.12.9) with ESMTP id hBFNGFgg022703 for ; Tue, 16 Dec 2003 00:16:15 +0100 (CET) (envelope-from rock@gate.rock.net) Received: (from rock@localhost) by gate.rock.net (8.12.10/8.12.9/Submit) id hBFNGF75022702; Tue, 16 Dec 2003 00:16:15 +0100 (CET) (envelope-from rock) Message-Id: <200312152316.hBFNGF75022702@gate.rock.net> Date: Tue, 16 Dec 2003 00:16:15 +0100 (CET) From: D.Rock@t-online.de (D. Rock) To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/60368: performance problem /usr/sbin/ppp X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: "D. Rock" List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Dec 2003 15:20:20 -0000 >Number: 60368 >Category: bin >Synopsis: performance problem /usr/sbin/ppp >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Dec 18 07:20:15 PST 2003 >Closed-Date: >Last-Modified: >Originator: D. Rock >Release: FreeBSD 5.2-CURRENT i386 >Organization: >Environment: System: FreeBSD gate.rock.net 5.2-CURRENT FreeBSD 5.2-CURRENT #832: Mon Dec 8 10:46:30 CET 2003 root@gate.rock.net:/export/common/src/sys/i386/compile/ROCK i386 >Description: With filtering rules active user-PPP (/usr/sbin/ppp) consumes high CPU load while filtering packets. Caused by calling getprotobynumber() for each packet filtered, regardless if there will be any logging output or not. >How-To-Repeat: Define filtering rules in your /etc/ppp/ppp.conf do some performance tests on the PPP link >Fix: see patch below --- ppp.diff begins here --- Index: usr.sbin/ppp/ip.c =================================================================== RCS file: /export/cvs/src/usr.sbin/ppp/ip.c,v retrieving revision 1.100 diff -u -r1.100 ip.c --- usr.sbin/ppp/ip.c 26 Mar 2003 02:27:32 -0000 1.100 +++ usr.sbin/ppp/ip.c 11 Dec 2003 22:20:27 -0000 @@ -161,6 +161,18 @@ } } +static char *toprototxt(int cproto) +{ + static char prototxt[16]; + struct protoent *pe; + + if ((pe = getprotobynumber(cproto)) == NULL) + snprintf(prototxt, sizeof prototxt, "%d", cproto); + else + snprintf(prototxt, sizeof prototxt, "%s", pe->p_name); + return prototxt; +} + /* * Check a packet against the given filter * Returns 0 to accept the packet, non-zero to drop the packet. @@ -187,8 +199,7 @@ int match; /* true if condition matched */ int mindata; /* minimum data size or zero */ const struct filterent *fp = filter->rule; - char dbuff[100], dstip[16], prototxt[16]; - struct protoent *pe; + char dbuff[100], dstip[16]; struct ncpaddr srcaddr, dstaddr; const char *payload; /* IP payload */ int datalen; /* IP datagram length */ @@ -239,10 +250,6 @@ cproto = pip->ip_p; } - if ((pe = getprotobynumber(cproto)) == NULL) - snprintf(prototxt, sizeof prototxt, "%d", cproto); - else - snprintf(prototxt, sizeof prototxt, "%s", pe->p_name); gotinfo = estab = syn = finrst = didname = 0; sport = dport = 0; @@ -356,7 +363,7 @@ if (datalen < mindata) { log_Printf(LogFILTER, " error: proto %s must be at least" - " %d octets\n", prototxt, mindata); + " %d octets\n", toprototxt(cproto), mindata); return 1; } @@ -367,7 +374,8 @@ ", estab = %d, syn = %d, finrst = %d", estab, syn, finrst); } - log_Printf(LogDEBUG, " Filter: proto = %s, %s\n", prototxt, dbuff); + log_Printf(LogDEBUG, " Filter: proto = %s, %s\n", + toprototxt(cproto), dbuff); } gotinfo = 1; } @@ -424,7 +432,8 @@ if (log_IsKept(LogFILTER)) { snprintf(dstip, sizeof dstip, "%s", ncpaddr_ntoa(&dstaddr)); log_Printf(LogFILTER, "%sbound rule = %d accept %s " - "src = %s:%d dst = %s:%d\n", filter->name, n, prototxt, + "src = %s:%d dst = %s:%d\n", filter->name, n, + toprototxt(cproto), ncpaddr_ntoa(&srcaddr), sport, dstip, dport); } } @@ -434,7 +443,7 @@ snprintf(dstip, sizeof dstip, "%s", ncpaddr_ntoa(&dstaddr)); log_Printf(LogFILTER, "%sbound rule = %d deny %s src = %s/%d dst = %s/%d\n", - filter->name, n, prototxt, + filter->name, n, toprototxt(cproto), ncpaddr_ntoa(&srcaddr), sport, dstip, dport); } return 1; @@ -450,7 +459,7 @@ snprintf(dstip, sizeof dstip, "%s", ncpaddr_ntoa(&dstaddr)); log_Printf(LogFILTER, "%sbound rule = implicit deny %s src = %s/%d dst = %s/%d\n", - filter->name, prototxt, ncpaddr_ntoa(&srcaddr), sport, + filter->name, toprototxt(cproto), ncpaddr_ntoa(&srcaddr), sport, dstip, dport); } --- ppp.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted: