Skip to content

Commit

Permalink
add warning msg when IPv6 is disabled for better understanding
Browse files Browse the repository at this point in the history
Summary: [openr] add warning msg when IPv6 is disabled for better understanding

Reviewed By: saifhhasan

Differential Revision: D15246657

fbshipit-source-id: 695c1d073980fb1f7fe697a95f8f6799b74f2d0c
  • Loading branch information
xiangxu1121 authored and facebook-github-bot committed May 9, 2019
1 parent bc34121 commit 89d390e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions openr/Main.cpp
Expand Up @@ -6,6 +6,7 @@
*/

#include <syslog.h>
#include <fstream>
#include <stdexcept>

#include <fbzmq/async/StopEventLoopSignalHandler.h>
Expand Down Expand Up @@ -73,11 +74,28 @@ const PersistentStoreUrl kConfigStoreUrl{"ipc:///tmp/openr_config_store_cmd"};

const fbzmq::SocketUrl kForceCrashServerUrl{"ipc:///tmp/force_crash_server"};

const std::string inet6Path = "/proc/net/if_inet6";
} // namespace

// Disable background jemalloc background thread => new jemalloc-5 feature
const char* malloc_conf = "background_thread:false";

void
checkIsIpv6Enabled() {
// check if file path exists
std::ifstream ifs(inet6Path);
if (!ifs) {
LOG(ERROR) << "File path: " << inet6Path << " doesn't exist!";
return;
}

// check file size for if_inet6_path.
// zero-size file means IPv6 is NOT enabled globally.
if (ifs.peek() == std::ifstream::traits_type::eof()) {
LOG(FATAL) << "IPv6 is NOT enabled. Pls check system config!";
}
}

void
waitForFibService(const fbzmq::ZmqEventLoop& evl) {
auto waitForFibStart = std::chrono::steady_clock::now();
Expand Down Expand Up @@ -176,6 +194,9 @@ main(int argc, char** argv) {
return 1;
}

// Sanity check for IPv6 global environment
checkIsIpv6Enabled();

// Sanity checks on Segment Routing labels
const int32_t maxLabel = Constants::kMaxSrLabel;
CHECK(Constants::kSrGlobalRange.first > 0);
Expand Down

0 comments on commit 89d390e

Please sign in to comment.