summaryrefslogtreecommitdiffstats
path: root/sbin/dhclient/bpf.c
diff options
context:
space:
mode:
authornatano <natano@openbsd.org>2016-05-03 07:47:26 +0000
committernatano <natano@openbsd.org>2016-05-03 07:47:26 +0000
commit3908450d51c220b8c0c8a978bcb30f3d2c7e48f8 (patch)
treeeed0274f21a15f11840983de65c9221e40fedb1b /sbin/dhclient/bpf.c
parentMove to /dev/bpf; ok lteo (diff)
downloadwireguard-openbsd-3908450d51c220b8c0c8a978bcb30f3d2c7e48f8.tar.xz
wireguard-openbsd-3908450d51c220b8c0c8a978bcb30f3d2c7e48f8.zip
Move to /dev/bpf; ok tb jmc
Diffstat (limited to 'sbin/dhclient/bpf.c')
-rw-r--r--sbin/dhclient/bpf.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c
index c10931ac922..57f3a1be2e4 100644
--- a/sbin/dhclient/bpf.c
+++ b/sbin/dhclient/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.38 2016/02/06 19:30:52 krw Exp $ */
+/* $OpenBSD: bpf.c,v 1.39 2016/05/03 07:47:26 natano Exp $ */
/* BPF socket interface code, originally contributed by Archie Cobbs. */
@@ -64,8 +64,6 @@
#include "dhcp.h"
#include "dhcpd.h"
-#define BPF_FORMAT "/dev/bpf%d"
-
int if_register_bpf(void);
/*
@@ -76,29 +74,17 @@ int if_register_bpf(void);
int
if_register_bpf(void)
{
- char filename[50];
struct ifreq ifr;
- int sock, b;
-
- /* Open a BPF device */
- for (b = 0; 1; b++) {
- snprintf(filename, sizeof(filename), BPF_FORMAT, b);
- sock = open(filename, O_RDWR | O_CLOEXEC, 0);
- if (sock < 0) {
- if (errno == EBUSY)
- continue;
- else
- error("Can't find free bpf: %s",
- strerror(errno));
- } else
- break;
- }
+ int sock;
+
+ if ((sock = open("/dev/bpf", O_RDWR | O_CLOEXEC)) == -1)
+ error("Can't open bpf: %s", strerror(errno));
/* Set the BPF device to point at this interface. */
strlcpy(ifr.ifr_name, ifi->name, IFNAMSIZ);
if (ioctl(sock, BIOCSETIF, &ifr) < 0)
- error("Can't attach interface %s to %s: %s",
- ifi->name, filename, strerror(errno));
+ error("Can't attach interface %s to /dev/bpf: %s",
+ ifi->name, strerror(errno));
return (sock);
}