From 6fe0f49646813924a072d786e080ab7bf4f9ab65 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 18 Apr 2020 14:37:48 +0200 Subject: executor: remove more code if ENABLE_NAPI_FRAGS is not set In some configurations tun_frags_enabled ends up being unused with a compiler warning and failed build. Remove mode code if ENABLE_NAPI_FRAGS is not enabled. --- executor/common_linux.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'executor') 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 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 #include +#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 -- cgit mrf-deployment