aboutsummaryrefslogtreecommitdiff
path: root/res_mkquery.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Accommodate a change in the type of std::span's sizeRyan Prichard2023-09-211-1/+1
| | | | | | | | | | | The WIP version of std::span in external/libcxx uses a ptrdiff_t size, but the final standardized version of std::span uses size_t instead. Use std::span() constructor calls rather than {}-syntax, which will convert the signed length to unsigned and works with either the old or the new libc++. Test: treehugger Change-Id: I5b5a16d0949e77a74269b9f6cf24382dd69a5973
* Enable some DNS logs in userdebug buildKen Chen2022-05-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Set DNS default logging level to INFO. 2. Adjust logging level on some traces. Output: [Success] resolv : GetAddrInfoHandler::run: {100 983140 100 983140 1021 0} resolv : res_nmkquery: (QUERY, IN, A) resolv : res_nsend: used send_dg 97 terrno: 0 resolv : doQuery: rcode=0, ancount=4 [Cache hit] resolv : GetAddrInfoHandler::run: {100 786532 100 983140 0 0} resolv : res_nmkquery: (QUERY, IN, AAAA) resolv : resolv_cache_lookup: FOUND IN CACHE entry=0xb4000075f51973d0 resolv : doQuery: rcode=0, ancount=1 [Error - NXDOMAIN] resolv : GetAddrInfoHandler::run: {100 786532 100 983140 0 0} resolv : res_nmkquery: (QUERY, IN, AAAA) resolv : res_nsend: used send_dg 104 terrno: 0 resolv : doQuery: rcode=3, ancount=0 [Timeout] resolv : GetAddrInfoHandler::run: {30 983070 30 983070 0 0} resolv : res_nmkquery: (QUERY, IN, A) resolv : res_nsend: used send_dg 0 terrno: 110 resolv : res_nsend: used send_dg 0 terrno: 110 resolv : doQuery: rcode=255, ancount=0 ... Bug: N/A Test: m; adb logcat Change-Id: I2a0ea2b416264d59382ef121d6d7755f8c7ffdf7
* Replace manual buffer handling with std::spanchenbruce2021-08-311-31/+27
| | | | | | Bug: 196298216 Test: cd packages/modules/DnsResolver && atest Change-Id: I8b0b8b0cc0c1185eb9a9e99ed10a2fc109bfa1d7
* Remove the obsolete res_state typedefBernie Innocenti2021-07-011-2/+2
| | | | Change-Id: Ia6b623628e8b2a5799246280198e20c950c30093
* Delete dead code in res_comp.cpp and misc cleanupsBernie Innocenti2020-01-241-1/+4
| | | | | | | | | | | | | | No functionality changes, this is mostly meant to improve our code coverage and cleanup our headers a bit. - delete dead functions res_ownok() and res_mailok() - Move prototypes of the remaining functions to the new header res_comp.h - Replace resolv_private.h with res_comp.h as needed - Drop the dependency on Bionic's <resolv.h> wherever possible - Eliminate the horrible maybe_XXX() macros - Make res_hnok() and res_dnok() return a proper bool instead of 0 and 1 Change-Id: Ic2e27753355d873925044a7561ccb78bd2c2d162
* Explicitly allocate ResState on the call stackBernie Innocenti2019-10-171-14/+10
| | | | | | | | | | | | | | | | | | | | | Previously known as __res_state, res_state, res or even statp, the ResState struct holds the context of a query in progress. After a long series of preparatory patches, the thread-local storage nonsense that's been plaguing this fine codebase for decades is finally gone. Sayonara! ResState is now explicitly allocated on the stack at the beginning of each query and passed down as a regular function argument. To keep this patch reviewable, I threw in two compatibility typedefs for the legacy names. We'll get rid of them in a separate mechanical patch. Next steps: - Give ResState a regular constructor and, crucially, a real destructor - Move the definition to ResState.h, like it's a real class - Populate the nameservers immediately on construction - Switch to safe C++ data structures Change-Id: I5c0b85da3ad9a55fa41dca6c87e57fe8f50c6abc
* Resolv: Replace BSD types with regular C99 typeschenbruce2019-09-181-14/+13
| | | | | | | | | Replace BSD types (u_long, u_int, u_char) with regular C99 types Bug: 140910031 Test: built, flashed, booted Test: atest Change-Id: I88829906f8e5be89ef3d5b222ebd4e4091a41b57
* Dead code removal - remove res->optionschenbruce2019-07-241-2/+2
| | | | | | | Bug: 135660701 Test: built, flashed, booted Test: atest Change-Id: Ic604d18e635a9cb373b9e258f4524a20fb1e393f
* Dead code removal - Remove res_setoptions()chenbruce2019-06-181-1/+1
| | | | | | | | | | - It’s been dead code for a long time, and adds lots of complexity - Keep options used by DoT Bug: 135094436 Test: built, flashed, booted Test: atest Change-Id: Id34c6850f07733219b576d1ee2cf1dd3b7c52fc1
* [Resolver-log]: Some modifications for debug loggingchenbruce2019-04-161-1/+0
| | | | | | | | - 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
* Modify trivial inline functions.chenbruce2019-04-011-16/+16
| | | | | | | | | | | | Replace ns_put16(), ns_put32(), ns_get16(), ns_get32 functions by htons(), htonl(), ntohs(), ntohl() Bug: 129515023 Test: built, flashed, booted Test: system/netd/tests/runtests.sh pass atest CtsNativeNetDnsTestCases atest DnsResolverTest Change-Id: I08d127627456139832c14ebf2fc48a918d8e2ddf
* Disable sensitive logsKen Chen2019-03-211-2/+2
| | | | | | | | | | | | | | | | | - 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
* resolv: small improvements for debug loggingBernie Innocenti2019-03-081-3/+5
| | | | | | | | | | | | | | | | | | | - 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-16/+7
| | | | | | | | | | | | | 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
* Replace res_randomid with arc4random_uniformLuke Huang2019-02-151-1/+1
| | | | | | | Test: built, flashed, booted system/netd/tests/runtests.sh pass Change-Id: Ie1f007f581c7e8becb429c0d27fd1c1b3a3f285e
* Expose DNS timeout error to netdMike Yu2018-11-141-2/+6
| | | | | | | | | | | | | | | | | | | | 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 a few internal constants out of resolv_params.hBernie Innocenti2018-10-171-31/+25
| | | | | | | | | | | | | | | | | This is a preliminary step to cleanly separate the public headers from the internal ones. No funtionality changes. In the process, I also un-ifdefd RES_USE_EDNS0 and EDNS0_PADDING, since they were always defined. For now I'm leaving alone these #ifdefs, which need some more thought: - HAVE_SIN6_SCOPE_ID: currently disabled, but <linux/in6.h> has it - HAS_INET6_STRUCTS: currently disabled, will need test coverage? - CANNOT_CONNECT_DGRAM: currently disabled Test: build, flash, then 'atest netd_integration_test' Change-Id: I4cee37d484a5183a2db082d502b2badcaa83e7e4
* Fix -Wimplicit-fallthrough warnings in netdBernie Innocenti2018-10-121-1/+2
| | | | | Test: atest netd_integration_test Change-Id: Ib5ab9661fb429fdccd6a4c4b5893831ff5fe104e
* Limit C linkage to public symbolsBernie Innocenti2018-10-031-12/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Switched all internal functions to C++ linkage. This makes it harder to accidentally call a function with a mismatched signature, and paves the way to using C++ data structures internally. This is the current list of symbols expoted by libnetd_resolv.so: _resolv_delete_cache_for_net _resolv_flush_cache_for_net _resolv_set_nameservers_for_net android_getaddrinfofornet android_getaddrinfofornetcontext android_gethostbyaddrfornet android_gethostbyaddrfornetcontext android_gethostbynamefornet android_gethostbynamefornetcontext android_net_res_stats_aggregate android_net_res_stats_get_info_for_net android_net_res_stats_get_usable_servers A mass-renaming pass would improve consistency. Perhaps we could use the prefix "netd_resolv_", or just "resolv_" for brevity. Once we begin shipping netd binaries using this interface, we might have to live with it for some time. Test: atest netd_integration_test (after flashing with new netd binary) Change-Id: I52f32add73fd908ad4a715ef8f8aff1f8d9733d0
* Minimal changes to bring the resolver into the C++ eraBernie Innocenti2018-09-111-0/+262
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