From 9cfabb6d838162d11ae73c1675513f5921f4ee73 Mon Sep 17 00:00:00 2001 From: darrenr Date: Sat, 10 Apr 2004 17:53:05 +0000 Subject: [PATCH] With recent changes to BPF, pushing the default buffer size to 1MB, running a bunch of small daemons that seem small packet flows can easily chew up significant kernel memory (each BPF device opened takes 2*buffersize of wired memory.) In each of these applications, add code to set the buffer size to 32k before setting the interface. --- common/pf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/pf.c b/common/pf.c index 7fed35f..1688975 100644 --- a/common/pf.c +++ b/common/pf.c @@ -1,4 +1,4 @@ -/* $NetBSD: pf.c,v 1.8 2003/04/20 00:17:22 christos Exp $ */ +/* $NetBSD: pf.c,v 1.9 2004/04/10 17:53:05 darrenr Exp $ */ /* * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. @@ -35,7 +35,7 @@ #include #ifndef lint -__RCSID("$NetBSD: pf.c,v 1.8 2003/04/20 00:17:22 christos Exp $"); +__RCSID("$NetBSD: pf.c,v 1.9 2004/04/10 17:53:05 darrenr Exp $"); #endif #include "os.h" @@ -82,6 +82,7 @@ pfInit(interface, mode, protocol, typ) struct ifreq ifr; u_int dlt; int immediate; + u_int bufsize; static struct bpf_insn insns[] = { BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12), @@ -115,6 +116,10 @@ pfInit(interface, mode, protocol, typ) mopLogWarn("pfInit: BIOCIMMEDIATE"); return(-1); } + bufsize = 32768; + if (ioctl(fd, BIOCSBLEN, &bufsize) < 0) { + mopLogWarn("pfInit: BIOCSBLEN(%d)", bufsize); + } (void) strncpy(ifr.ifr_name, interface, sizeof ifr.ifr_name); if (ioctl(fd, BIOCSETIF, (caddr_t) & ifr) < 0) { mopLogWarn("pfInit: BIOCSETIF");