bin/60368: performance problem /usr/sbin/ppp
D. Rock
D.Rock at t-online.de
Thu Dec 18 07:20:20 PST 2003
>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 at 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:
More information about the freebsd-bugs
mailing list