summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2019-03-18 00:00:59 +0000
committerdlg <dlg@openbsd.org>2019-03-18 00:00:59 +0000
commitb57001d2402253b2754c7550188932001fb07564 (patch)
treec6a4cccd021ced73f832459e308ac89cd578f11d
parentextend BIOCSFILDROP so it can be configured to not capture packets. (diff)
downloadwireguard-openbsd-b57001d2402253b2754c7550188932001fb07564.tar.xz
wireguard-openbsd-b57001d2402253b2754c7550188932001fb07564.zip
explicitly use BPF_FILDROP_CAPTURE when configuring BIOCSFILDROP
BIOCSFILDROP used to just be a flag, ie, any non-zero value was treated the same, but i'm changing it so different values do different things. this way the programs should keep working even if i decide to change the values for these macros.
-rw-r--r--sbin/dhclient/bpf.c5
-rw-r--r--usr.sbin/dhcpd/bpf.c5
-rw-r--r--usr.sbin/dhcrelay6/bpf.c4
3 files changed, 8 insertions, 6 deletions
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c
index d1aeeaf8ba7..1bb287687fc 100644
--- a/sbin/dhclient/bpf.c
+++ b/sbin/dhclient/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.74 2019/01/05 21:40:44 krw Exp $ */
+/* $OpenBSD: bpf.c,v 1.75 2019/03/18 00:00:59 dlg Exp $ */
/* BPF socket interface code, originally contributed by Archie Cobbs. */
@@ -183,6 +183,7 @@ configure_bpf_sock(int bpffd)
struct bpf_version v;
struct bpf_program p;
int flag = 1, sz;
+ int fildrop = BPF_FILDROP_CAPTURE;
/* Make sure the BPF version is in range. */
if (ioctl(bpffd, BIOCVERSION, &v) == -1)
@@ -201,7 +202,7 @@ configure_bpf_sock(int bpffd)
if (ioctl(bpffd, BIOCIMMEDIATE, &flag) == -1)
fatal("BIOCIMMEDIATE");
- if (ioctl(bpffd, BIOCSFILDROP, &flag) == -1)
+ if (ioctl(bpffd, BIOCSFILDROP, &fildrop) == -1)
fatal("BIOCSFILDROP");
/* Get the required BPF buffer length from the kernel. */
diff --git a/usr.sbin/dhcpd/bpf.c b/usr.sbin/dhcpd/bpf.c
index 784301a5e1b..c47f3812a40 100644
--- a/usr.sbin/dhcpd/bpf.c
+++ b/usr.sbin/dhcpd/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.19 2017/04/19 05:36:12 natano Exp $ */
+/* $OpenBSD: bpf.c,v 1.20 2019/03/18 00:00:59 dlg Exp $ */
/* BPF socket interface code, originally contributed by Archie Cobbs. */
@@ -175,6 +175,7 @@ if_register_receive(struct interface_info *info)
struct bpf_version v;
struct bpf_program p;
int flag = 1, sz, cmplt = 0;
+ int fildrop = BPF_FILDROP_CAPTURE;
/* Open a BPF device and hang it on this interface... */
info->rfdesc = if_register_bpf(info);
@@ -195,7 +196,7 @@ if_register_receive(struct interface_info *info)
if (ioctl(info->rfdesc, BIOCIMMEDIATE, &flag) == -1)
fatal("Can't set immediate mode on bpf device");
- if (ioctl(info->rfdesc, BIOCSFILDROP, &flag) == -1)
+ if (ioctl(info->rfdesc, BIOCSFILDROP, &fildrop) == -1)
fatal("Can't set filter-drop mode on bpf device");
/* make sure kernel fills in the source ethernet address */
diff --git a/usr.sbin/dhcrelay6/bpf.c b/usr.sbin/dhcrelay6/bpf.c
index dbc7098c9a8..4b15e6d1b9d 100644
--- a/usr.sbin/dhcrelay6/bpf.c
+++ b/usr.sbin/dhcrelay6/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.2 2017/04/19 05:36:13 natano Exp $ */
+/* $OpenBSD: bpf.c,v 1.3 2019/03/18 00:00:59 dlg Exp $ */
/* BPF socket interface code, originally contributed by Archie Cobbs. */
@@ -203,7 +203,7 @@ if_register_receive(struct interface_info *info)
fatal("Can't set BPF direction capture");
/* Drop them so they don't go up in the network stack. */
- flag = 1;
+ flag = BPF_FILDROP_CAPTURE;
if (ioctl(info->rfdesc, BIOCSFILDROP, &flag) == -1)
fatal("Can't set BPF filter drop");