Modularize resolver statistics

The extendibility of the legacy resolver statistics is limited because
it was originally designed for libc, which is hard to implement to
support other types of DNS, e.g. DNS-over-TLS. Therefore, DnsStats
is introduced to manage the statistics in a more general way.

DoT statistics is now available from DnsStats and is shown in
dumpsys dnsresolver.

Example of output from dumpsys dnsresolver:

Server statistics: (total, RTT avg, {rcode:counts}, last update)
  over UDP
    8.8.4.4 <no data>
    8.8.8.8 <no data>
    2001:4860:4860::8844 (7, 2201ms, [NOERROR:4 TIMEOUT:3 ], 2s)
    2001:4860:4860::8888 (3, 11ms, [NOERROR:3 ], 4s)
  over TLS
    <no server>
  over TCP
    8.8.4.4 <no data>
    8.8.8.8 <no data>
    2001:4860:4860::8844 <no data>
    2001:4860:4860::8888 <no data>

Bug: 140286585
Test: atest --include-subdirs packages/modules/DnsResolver
Test: checked output in dumpsys dnsresolver
Change-Id: I73f0108d5e9bb493cf7eda68252f5a0922149a98
11 files changed
tree: f0ba775dd52d239acf6042104d12c39d3fbfcfd5
  1. aidl/
  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. dnsresolver_binder_test.cpp
  15. DnsResolverService.cpp
  16. DnsResolverService.h
  17. DnsStats.cpp
  18. DnsStats.h
  19. DnsStatsTest.cpp
  20. DnsTlsDispatcher.cpp
  21. DnsTlsDispatcher.h
  22. DnsTlsQueryMap.cpp
  23. DnsTlsQueryMap.h
  24. DnsTlsServer.cpp
  25. DnsTlsServer.h
  26. DnsTlsSessionCache.cpp
  27. DnsTlsSessionCache.h
  28. DnsTlsSocket.cpp
  29. DnsTlsSocket.h
  30. DnsTlsSocketFactory.h
  31. DnsTlsTransport.cpp
  32. DnsTlsTransport.h
  33. getaddrinfo.cpp
  34. getaddrinfo.h
  35. gethnamaddr.cpp
  36. gethnamaddr.h
  37. hostent.h
  38. IDnsTlsSocket.h
  39. IDnsTlsSocketFactory.h
  40. IDnsTlsSocketObserver.h
  41. libnetd_resolv.map.txt
  42. LockedQueue.h
  43. NOTICE
  44. OWNERS
  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_integration_test.cpp
  64. resolv_private.h
  65. resolv_tls_unit_test.cpp
  66. resolv_unit_test.cpp
  67. ResolverController.cpp
  68. ResolverController.h
  69. ResolverEventReporter.cpp
  70. ResolverEventReporter.h
  71. ResolverStats.h
  72. sethostent.cpp
  73. stats.proto
  74. TEST_MAPPING
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.