[webkit-changes] [WebKit/WebKit] 5aa25a: DNS lookup should request then wait for IPv4 and I...

Alex Christensen noreply at github.com
Mon May 29 08:51:56 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5aa25a106be747000c280a1e55134b906f9ffc41
      https://github.com/WebKit/WebKit/commit/5aa25a106be747000c280a1e55134b906f9ffc41
  Author: Alex Christensen <achristensen at apple.com>
  Date:   2023-05-29 (Mon, 29 May 2023)

  Changed paths:
    M Source/WebCore/platform/network/DNS.cpp
    M Source/WebCore/platform/network/DNS.h
    M Source/WebCore/platform/network/cf/DNSResolveQueueCFNet.cpp

  Log Message:
  -----------
  DNS lookup should request then wait for IPv4 and IPv6 addresses
https://bugs.webkit.org/show_bug.cgi?id=257404
rdar://109911384

Reviewed by Youenn Fablet.

As advised by one who knows DNS better than I do, with the code I wrote earlier today
in https://github.com/WebKit/WebKit/pull/14326 I am missing some of the IP addresses.

To receive a set of IP addresses equivalent to what CFHost received, I need to add
the kDNSServiceFlagsReturnIntermediates flag.

Also, there are some times when we receive IPv4 addresses then get a callback with
kDNSServiceFlagsMoreComing and then sometime later receive IPv6 addresses, or vice versa.
The addresses from the second set of callbacks were being dropped.  To fix this,
I explicitly add the protocols kDNSServiceProtocol_IPv4 | kDNSServiceProtocol_IPv6
to request callbacks for both protocols.  This makes it so that sometimes I get
callbacks with kDNSServiceErr_NoSuchRecord and callbacks with IP addresses that are all
zeros.  We simiply ignore kDNSServiceErr_NoSuchRecord and filter out all the all-zero
IP addresses.  That way the result of DNSResolveQueueCFNet::performDNSLookup always
contains all the IP addresses.

I manually verified that IP address lists were incomplete sometimes before this change,
and now they are complete all the time.  There are also two unit tests that exercise
this code path, webrtc/datachannel/mdns-ice-candidates.html and TestWebKitAPI.WebKit2.RTCDataChannelPostMessage
and I verified that they both pass.

* Source/WebCore/platform/network/DNS.cpp:
(WebCore::IPAddress::isAllZeros const):
* Source/WebCore/platform/network/DNS.h:
* Source/WebCore/platform/network/cf/DNSResolveQueueCFNet.cpp:
(WebCore::DNSResolveQueueCFNet::CompletionHandlerWrapper::complete):
(WebCore::DNSResolveQueueCFNet::CompletionHandlerWrapper::addIPAddress):
(WebCore::DNSResolveQueueCFNet::CompletionHandlerWrapper::shouldWaitForMoreAddresses const):
(WebCore::DNSResolveQueueCFNet::CompletionHandlerWrapper::filterZeroAddresses):
(WebCore::dnsLookupCallback):
(WebCore::DNSResolveQueueCFNet::performDNSLookup):

Canonical link: https://commits.webkit.org/264655@main




More information about the webkit-changes mailing list