Two copies of resolver routines in libc ?

Hajimu UMEMOTO ume at
Sat Nov 8 00:40:01 PST 2008


>>>>> On Thu, 6 Nov 2008 20:21:03 +0100
>>>>> Luigi Rizzo <rizzo at> said:

rizzo> While looking for a workaround (attached, read later), i noticed
rizzo> that libc has two versions of the resolver routines: one is in

rizzo>         /usr/src/lib/libc/resolv/res_query.c

rizzo> the other one is embedded into
rizzo>         /usr/src/lib/libc/net/getaddrinfo.c

rizzo> which includes a slightly modified version of res_nquery, res_ndots,
rizzo> res_nquerydomain (all parts of the routines documented in resolver(3)).


rizzo> If we are lucky, this is just replicated code.

No, the resolver functions in getaddrinfo.c has some addition of
functionality.  It was done for solving the query order problem.

rizzo> But i am not even sure they are the same, e.g. in the handling of
rizzo> options (in resolv.conf or the environment variable RES_OPTIONS).

The basic functionality including the handling of options are same.

rizzo> This is really annoying, because generally you don't know if an
rizzo> application uses getaddrinfo() or the traditional gethost*() routines
rizzo> (which in turn use resolver(3)), so it is hard to tell whether
rizzo> applications have a consistent behaviour.

You don't need to worry about it.

rizzo> If someone has time, it would be worthwhile trying to merge
rizzo> the two versions of the code into one (and i believe we should
rizzo> make getaddrinfo use the standard stuff in resolv/

When we tried to solve the query order problem, we decided to have a
modification code of the resolver into getaddrinfo.c.  Because:

  - Hide the internal functions from outside of libc.
  - Don't change the resolver as possible to ease further merge from

Since we have the symbol versioning facility, we can hide the libc
internal functions from outside of libc, these days.  So, it may
better to merge the two.  I attached the proposed patch in this mail.
Please review it.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: resolver-multi.diff
Type: text/x-patch
Size: 19773 bytes
Desc: not available
Url :
-------------- next part --------------

Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
ume at  ume@{,jp.}

More information about the freebsd-net mailing list