Avoid keeping sending queries to an invalid nameserver

When a nameserver is known to be not workable due to wrong setup,
e.g. invalid address or network unreachable, it should be considered
unusable, just like what the code does for a nameserver which always
times out.

This change is beneficial to:
  [1] Fix the bug which the code can never mark all of the
      nameservers as unusable in some edge cases.
  [2] Decrease the noise of internal_error in the metrics.

Bug: 144828038
Test: cd packages/modules/DnsResolver && atest
Change-Id: Id84c49690a7ae1dbd209f9f7751120052efd6c13
3 files changed
tree: 931c3bc8c22a2f6998c0e83af76987aa3d23d8a6
  1. aidl_api/
  2. apex/
  3. binder/
  4. include/
  5. tests/
  6. .editorconfig
  7. Android.bp
  8. Dns64Configuration.cpp
  9. Dns64Configuration.h
  10. DnsProxyListener.cpp
  11. DnsProxyListener.h
  12. DnsResolver.cpp
  13. DnsResolver.h
  14. DnsResolverService.cpp
  15. DnsResolverService.h
  16. DnsStats.cpp
  17. DnsStats.h
  18. DnsStatsTest.cpp
  19. DnsTlsDispatcher.cpp
  20. DnsTlsDispatcher.h
  21. DnsTlsQueryMap.cpp
  22. DnsTlsQueryMap.h
  23. DnsTlsServer.cpp
  24. DnsTlsServer.h
  25. DnsTlsSessionCache.cpp
  26. DnsTlsSessionCache.h
  27. DnsTlsSocket.cpp
  28. DnsTlsSocket.h
  29. DnsTlsSocketFactory.h
  30. DnsTlsTransport.cpp
  31. DnsTlsTransport.h
  32. getaddrinfo.cpp
  33. getaddrinfo.h
  34. gethnamaddr.cpp
  35. gethnamaddr.h
  36. hostent.h
  37. IDnsTlsSocket.h
  38. IDnsTlsSocketFactory.h
  39. IDnsTlsSocketObserver.h
  40. libnetd_resolv.map.txt
  41. LockedQueue.h
  42. NOTICE
  43. OWNERS
  44. params.h
  45. PREUPLOAD.cfg
  46. PrivateDnsConfiguration.cpp
  47. PrivateDnsConfiguration.h
  48. README-DoT.md
  49. README.md
  50. res_cache.cpp
  51. res_comp.cpp
  52. res_debug.cpp
  53. res_debug.h
  54. res_init.cpp
  55. res_init.h
  56. res_mkquery.cpp
  57. res_query.cpp
  58. res_send.cpp
  59. res_send.h
  60. res_stats.cpp
  61. resolv_cache.h
  62. resolv_cache_unit_test.cpp
  63. resolv_private.h
  64. resolv_tls_unit_test.cpp
  65. resolv_unit_test.cpp
  66. ResolverController.cpp
  67. ResolverController.h
  68. ResolverEventReporter.cpp
  69. ResolverEventReporter.h
  70. ResolverStats.h
  71. sethostent.cpp
  72. stats.h
  73. stats.proto
  74. TEST_MAPPING
  75. util.cpp
  76. util.h
README.md

Logging

This code uses LOG(X) for logging. Log levels are VERBOSE,DEBUG,INFO,WARNING and ERROR. The default setting is WARNING and logs relate to WARNING and ERROR will be shown. If you want to enable the DEBUG level logs, using following command. adb shell service call dnsresolver 10 i32 1 VERBOSE 0 DEBUG 1 INFO 2 WARNING 3 ERROR 4 Verbose resolver logs could contain PII -- do NOT enable in production builds.