aboutsummaryrefslogtreecommitdiffstats
path: root/executor
diff options
context:
space:
mode:
Diffstat (limited to 'executor')
-rw-r--r--executor/common_linux.h19
1 files changed, 11 insertions, 8 deletions
diff --git a/executor/common_linux.h b/executor/common_linux.h
index 772d98c03..feef6cf68 100644
--- a/executor/common_linux.h
+++ b/executor/common_linux.h
@@ -456,25 +456,24 @@ static void netlink_add_neigh(struct nlmsg* nlmsg, int sock, const char* name,
#include <linux/tcp.h>
static int tunfd = -1;
-static int tun_frags_enabled;
#define TUN_IFACE "syz_tun"
-
#define LOCAL_MAC 0xaaaaaaaaaaaa
#define REMOTE_MAC 0xaaaaaaaaaabb
-
#define LOCAL_IPV4 "172.20.20.170"
#define REMOTE_IPV4 "172.20.20.187"
-
#define LOCAL_IPV6 "fe80::aa"
#define REMOTE_IPV6 "fe80::bb"
#ifndef IFF_NAPI
#define IFF_NAPI 0x0010
#endif
+#if ENABLE_NAPI_FRAGS
+static int tun_frags_enabled;
#ifndef IFF_NAPI_FRAGS
#define IFF_NAPI_FRAGS 0x0020
#endif
+#endif
static void initialize_tun(void)
{
@@ -1282,10 +1281,8 @@ static int read_tun(char* data, int size)
int rv = read(tunfd, data, size);
if (rv < 0) {
- if (errno == EAGAIN)
- return -1;
- // Tun sometimes returns this, unclear if it's a kernel bug or not.
- if (errno == EBADFD)
+ // Tun sometimes returns EBADFD, unclear if it's a kernel bug or not.
+ if (errno == EAGAIN || errno == EBADFD)
return -1;
fail("tun: read failed with %d", rv);
}
@@ -1297,12 +1294,14 @@ static int read_tun(char* data, int size)
#include <stdbool.h>
#include <sys/uio.h>
+#if ENABLE_NAPI_FRAGS
#define MAX_FRAGS 4
struct vnet_fragmentation {
uint32 full;
uint32 count;
uint32 frags[MAX_FRAGS];
};
+#endif
static long syz_emit_ethernet(volatile long a0, volatile long a1, volatile long a2)
{
@@ -1319,6 +1318,7 @@ static long syz_emit_ethernet(volatile long a0, volatile long a1, volatile long
char* data = (char*)a1;
debug_dump_data(data, length);
+#if ENABLE_NAPI_FRAGS
struct vnet_fragmentation* frags = (struct vnet_fragmentation*)a2;
struct iovec vecs[MAX_FRAGS + 1];
uint32 nfrags = 0;
@@ -1351,6 +1351,9 @@ static long syz_emit_ethernet(volatile long a0, volatile long a1, volatile long
}
}
return writev(tunfd, vecs, nfrags);
+#else
+ return write(tunfd, data, length);
+#endif
}
#endif