From 8fb452de824b9484b07af4e93433de9550c9f747 Mon Sep 17 00:00:00 2001 From: angt Date: Mon, 9 Nov 2015 12:47:04 +0100 Subject: [PATCH] Warn if IFF_MULTI_QUEUE is not supported --- main.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index e46d8a8..bb06e50 100644 --- a/main.c +++ b/main.c @@ -20,12 +20,12 @@ # include #endif +#include + #ifndef O_CLOEXEC #define O_CLOEXEC 0 #endif -#include - #define GT_BUFFER_SIZE (4*1024*1024) struct netio { @@ -45,6 +45,11 @@ struct crypto_ctx { volatile sig_atomic_t running; +static void gt_not_available (const char *name) +{ + fprintf(stderr, "%s is not available on your platform!\n", name); +} + static int64_t dt_ms (struct timeval *ta, struct timeval *tb) { const int64_t s = ta->tv_sec-tb->tv_sec; @@ -100,7 +105,7 @@ static void sk_set_congestion (int fd, const char *name) #else static void sk_set_congestion (_unused_ int fd, _unused_ const char *name) { - fprintf(stderr, "TCP_CONGESTION is not available on your platform!\n"); + gt_not_available("TCP_CONGESTION"); } #endif @@ -284,8 +289,13 @@ static int tun_create (char *name, int multiqueue) .ifr_flags = IFF_TUN|IFF_NO_PI, }; - if (multiqueue) + if (multiqueue) { +#ifdef IFF_MULTI_QUEUE ifr.ifr_flags |= IFF_MULTI_QUEUE; +#else + gt_not_available("IFF_MULTI_QUEUE"); +#endif + } str_cpy(ifr.ifr_name, name, IFNAMSIZ-1); @@ -626,7 +636,7 @@ int main (int argc, char **argv) } if (!crypto_aead_aes256gcm_is_available()) { - fprintf(stderr, "AES-256-GCM is not available on your platform!\n"); + gt_not_available("AES-256-GCM"); return 1; }