[dns-client] enhance logic for following up with IPv4 address query (#10781)

This commit updates the `ReplaceWithIp4Query()` method, which
determines whether an unsuccessful IPv6 address query should be
followed up with an IPv4 query.

The logic is changed as follows:

- If the response code to the IPv6 query indicates success but the
  answer section is empty (meaning the name exists but has no IPv6
  address), or the response code indicates an error other than
  `NameError`, the query is replaced with an IPv4 address resolution
  query for the same name.
- If the server responds with `NameError` (RCode=3), indicating that
  the name doesn't exist, an IPv4 query is not attempted.

This replaces the previous behavior where a follow-up query was
attempted for any error response code.
This commit is contained in:
Abtin Keshavarzian
2024-10-11 10:32:53 -07:00
committed by GitHub
parent af2e10a7bf
commit d163dee2af
3 changed files with 35 additions and 8 deletions
@@ -1696,6 +1696,7 @@ void TestProxyTimeout(void)
config.Clear();
config.mResponseTimeout = 120 * 1000; // 2 minutes (in msec)
config.mNat64Mode = OT_DNS_NAT64_DISALLOW;
dnsClient->SetDefaultConfig(config);
Log("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ");