From 4e83c41d472189286616db56f1f10d9fa632fbab Mon Sep 17 00:00:00 2001 From: christos Date: Wed, 1 Dec 2004 23:15:08 +0000 Subject: [PATCH] Use cloning bpf. --- common/pf.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/common/pf.c b/common/pf.c index 1688975..a15c3d6 100644 --- a/common/pf.c +++ b/common/pf.c @@ -1,4 +1,4 @@ -/* $NetBSD: pf.c,v 1.9 2004/04/10 17:53:05 darrenr Exp $ */ +/* $NetBSD: pf.c,v 1.10 2004/12/01 23:15:08 christos Exp $ */ /* * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. @@ -35,11 +35,12 @@ #include #ifndef lint -__RCSID("$NetBSD: pf.c,v 1.9 2004/04/10 17:53:05 darrenr Exp $"); +__RCSID("$NetBSD: pf.c,v 1.10 2004/12/01 23:15:08 christos Exp $"); #endif #include "os.h" +#include #include #include @@ -77,12 +78,11 @@ pfInit(interface, mode, protocol, typ) int typ, mode; { int fd; - int n = 0; - char device[sizeof "/dev/bpf000"]; struct ifreq ifr; u_int dlt; int immediate; u_int bufsize; + const char *device = _PATH_BPF; static struct bpf_insn insns[] = { BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12), @@ -99,12 +99,7 @@ pfInit(interface, mode, protocol, typ) insns }; - /* Go through all the minors and find one that isn't in use. */ - do { - (void) snprintf(device, sizeof(device), "/dev/bpf%d", n++); - fd = open(device, mode); - } while (fd < 0 && errno == EBUSY); - + fd = open(device, mode); if (fd < 0) { mopLogWarn("pfInit: open %s", device); return(-1);