From 29f66f8f0d668d8d9e83da4ca048a21ac7e792d7 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 16 May 2012 13:16:22 +0000 Subject: [PATCH] create a cli flag to disable automatic fallback to userspace if desired --- daemon/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/daemon/main.c b/daemon/main.c index 0665b4b60..64bbb66ca 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -39,6 +39,7 @@ static struct in6_addr udp_listenp; static u_int16_t udp_listenport; static int tos; static int table; +static int no_fallback; static int timeout; static int silent_timeout; static int port_min; @@ -155,6 +156,7 @@ static void options(int *argc, char ***argv) { static GOptionEntry e[] = { { "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Print build time and exit", NULL }, { "table", 't', 0, G_OPTION_ARG_INT, &table, "Kernel table to use", "INT" }, + { "no-fallback",'F', 0, G_OPTION_ARG_NONE, &no_fallback, "Only start when kernel module is available", NULL }, { "ip", 'i', 0, G_OPTION_ARG_STRING, &ipv4s, "Local IPv4 address for RTP", "IP" }, { "advertised-ip", 'a', 0, G_OPTION_ARG_STRING, &adv_ipv4s, "IPv4 address to advertise", "IP" }, { "ip6", 'I', 0, G_OPTION_ARG_STRING, &ipv6s, "Local IPv6 address for RTP", "IP6" }, @@ -279,6 +281,8 @@ int main(int argc, char **argv) { fprintf(stderr, "FAILED TO CREATE KERNEL TABLE %i, KERNEL FORWARDING DISABLED\n", table); mylog(LOG_CRIT, "FAILED TO CREATE KERNEL TABLE %i, KERNEL FORWARDING DISABLED\n", table); table = -1; + if (no_fallback) + exit(-1); } if (table >= 0) { kfd = kernel_open_table(table); @@ -286,6 +290,8 @@ int main(int argc, char **argv) { fprintf(stderr, "FAILED TO OPEN KERNEL TABLE %i, KERNEL FORWARDING DISABLED\n", table); mylog(LOG_CRIT, "FAILED TO OPEN KERNEL TABLE %i, KERNEL FORWARDING DISABLED\n", table); table = -1; + if (no_fallback) + exit(-1); } }