This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Record TTL also for DNS PTR queries
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: libc-alpha at sourceware dot org
- Date: Tue, 16 Jun 2015 19:19:17 +0200
- Subject: Re: [PATCH] Record TTL also for DNS PTR queries
- Authentication-results: sourceware.org; auth=none
- References: <mvm7frbgbkg dot fsf at hawking dot suse dot de>
On Wed, Jun 10, 2015 at 11:25:03AM +0200, Andreas Schwab wrote:
> This allows nscd to manage proper TTL for GETHOSTBYADDR[v6] requests.
>
> Andreas.
>
I looked into code and its bit suspect, gaih_getanswer_slice updates
ttl when following holds.
if (type == T_CNAME)
{
I couldn't find from code when exacly we need to update ttl and when
not. Ideally I would put conditions to update ttl just after reading
that where its easily checkable.
> [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;
> --
> 2.4.3
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."