aboutsummaryrefslogtreecommitdiff
path: root/res_debug.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix ambiguous fmt::format_to callsRyan Prichard2024-02-091-37/+35
| | | | | | | | | New versions of libc++ have a std::format_to that is also a candidate because of ADL. Bug: 175635923 Test: m MODULES-IN-packages-modules-DnsResolver Change-Id: I0cc891ddd869d7f41480851006b96cb8f0158bf9
* Update fmtlib to 10.1.1Henri Chataing2023-11-031-1/+1
| | | | | Test: m Change-Id: I3e6d11c49244ebe9a3ecf41e0e5ac8bb94a5f8d0
* DoH: Refactor FFIMatthew Maurer2021-10-051-6/+6
| | | | | | | | | | | | | | | | | * Factor out constants to level enum conversion * Document property that doh_init_logger will have no effect on future calls * Change `doh_set_log_level` to default to `Error` logging on an invalid value rather than disabling all logging. This matches the behavior of `doh_init_logger`. * Prefix constants with `DOH_`. `cbindgen`-exported constants are not in a namespace; they are raw C constants. Prepending the library name will help avoid future collisions. * `android_logger::init_once` explicitly states in the documentation that calling it more than once is safe, and will simply not change the logger on future calls. Bug: 202081046 Change-Id: I91a8a7f40363ee2dcf6211fb595e1c6e7f6084a8
* Replace StringAppendF() with fmt::format_tochenbruce2021-08-231-40/+41
| | | | | | Bug: 196298216 Test: cd packages/modules/DnsResolver && atest Change-Id: Iddcd0e69f46911ced852cf3994e6e243e9637820
* Replace StringPrintf() with fmt::format()chenbruce2021-08-201-1/+0
| | | | | | Bug: 196298216 Test: cd packages/modules/DnsResolver && atest Change-Id: I581c282bba1527afd2be9daf925e9ec5bd2e5cd6
* use std::span for res_pquerychenbruce2021-08-181-5/+16
| | | | | | | | | Manual buffer handling may make mistakes easily. Replacing it by std::span. Bug: 196298216 Test: cd packages/modules/DnsResolver && atest Change-Id: I2a9ebb5c9f7eb9d09fa7bdcafe4748eb2042ca6b
* Adjust the log mechanism for DoH and some minor changes.Luke Huang2021-07-201-0/+7
| | | | | | | | | | | | 1. Init the log level by device build. 2. Add TODO comment for aosp/1769446. 3. Higher the log level for sensitive log msgs. 4. Sort the input servers before processing it with DoH. Test: atest Bug: 193850030 Bug: 155855709 Change-Id: I67932699275354e7ebdb1636d7c8bf977d43cfbd
* Resolv: Replace BSD types with regular C99 typeschenbruce2019-09-181-8/+8
| | | | | | | | | Replace BSD types (u_long, u_int, u_char) with regular C99 types Bug: 140910031 Test: built, flashed, booted Test: atest Change-Id: I88829906f8e5be89ef3d5b222ebd4e4091a41b57
* Delete dump_bytes() and its helper functionsMike Yu2019-08-221-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change removes dump_bytes() as well as bprint_* functions which are used for debugging purpose. Instead, use netdutils Slice for hex dump since it's simpler and safer. Log example from res_pquery(): V resolv : ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37806 V resolv : ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 V resolv : ;; QUERY SECTION: V resolv : ;; google.com, type = A, class = IN V resolv : V resolv : ;; ANSWER SECTION: V resolv : ;; google.com. 4m59s IN A X.X.X.X V resolv : V resolv : V resolv : ;; ADDITIONAL SECTION: V resolv : ; EDNS: version: 0, udp=512, flags=8000 V resolv : V resolv : Hex dump: V resolv : 93ae8180000100010000000106676f6f676c6503636f6d0000010001c00c0001 V resolv : 00010000012b0004acd9a06e0000290200000080000000 For debugging, we can use scapy to parse the hex dump: pkt = "93ae8180000100010000000106676f6f676c6503636f6d0000010001c00c000100010000012b0004acd9a06e0000290200000080000000" DNS(pkt.decode("hex")).show2() Bug: 130686826 Bug: 139332724 Test: adb shell service call dnsresolver 10 i32 0 && atest --include-subdirs packages/modules/DnsResolver Test: debugging logs were printed correctly Test: No PII logs are revealed in default log severity Change-Id: Ia298ff3e4ce5c9ff42a1a84cf3e34a7bda818519
* Add netd binder and resolver APIKen Chen2019-04-291-21/+30
| | | | | | | | | | | - Add a path for ConnectivityService to pass log severity to resolver. - Remove persist system property. No more keep logging severity setting after reboot. Bug: 129108902 Test: full build, flash ROM Test: atest resolv_integration_test Change-Id: I66a065dcd034c88ed8e0b5f24f53382d355735bd
* [Resolver-log]: ResolverTest fail when enabling VERBOSE log severity.chenbruce2019-04-221-4/+7
| | | | | | | | | Run resolv_integration_test --gtest_filter=ResolverTest.GetAddrInfo_cnamesIllegalRdata, resolver will stuck becuase the do_section function doesn't handle well. Bug: 130785203 Test: make; flash; enable verbose severity and run tests case. Change-Id: I9ee9ce6f61e791392430a74ecd16f8e44e5bec99
* [Resolver-log]: Some modifications for debug loggingchenbruce2019-04-161-93/+53
| | | | | | | | - Remove stdio.h from all files now that we're no longer using printf() etc - Use std::string to buffer the output and android::base::StringAppendF() to write into it. Test: Test: make; flash; runtests.sh Change-Id: Iea268dbf3e799c04b0812926ca8e381be213c9b4
* Unify log tag of DNS resolverKen Chen2019-04-151-1/+1
| | | | | | | | | Set LOG_TAG to "resolv" on DNS resolver. Then, the log can be filtered by "adb logcat [filterspecs]", such as "adb logcat *:S resolv:*", or 'grep'. Test: resolv_integration_test pass Change-Id: Ic4f97685d487257560ec3dfe62bab0d187bf9d93
* Add an explicit VERBOSE log levelBernie Innocenti2019-04-011-6/+13
| | | | | | | | | | | | | Now it's possible to set the level to VERBOSE and DEBUG independently in debug builds. Setting the level to VERBOSE in a release build is equivalent to setting it to DEBUG. Test: - build, flash - adb shell setprop persist.sys.nw_dns_resolver_log VERBOSE - adb logcat | grep libnetd_resolv Change-Id: Ieafa90fa31e74490203d9d0d8c4f548a68ed3504
* [Resolver-log]: Refactor EDNS OPT log print.chenbruce2019-03-271-2/+3
| | | | | | | | | | | | | | | An OPT RR has a fixed part and a variable set of options expressed as {attribute, value} pairs. In OPTION-DATA print function, we refactor the EDNS print part becuase it could not handle multi-pairs data well. If the dns server sent two pairs, the print funtion will have infinite loops. Bug: 128284562 Test: make; flash; enable resolv log(VERBOSE); Test: set private DNS to strict mode Test: server = 1dot1dot1dot1.cloudflare-dns.com Test: access www.hp.com to make sure issue doesn't happen. Change-Id: I5ff30c933728f1a4034faeca42fce97a22551ea8
* Disable sensitive logsKen Chen2019-03-211-11/+11
| | | | | | | | | | | | | | | | | - PII logs can only appear in VERBOSE level - logSeverityStrToEnum() no more support VERBOSE level input, only accept DEBUG, INFO, WARNING, and ERROR. - developer can set DBG flag from code to have a debug build, the DEBUG level is automatically promote to VERBOSE. - uniform log format to [FILE NAME]: [FUNC NAME]: [MSG] - move from ALOG to LOG on DnsProxyListener - adjust severity for some logs - correct print format on uint8_t type Bug: 128736560 Test: builds, boots Test: atest resolv_integration_test Change-Id: I0ff03824901168165bbe1f5abae9ff3e74db63d6
* [Resolver] Remove statp->pfcode, which was only used by digchenbruce2019-03-111-34/+23
| | | | | | | statp->pfcode is set to 0 by default and is used by dig. Remove it. Test: full build, flash ROM, runtests.sh Change-Id: Id63c5fcc5c64bc92bd190d0c628e8e12eecb9d6f
* resolv: small improvements for debug loggingBernie Innocenti2019-03-081-52/+8
| | | | | | | | | | | | | | | | | | | - use __func__ instead of the hand-written and often incorrect names - fix a few cosmetic issues, such as those ugly ";;" prefixes - add some logging around explore_fqdn and explore_numeric - change the verbosity of a few messages - replace compile-time DBG macro with verbosity checks in DnsProxyListener - delete various unused functions in res_debug - skip slow res_pquery() if log level is less than VERBOSE TODO: convert the remaining ALOGx() lines to LOG(x). Leaving this for a future patch. Test: as follows: adb shell setprop persist.sys.nw_dns_resolver_log DEBUG atest reolv_integration_test Change-Id: I7153f0c75d39d513fa006e0c1e5bf649d47ba154
* [Resolver-log] Replacing unused debuging functions by LOG(x).chenbruce2019-02-271-52/+111
| | | | | | | | | | | | | Removing printf/vlog/syslog/ ...etc debuging functions and using LOG(x). Then we can configure the log verbosity in the resolver with: // Set the minimum severity level for logging, returning the old severity. LogSeverity SetMinimumLogSeverity(LogSeverity new_severity); Bug: 121176138 Test: make; flash; Test: The default severity is WARNING. Reboot device and check that only WARNING/ERROR logs are printed. Change-Id: Ib8de89a4cba96ded186579ccefaf88031066e508
* Expose DNS timeout error to netdMike Yu2018-11-141-2/+0
| | | | | | | | | | | | | | | | | | | | For resolver stats, RCODE_TIMEOUT has been used for catching DNS timeout error. This change adds the Support for reporting NETD_RESOLV_TIMEOUT to frameworks. Also clean up res_data.cpp as these functions are not used. - res_init - res_mkquery - res_query - res_send - res_search Bug: 113916551 Test: as follows - built and flash netd - system/netd/tests/runtests.sh passed - silently drop packets by iptables, the return error is correct Change-Id: I62ba6759b519d42aef62ae5b756a3c1ae3cb00d8
* Move resolver public headers to separate include pathBernie Innocenti2018-10-181-34/+40
| | | | | | | | | | Additionally rename functions and structs to eliminate those ugly underscores from the public API (with the notable exception of __res_params, which will come in its own separate change to keep this one from growing too large). Test: build, flash, then 'atest netd_integration_test' Change-Id: I7e9b0ee6cdbec889e9c35b5a17b5daa65533686e
* Dead code removal in res_debug.cppBernie Innocenti2018-10-031-426/+0
| | | | Change-Id: I863f0e050a9e309c08cdd623fa306e512332a22e
* resolv: dead code removalBernie Innocenti2018-10-031-62/+0
| | | | | | | | | | | | | | | | - hostalias() and res_hostalias(): these were no-ops - res_opt(), res_querydomain(), p_option(), p_query(), res_isourserver(), res_nisourserver(): had no callers - res_ourserver_p(): made local to res_data.cpp - res_send_setqhook(): unused, DnsProxyListener sets the qhook directly in android_net_context, which is then copied to res_state by res_setnetcontext(). We can further simplify it later on. Test: atest netd_integration_test Change-Id: I70f72202e5b940986cac67dc99ab9461af882187
* Dead code removal in res_debug.cppBernie Innocenti2018-09-111-81/+1
| | | | | Test: m libnetd_resolv Change-Id: Ie33d48ad4d2c4b99aa17f9e81a9045ac5b9fc73d
* Minimal changes to bring the resolver into the C++ eraBernie Innocenti2018-09-111-0/+1082
It took surprisingly few changes, considering the leap from C with some K&R constructs to C++17; most of the diffs are adding explicit pointer casts and renaming variables called 'class' or 'try'. As a result of building as C++, some of the names are now mangled, making clashes with bionic harder. However, some names remain C due to the __BEGIN_DECLS / __END_DECLS macros, scheduled to be removed in a later cleanup pass. Test: atest netd_integration_test Change-Id: I3aefb9078421ec42f98f97d917785b365545feba