diff options
author | Amirsaman Memaripour <amirsaman.memaripour@mongodb.com> | 2020-03-05 16:05:53 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-03-10 02:49:40 +0000 |
commit | fe90d82d6ce709828c8ed22e83262190dda5570a (patch) | |
tree | ccd5e5482b0f8892ce654fd43726dee94883d493 | |
parent | ef959bbc8e0b3601323a162eb99d69716b07e548 (diff) | |
download | mongo-fe90d82d6ce709828c8ed22e83262190dda5570a.tar.gz |
SERVER-42065 Handle bindIpAll exception when ipv6 is not supported
-rw-r--r-- | src/mongo/transport/transport_layer_asio.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/mongo/transport/transport_layer_asio.cpp b/src/mongo/transport/transport_layer_asio.cpp index 67149bb2199..43955258496 100644 --- a/src/mongo/transport/transport_layer_asio.cpp +++ b/src/mongo/transport/transport_layer_asio.cpp @@ -921,7 +921,22 @@ Status TransportLayerASIO::setup() { } GenericAcceptor acceptor(*_acceptorReactor); - acceptor.open(addr->protocol()); + try { + acceptor.open(addr->protocol()); + } catch (std::exception&) { + // Allow the server to start when "ipv6: true" and "bindIpAll: true", but the platform + // does not support ipv6 (e.g., ipv6 kernel module is not loaded in Linux). + const auto bindAllIPv6Addr = ":::"_sd + std::to_string(_listenerPort); + if (errno == EAFNOSUPPORT && _listenerOptions.enableIPv6 && addr.family() == AF_INET6 && + addr.toString() == bindAllIPv6Addr) { + LOGV2_WARNING(4206501, + "Failed to bind to {bind_addr} as the platform does not support ipv6", + "bind_addr"_attr = addr.toString()); + continue; + } + + throw; + } acceptor.set_option(GenericAcceptor::reuse_address(true)); std::error_code ec; |