From owner-svn-src-all@freebsd.org Mon Feb 4 20:10:01 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A069714B0B09; Mon, 4 Feb 2019 20:10:01 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E04CE702D6; Mon, 4 Feb 2019 20:10:00 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id x14K9v64037930; Mon, 4 Feb 2019 12:09:57 -0800 (PST) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id x14K9vIJ037929; Mon, 4 Feb 2019 12:09:57 -0800 (PST) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201902042009.x14K9vIJ037929@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r343751 - head/lib/libc/tests/sys In-Reply-To: <201902041912.x14JCjBd020269@repo.freebsd.org> To: Enji Cooper Date: Mon, 4 Feb 2019 12:09:57 -0800 (PST) CC: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: E04CE702D6 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.97 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Feb 2019 20:10:01 -0000 > Author: ngie > Date: Mon Feb 4 19:12:45 2019 > New Revision: 343751 > URL: https://svnweb.freebsd.org/changeset/base/343751 > > Log: > Avoid the DNS lookup for "localhost" > > ci.FreeBSD.org does not have access to a DNS resolver/network (unlike my test > VM), so in order for the test to pass on the host, it needs to avoid the DNS > lookup by using the numeric host address representation. If it can not get to a resolver, it should be falling back to /etc/hosts whch does have the correct entries for localhost. > > PR: 235200 > Reviewed by: asomers, lwhsu > Approved by: emaste (mentor) > MFC after: 2 weeks > MFC with: r343362, r343365, r343367-r343368, r343461 > Differential Revision: https://reviews.freebsd.org/D19026 > > Modified: > head/lib/libc/tests/sys/sendfile_test.c > > Modified: head/lib/libc/tests/sys/sendfile_test.c > ============================================================================== > --- head/lib/libc/tests/sys/sendfile_test.c Mon Feb 4 18:30:47 2019 (r343750) > +++ head/lib/libc/tests/sys/sendfile_test.c Mon Feb 4 19:12:45 2019 (r343751) > @@ -97,22 +97,31 @@ generate_random_port(int seed) > static void > resolve_localhost(struct addrinfo **res, int domain, int type, int port) > { > + const char *host; > char *serv; > struct addrinfo hints; > int error; > > - ATF_REQUIRE_MSG(domain == AF_INET || domain == AF_INET6, > - "unhandled domain: %d", domain); > + switch (domain) { > + case AF_INET: > + host = "127.0.0.1"; > + break; > + case AF_INET6: > + host = "::1"; > + break; > + default: > + atf_tc_fail("unhandled domain: %d", domain); > + } > > ATF_REQUIRE_MSG(asprintf(&serv, "%d", port) >= 0, > "asprintf failed: %s", strerror(errno)); > > memset(&hints, 0, sizeof(hints)); > hints.ai_family = domain; > - hints.ai_flags = AI_ADDRCONFIG|AI_NUMERICSERV; > + hints.ai_flags = AI_ADDRCONFIG|AI_NUMERICSERV|AI_NUMERICHOST; > hints.ai_socktype = type; > > - error = getaddrinfo("localhost", serv, &hints, res); > + error = getaddrinfo(host, serv, &hints, res); > ATF_REQUIRE_EQ_MSG(error, 0, > "getaddrinfo failed: %s", gai_strerror(error)); > free(serv); -- Rod Grimes rgrimes@freebsd.org