This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Can getaddrinfo() be extended to return the record TTL
- From: David Howells <dhowells at redhat dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: dhowells at redhat dot com, jlayton at redhat dot com, libc-alpha at sourceware dot org
- Date: Fri, 02 Aug 2019 17:42:22 +0100
- Subject: Can getaddrinfo() be extended to return the record TTL
Hi Florian,
The Linux kernel has an upcall to get name -> address mappings for network
filesystems. The userspace side (key.dns_resolver.c in keyutils) uses
getaddrinfo() to perform the lookup as this gives a greater range of sources
than, say, using res_send(), giving access to NIS, YP, LDAP, files or
whatever, but getaddrinfo() does not include any expiry information for the
information.
The userspace side of the upcall *should* be setting the expiry time on the
record - but it can't as the C library doesn't give us that (and, indeed, it's
not available from all sources).
The userspace upcall program *does* do it for AFSDB records for the afs
filesystem since those are looked up directly in the DNS and the TTL record is
thus available.
Anyway, looking at getaddrinfo(), it looks like the addrinfo struct should be
extensible. Perhaps a flag, say AI_EXTENDED, could be provided that indicates
that is replaced with a larger struct that has additional fields such as
expiry time and a flag, AI_HAS_EXPIRY that indicates if the expiry time is
actually set.
This looks like it should work as the result records appear to be in a list
rather than being an array.
Another possible additional field would be a source indicator of some kind
that says where the data came from (e.g. 0=file, 1=dns, 2=yp, 3=ldap, ...).
If it's not possible to extend getaddrinfo() in this way, would it be possible
to provide a getaddrinfo2() that returns this information through an
additional parameter?
Thanks,
David