Loading src/daemon/daemon.cpp +47 −2 Original line number Diff line number Diff line Loading @@ -40,6 +40,11 @@ #include <daemon/backend/data/chunk_storage.hpp> #include <daemon/util.hpp> #include <sys/ioctl.h> #include <net/if.h> #include <netinet/in.h> #include <stdio.h> #include <arpa/inet.h> #ifdef GKFS_ENABLE_AGIOS #include <daemon/scheduler/agios.hpp> #endif Loading Loading @@ -389,6 +394,45 @@ initialize_loggers() { gkfs::log::setup(logger_names, level, path); } string get_host_default(){ char buf[1024]; struct ifconf ifc; struct ifreq *ifr; int sck; int nInterfaces; int i; /* Get a socket handle. */ sck = socket(AF_INET, SOCK_DGRAM, 0); if(sck < 0){ perror("socket"); return ""s; } /* Query available interfaces. */ ifc.ifc_len = sizeof(buf); ifc.ifc_buf = buf; if(ioctl(sck, SIOCGIFCONF, &ifc) < 0){ perror("ioctl(SIOCGIFCONF)"); return ""s; } /* Iterate through the list of interfaces. */ ifr = ifc.ifc_req; nInterfaces = ifc.ifc_len / sizeof(struct ifreq); for(i = 0; i < nInterfaces; i++){ struct ifreq *item = &ifr[i]; if(strcmp(item->ifr_name, "lo") != 0) return inet_ntoa(((struct sockaddr_in *)&item->ifr_addr)->sin_addr); } if(nInterfaces > 0) return inet_ntoa(((struct sockaddr_in *)&(&ifr[0])->ifr_addr)->sin_addr); return ""s; } /** * * @param vm Loading Loading @@ -430,7 +474,8 @@ parse_input(const po::variables_map& vm) { } } else { if(rpc_protocol != gkfs::rpc::protocol::ofi_verbs) addr = gkfs::rpc::get_my_hostname(true); addr = get_host_default(); } GKFS_DATA->rpc_protocol(rpc_protocol); Loading Loading @@ -512,7 +557,7 @@ main(int argc, const char* argv[]) { "Metadata directory where GekkoFS' RocksDB data directory is located. If not set, rootdir is used."); desc.add_options()( "listen,l", po::value<string>(), "Address or interface to bind the daemon to. Default: local hostname.\n" "Address or interface to bind the daemon to. Default: First non-localhost interface.\n" "When used with ofi+verbs the FI_VERBS_IFACE environment variable is set accordingly " "which associates the verbs device with the network interface. In case FI_VERBS_IFACE " "is already defined, the argument is ignored. Default 'ib'."); Loading Loading
src/daemon/daemon.cpp +47 −2 Original line number Diff line number Diff line Loading @@ -40,6 +40,11 @@ #include <daemon/backend/data/chunk_storage.hpp> #include <daemon/util.hpp> #include <sys/ioctl.h> #include <net/if.h> #include <netinet/in.h> #include <stdio.h> #include <arpa/inet.h> #ifdef GKFS_ENABLE_AGIOS #include <daemon/scheduler/agios.hpp> #endif Loading Loading @@ -389,6 +394,45 @@ initialize_loggers() { gkfs::log::setup(logger_names, level, path); } string get_host_default(){ char buf[1024]; struct ifconf ifc; struct ifreq *ifr; int sck; int nInterfaces; int i; /* Get a socket handle. */ sck = socket(AF_INET, SOCK_DGRAM, 0); if(sck < 0){ perror("socket"); return ""s; } /* Query available interfaces. */ ifc.ifc_len = sizeof(buf); ifc.ifc_buf = buf; if(ioctl(sck, SIOCGIFCONF, &ifc) < 0){ perror("ioctl(SIOCGIFCONF)"); return ""s; } /* Iterate through the list of interfaces. */ ifr = ifc.ifc_req; nInterfaces = ifc.ifc_len / sizeof(struct ifreq); for(i = 0; i < nInterfaces; i++){ struct ifreq *item = &ifr[i]; if(strcmp(item->ifr_name, "lo") != 0) return inet_ntoa(((struct sockaddr_in *)&item->ifr_addr)->sin_addr); } if(nInterfaces > 0) return inet_ntoa(((struct sockaddr_in *)&(&ifr[0])->ifr_addr)->sin_addr); return ""s; } /** * * @param vm Loading Loading @@ -430,7 +474,8 @@ parse_input(const po::variables_map& vm) { } } else { if(rpc_protocol != gkfs::rpc::protocol::ofi_verbs) addr = gkfs::rpc::get_my_hostname(true); addr = get_host_default(); } GKFS_DATA->rpc_protocol(rpc_protocol); Loading Loading @@ -512,7 +557,7 @@ main(int argc, const char* argv[]) { "Metadata directory where GekkoFS' RocksDB data directory is located. If not set, rootdir is used."); desc.add_options()( "listen,l", po::value<string>(), "Address or interface to bind the daemon to. Default: local hostname.\n" "Address or interface to bind the daemon to. Default: First non-localhost interface.\n" "When used with ofi+verbs the FI_VERBS_IFACE environment variable is set accordingly " "which associates the verbs device with the network interface. In case FI_VERBS_IFACE " "is already defined, the argument is ignored. Default 'ib'."); Loading