X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fsocket-util.c;h=3fcd5a1e8e79f73210c0d2ec70feeb33b370a1dd;hb=a5e54d9b6f8002f34cc792df69e6eda68cf95223;hp=d537434879ccf085304c085979aad1fcae421378;hpb=4cff83cbad9c0ccd8575a001c7345066a2e6fa00;p=sliver-openvswitch.git diff --git a/lib/socket-util.c b/lib/socket-util.c index d53743487..3fcd5a1e8 100644 --- a/lib/socket-util.c +++ b/lib/socket-util.c @@ -73,25 +73,16 @@ get_max_fds(void) return max_fds; } -/* Translates 'host_name', which may be a DNS name or an IP address, into a - * numeric IP address in '*addr'. Returns 0 if successful, otherwise a - * positive errno value. */ +/* Translates 'host_name', which must be a string representation of an IP + * address, into a numeric IP address in '*addr'. Returns 0 if successful, + * otherwise a positive errno value. */ int lookup_ip(const char *host_name, struct in_addr *addr) { if (!inet_aton(host_name, addr)) { - struct hostent *he = gethostbyname(host_name); - if (he == NULL) { - struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); - VLOG_ERR_RL(&rl, "gethostbyname(%s): %s", host_name, - (h_errno == HOST_NOT_FOUND ? "host not found" - : h_errno == TRY_AGAIN ? "try again" - : h_errno == NO_RECOVERY ? "non-recoverable error" - : h_errno == NO_ADDRESS ? "no address" - : "unknown error")); - return ENOENT; - } - addr->s_addr = *(uint32_t *) he->h_addr; + struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_ERR_RL(&rl, "\"%s\" is not a valid IP address", host_name); + return ENOENT; } return 0; }