Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Winsock name resolution APIs use separate cache entries for AF_UNSPEC and AF_INET/AF_INET6 queries


Symptoms

After an application calls getaddrinfo with AF_UNSPEC on hints, if you call getaddrinfo again with AF_INET/AF_INET6, the function doesn't use the DNS cache and sends a DNS query to the wire. DnsQuery with option DNS_QUERY_NO_WIRE_QUERY may fail with DNS_ERROR_RECORD_DOES_NOT_EXIST even after an application calls getaddrinfo.

↑ Back to the top


Cause

When IE or an application calls getaddrinfo with AF_UNSPEC on a machine which has IPv4 and Ipv6 addresses, it results in dual address query from winsock to dns. Dns caches these dual address queries into a bucket with a specific private flag so that it can only be retrieved through application calling that flag (only winsock APIs calling getaddrinfo but not through DnsQuery publicly documented flags).

↑ Back to the top


Resolution

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section of this article.

↑ Back to the top


More Information

Below are two common scenarios for this issue.


Scenario A:

1 Start Network monitor and monitor DNS traffic.

2 Call getaddrinfo for a name using AF_UNSPEC flags on hints (A pointer to an addrinfo structure)
for the addrinfo Structure, please refer to MSDN document:
http://msdn.microsoft.com/en-us/library/ms737530(v=VS.85).aspx

3 Call getaddrinfo for the same name using AF_INET.

4 Call getaddrinfo for the same name using AF_UNSPEC.


Expected result:

Only the second step should send a query to the wire.


Actual result:

Steps 3 and 4 also send a query to the wire and not use cache.



Scenario B:

1 Call getaddrinfo for a name using AF_UNSPEC on hints.

2 Call DnsQuery with option DNS_QUERY_NO_WIRE_QUERY
(Windows 2000 Server and Windows 2000 Professional: use DNS_QUERY_CACHE_ONLY flag instead.)

Expected result:

DsnQuery can get the record from DNS cache.


Actual result:

DnsQuery fails with DNS_ERROR_RECORD_DOES_NOT_EXIST.

↑ Back to the top


Keywords: kbwinsock, kbdns, kb

↑ Back to the top

Article Info
Article ID : 2299432
Revision : 1
Created on : 1/7/2017
Published on : 8/4/2010
Exists online : False
Views : 707