From patchwork Thu May 16 18:18:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1100696 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-102039-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="IFKLY/jq"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 454fnM2CfRz9s9N for ; Fri, 17 May 2019 04:18:47 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=Xhj+uc2NJnC9mswXKcTevmEJqdhVX uU7OtPa0nkpZkGeH4SBis+u9BVYzuqeQrBteztv8G/sVCd2XadPVnHrOv1cgywQh 4HZZab1unMZtuu4jyDS0wU5SbGXSfOp9V5t8CQXcBpndDR2k0bp3hoABHF4WPRI0 J6fD74L4/AAIsc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; s=default; bh=pXmxNmoc5I/YmPe2t4j56oW4hdY=; b=IFK LY/jqAz2w47W6lyHHciOvwBM+V4zalZostogLYXJObLhroJggc9IQ0Tfg0ichMO/ mK2MfacoPJOBHxnirCkCjqEKjIGKr9v7Fm049A+ixMclV9s/GePwKZ6fDW6SVLlr zZIThHb8Ad8E3Cd1j8EAr0XynVyv0URI2Z+6HAxw= Received: (qmail 83717 invoked by alias); 16 May 2019 18:18:41 -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 83709 invoked by uid 89); 16 May 2019 18:18:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:4539 X-HELO: mx1.redhat.com From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH] nss_dns: Remove RES_USE_INET6 handling Date: Thu, 16 May 2019 20:18:36 +0200 Message-ID: <87ef4ys1oj.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Since commit 3f8b44be0a658266adff5ece1e4bc3ce097a5dbe ("resolv: Remove support for RES_USE_INET6 and the inet6 option"), res_use_inet6 () always evaluates to false. 2019-05-16 Florian Weimer * resolv/nss_dns/dns-host.c (gethostbyname3_context): Do not perform IPv6 lookup. (_nss_dns_gethostbyname_r): Do not request IPv4 address mapping from gethostbyname3_context. diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index 9c40051aff..40c23dfe00 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -85,10 +85,6 @@ #include #include -/* Get implementations of some internal functions. */ -#include -#include - #define RESOLVSORT #if PACKETSZ > 65536 @@ -114,7 +110,7 @@ static enum nss_status getanswer_r (struct resolv_context *ctx, const char *qname, int qtype, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop, - int map, int32_t *ttlp, char **canonp); + int32_t *ttlp, char **canonp); static enum nss_status gaih_getanswer (const querybuf *answer1, int anslen1, const querybuf *answer2, int anslen2, @@ -182,7 +178,6 @@ gethostbyname3_context (struct resolv_context *ctx, char tmp[NS_MAXDNAME]; int size, type, n; const char *cp; - int map = 0; int olderr = errno; enum nss_status status; @@ -244,31 +239,14 @@ gethostbyname3_context (struct resolv_context *ctx, else __set_errno (olderr); - /* If we are looking for an IPv6 address and mapping is enabled - by having the RES_USE_INET6 bit in _res.options set, we try - another lookup. */ - if (af == AF_INET6 && res_use_inet6 ()) - n = __res_context_search (ctx, name, C_IN, T_A, host_buffer.buf->buf, - host_buffer.buf != orig_host_buffer - ? MAXPACKET : 1024, &host_buffer.ptr, - NULL, NULL, NULL, NULL); - - if (n < 0) - { - if (host_buffer.buf != orig_host_buffer) - free (host_buffer.buf); - return status; - } - - map = 1; - - result->h_addrtype = AF_INET; - result->h_length = INADDRSZ; + if (host_buffer.buf != orig_host_buffer) + free (host_buffer.buf); + return status; } status = getanswer_r (ctx, host_buffer.buf, n, name, type, result, buffer, buflen, - errnop, h_errnop, map, ttlp, canonp); + errnop, h_errnop, ttlp, canonp); if (host_buffer.buf != orig_host_buffer) free (host_buffer.buf); return status; @@ -314,13 +292,8 @@ _nss_dns_gethostbyname_r (const char *name, struct hostent *result, *h_errnop = NETDB_INTERNAL; return NSS_STATUS_UNAVAIL; } - status = NSS_STATUS_NOTFOUND; - if (res_use_inet6 ()) - status = gethostbyname3_context (ctx, name, AF_INET6, result, buffer, - buflen, errnop, h_errnop, NULL, NULL); - if (status == NSS_STATUS_NOTFOUND) - status = gethostbyname3_context (ctx, name, AF_INET, result, buffer, - buflen, errnop, h_errnop, NULL, NULL); + status = gethostbyname3_context (ctx, name, AF_INET, result, buffer, + buflen, errnop, h_errnop, NULL, NULL); __resolv_context_put (ctx); return status; } @@ -547,7 +520,7 @@ _nss_dns_gethostbyaddr2_r (const void *addr, socklen_t len, int af, status = getanswer_r (ctx, host_buffer.buf, n, qbuf, T_PTR, result, buffer, buflen, - errnop, h_errnop, 0 /* XXX */, ttlp, NULL); + errnop, h_errnop, ttlp, NULL); if (host_buffer.buf != orig_host_buffer) free (host_buffer.buf); if (status != NSS_STATUS_SUCCESS) @@ -627,7 +600,7 @@ static enum nss_status getanswer_r (struct resolv_context *ctx, const querybuf *answer, int anslen, const char *qname, int qtype, struct hostent *result, char *buffer, size_t buflen, - int *errnop, int *h_errnop, int map, int32_t *ttlp, char **canonp) + int *errnop, int *h_errnop, int32_t *ttlp, char **canonp) { struct host_data { @@ -645,7 +618,6 @@ getanswer_r (struct resolv_context *ctx, const char *tname; int (*name_ok) (const char *); u_char packtmp[NS_MAXCDNAME]; - int have_to_map = 0; uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct host_data); buffer += pad; buflen = buflen > pad ? buflen - pad : 0; @@ -870,9 +842,7 @@ getanswer_r (struct resolv_context *ctx, continue; } - if (type == T_A && qtype == T_AAAA && map) - have_to_map = 1; - else if (__glibc_unlikely (type != qtype)) + if (__glibc_unlikely (type != qtype)) { cp += n; continue; /* XXX - had_error++ ? */ @@ -995,9 +965,6 @@ getanswer_r (struct resolv_context *ctx, linebuflen -= n; } - if (have_to_map) - if (map_v4v6_hostent (result, &bp, &linebuflen)) - goto too_small; *h_errnop = NETDB_SUCCESS; return NSS_STATUS_SUCCESS; }