From patchwork Wed Jun 10 09:25:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 482567 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 07644140295 for ; Wed, 10 Jun 2015 19:25:16 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=sourceware.org header.i=@sourceware.org header.b=a/JKgS1B; dkim-atps=neutral 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=pmo6Au07YXo2u8RpGreZ+Zg4d3A1Q CXC95rUODnYuTTkr7qYQIYmbIyy68uk0QYB/kMYZSatlvtag8nnQl50CwtpFxOCf LWqXkZjHXME44xgyKjpoO87bt3rt5w7SAezZyZMsayX10nklegeSLgBXNpckSGBB n+QQVtnfBNKXCA= 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=cEobztPmuBaWX+Eh/x0dUXaOsiA=; b=a/J KgS1Bk+r0COjXc/Lp/Hf9LGfjudZVpYrunqtU7snFHhUsh1Zqyd2433suGJFUAvA 5R74eU7VWtkQtnUSYXxfOmmCkmgUeKB7rqOcssmE/5RpRajocflgDxjWEEBQcKoB UZIbdQecs1/htnXLc7wphnUFVoeNi/+pwmEIRdA8= Received: (qmail 17089 invoked by alias); 10 Jun 2015 09:25:10 -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 17080 invoked by uid 89); 10 Jun 2015 09:25:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx2.suse.de From: Andreas Schwab To: libc-alpha@sourceware.org Subject: [PATCH] Record TTL also for DNS PTR queries X-Yow: Where's my SOCIAL WORKER? Date: Wed, 10 Jun 2015 11:25:03 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 This allows nscd to manage proper TTL for GETHOSTBYADDR[v6] requests. Andreas. [BZ #18513] * resolv/nss_dns/dns-host.c (getanswer_r): Record TTL also for PTR queries. --- resolv/nss_dns/dns-host.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index d8c5579..357ac04 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -800,6 +800,10 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, if (qtype == T_PTR && type == T_CNAME) { + /* A CNAME could also have a TTL entry. */ + if (ttlp != NULL && ttl < *ttlp) + *ttlp = ttl; + n = dn_expand (answer->buf, end_of_message, cp, tbuf, sizeof tbuf); if (__glibc_unlikely (n < 0 || res_dnok (tbuf) == 0)) { @@ -863,6 +867,8 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, ++had_error; break; } + if (ttlp != NULL && ttl < *ttlp) + *ttlp = ttl; /* bind would put multiple PTR records as aliases, but we don't do that. */ result->h_name = bp;