This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
usage of the extended __res_state
- From: Petar Bogdanovic <petar at smokva dot net>
- To: libc-help at sourceware dot org
- Date: Wed, 30 Sep 2009 20:34:21 +0200
- Subject: usage of the extended __res_state
Hi,
how exactly does the extended __res_state work? I've spent several
hours with trial'n'error (resolver related documentation seems to be
scarce) and still wasn't able to get something like a general idea.
The basic stuff seems simple: _ext.nsaddr contains ipv6 addresses,
_ext.nscount6 contains the sum of all ipv6-servers. What's left is
_ext.nsmap and according to Jakub Jelinek (in a post which is about
eight years old):
> ----- http://sourceware.org/ml/libc-hacker/2002-05/msg00035.html
>
> nsmap[X] = Y means that..
>
> 1. nsaddrs[X] is unused slot if Y == MAXNS
>
> 2. nsaddrs[X] is an IPv6 address if Y == MAXNS + 1
>
> 3. nsmap[X] = Y means that nsaddrs[X] corresponds to
> nsaddr_list[Y] if Y < MAXNS
>
> -----
I can confirm 1. and 2. but while I think I also understood number 3.,
it certainly didn't work the way I expected it to work. Here are three
things that I can remember:
- When one address in nsaddr_list was `0.0.0.0', the resolver
didn't just skip it, it tried 127.0.0.1. Even if there were
other ipv4 servers in the queue. I thought 127.0.0.1 was the
last resort when there is no resolv.conf an nothing was
provided manually.
- When having MAXNS nameservers in a ipv4/ipv6 resolv.conf, with
::1 being on the first place, the resolver tried ::1,
127.0.0.1, 1.1.1.1 and skipped the last nameserver, 2.2.2.2.
- When having MAXNS nameservers in a ipv4 resolv.conf (1.1.1.1,
2.2.2.2, 3.3.3.3), manually setting nsaddr_list[0] to 0.0.0.0
and nsaddrs[0] to ::1, the resolver tried 2.2.2.2 (twice) and
then fell back to ::1.
I've read the related parts in resolv/res_init.c and it seemed mostly
consistent with the things I did in order to set/override an ipv6-
address. So is there maybe something else that I have to keep in mind
when messing with a mixed (ipv4/ipv6) serverlist (or messing with
nsaddr_list/nsaddrs in general)? A variation of res_setservers()
perhaps?
Also should one use __res_state at all? The prefix somehow wants to
tell me that it's res_state I'm actually looking for.
Thanks,
Petar Bogdanovic