From patchwork Tue Sep 5 16:05:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Stelmach?= X-Patchwork-Id: 22625 Received: (qmail 118119 invoked by alias); 5 Sep 2017 16:06:19 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 118097 invoked by uid 89); 5 Sep 2017 16:06:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=AAAA, Hx-languages-length:1898, aaaa, HContent-Transfer-Encoding:8bit X-HELO: smtpo.poczta.interia.pl X-Interia-R: Interia X-Interia-R-IP: 89.64.33.181 X-Interia-R-Helo: From: =?UTF-8?q?=C5=81ukasz=20Stelmach?= To: libc-alpha@sourceware.org Cc: =?UTF-8?q?=C5=81ukasz=20Stelmach?= Subject: [RFC][PATCH 4/4][BZ 17083] getaddrinfo: Use the new getaddrinfo5_r NSS function Date: Tue, 5 Sep 2017 18:05:30 +0200 Message-Id: <20170905160530.19525-5-stlman@poczta.fm> In-Reply-To: <20170905160530.19525-1-stlman@poczta.fm> References: <20170905160530.19525-1-stlman@poczta.fm> MIME-Version: 1.0 X-Interia-Antivirus: OK X-IPL-POID: 4 X-IPL-SAS-SPAS: -0.6 X-IPL-SAS-UREP: 0 X-IPL-SAS-UREP-PRIV: 0 X-IPL-Envelope-To: stlman@poczta.fm Signed-off-by: Ɓukasz Stelmach --- sysdeps/posix/getaddrinfo.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index 4b4e192e89..38e231091a 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -302,6 +302,10 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req, } +typedef enum nss_status (*nss_gethostbyname5_r) + (const char *name, int af, struct gaih_addrtuple **pat, + char *buffer, size_t buflen, int *errnop, + int *h_errnop, int32_t *ttlp); typedef enum nss_status (*nss_gethostbyname4_r) (const char *name, struct gaih_addrtuple **pat, char *buffer, size_t buflen, int *errnop, @@ -777,19 +781,27 @@ gaih_inet (const char *name, const struct gaih_service *service, no_data = 0; nss_gethostbyname4_r fct4 = NULL; + /* gethostbyname5_r accepts af argument and returns + gaih_addrtupple. What more do we need? */ + nss_gethostbyname5_r fct5 = __nss_lookup_function (nip, "gethostbyname5_r"); /* gethostbyname4_r sends out parallel A and AAAA queries and is thus only suitable for PF_UNSPEC. */ - if (req->ai_family == PF_UNSPEC) + if (req->ai_family == PF_UNSPEC && fct5 == NULL) fct4 = __nss_lookup_function (nip, "gethostbyname4_r"); - - if (fct4 != NULL) + if (fct5 != NULL || fct4 != NULL) { while (1) { - status = DL_CALL_FCT (fct4, (name, pat, - tmpbuf->data, tmpbuf->length, - &errno, &h_errno, - NULL)); + if (fct5 != NULL) + status = DL_CALL_FCT (fct5, (name, req->ai_family, pat, + tmpbuf->data, tmpbuf->length, + &errno, &h_errno, + NULL)); + else + status = DL_CALL_FCT (fct4, (name, pat, + tmpbuf->data, tmpbuf->length, + &errno, &h_errno, + NULL)); if (status == NSS_STATUS_SUCCESS) break; if (status != NSS_STATUS_TRYAGAIN