diff --git a/deps/oblib/src/lib/net/ob_net_util.cpp b/deps/oblib/src/lib/net/ob_net_util.cpp index e4acc5967d..d2c79cfd3b 100644 --- a/deps/oblib/src/lib/net/ob_net_util.cpp +++ b/deps/oblib/src/lib/net/ob_net_util.cpp @@ -77,6 +77,13 @@ int ObNetUtil::get_local_addr_ipv6(const char *dev_name, char *ipv6, int len, } // if end ifa_tmp = ifa_tmp->ifa_next; } // while end + + // if dev_name is invalid, then level will keep its initial value(-1) + if (level == -1) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("invalid devname specified by -i", "devname", dev_name, "info", + "you may list devnames by shell command: ifconfig"); + } } if (nullptr != ifa) { @@ -111,6 +118,12 @@ uint32_t ObNetUtil::get_local_addr_ipv4(const char *dev_name) } // if end ifa_tmp = ifa_tmp->ifa_next; } // while end + + if (!has_found) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("invalid devname specified by -i", "devname", dev_name, "info", + "you may list devnames by shell command: ifconfig"); + } } if (nullptr != ifa) {