aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common_bsd.h
diff options
context:
space:
mode:
authorMichael Tüxen <tuexen@fh-muenster.de>2018-12-01 11:22:39 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-12-01 10:22:39 +0000
commit5a58167323289751602879a986a1b9f95531a31b (patch)
treea73fd4ca00d50e07c60e129c39ad52af300c8fa4 /executor/common_bsd.h
parentd8988561c04c0244155309bdf701998b9fb98dd5 (diff)
executor: add support for tap interfaces on FreeBSD
Diffstat (limited to 'executor/common_bsd.h')
-rw-r--r--executor/common_bsd.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/executor/common_bsd.h b/executor/common_bsd.h
index be9fa4029..0d95dc42e 100644
--- a/executor/common_bsd.h
+++ b/executor/common_bsd.h
@@ -33,6 +33,10 @@ static uintptr_t syz_open_pts(void)
#endif // SYZ_EXECUTOR || __NR_syz_open_pts
+#endif // GOOS_openbsd
+
+#if GOOS_freebsd || GOOS_openbsd
+
#if SYZ_EXECUTOR || SYZ_TUN_ENABLE
#include <fcntl.h>
@@ -115,6 +119,12 @@ static void initialize_tun(int tun_id)
snprintf_check(tun_device, sizeof(tun_device), TUN_DEVICE, tun_id);
tunfd = open(tun_device, O_RDWR | O_NONBLOCK);
+#if GOOS_freebsd
+ if ((tunfd < 0) && (errno == ENOENT)) {
+ execute_command(0, "kldload -q if_tap");
+ tunfd = open(tun_device, O_RDWR | O_NONBLOCK);
+ }
+#endif
if (tunfd == -1) {
#if SYZ_EXECUTOR
fail("tun: can't open %s\n", tun_device);
@@ -188,7 +198,11 @@ struct tcp_resources {
uint32 ack;
};
+#if GOOS_freebsd
+#include <net/ethernet.h>
+#else
#include <net/ethertypes.h>
+#endif
#include <net/if.h>
#include <net/if_arp.h>
#include <netinet/in.h>
@@ -250,13 +264,13 @@ static long syz_extract_tcp_res(long a0, long a1, long a2)
return 0;
}
#endif
-#endif // GOOS_openbsd
+#endif // GOOS_freebsd || GOOS_openbsd
#if SYZ_EXECUTOR || SYZ_SANDBOX_NONE
static void loop();
static int do_sandbox_none(void)
{
-#if GOOS_openbsd && (SYZ_EXECUTOR || SYZ_TUN_ENABLE)
+#if (GOOS_freebsd || GOOS_openbsd) && (SYZ_EXECUTOR || SYZ_TUN_ENABLE)
initialize_tun(procid);
#endif
loop();