From 0e89e445f296ccd1a1453ed2a29c7c3b5e12ec0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 24 Aug 2017 15:08:14 +0300 Subject: [PATCH] Bind admin interface to IPv4 if IPv6 fails The default interface for the admin interface is the IPv6 address '::' which corresponds to the IPv4 address '0.0.0.0'. If the system doesn't support IPv6, then an attempt to bind on IPv4 should be made. --- server/core/gateway.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/core/gateway.cc b/server/core/gateway.cc index 47d298f9f..e986dfe79 100644 --- a/server/core/gateway.cc +++ b/server/core/gateway.cc @@ -2062,7 +2062,17 @@ int main(int argc, char **argv) if (cnf->admin_enabled) { - if (mxs_admin_init()) + bool success = mxs_admin_init(); + + if (!success && strcmp(cnf->admin_host, "::") == 0) + { + MXS_WARNING("Failed to bind on address '::', attempting to " + "bind on IPv4 address '0.0.0.0'."); + strcpy(cnf->admin_host, "0.0.0.0"); + success = mxs_admin_init(); + } + + if (success) { MXS_NOTICE("Started REST API on [%s]:%u", cnf->admin_host, cnf->admin_port); } @@ -2075,7 +2085,6 @@ int main(int argc, char **argv) } } - MXS_NOTICE("MaxScale started with %d worker threads, each with a stack size of %lu bytes.", n_threads, thread_stack_size);