| Commit message (Collapse) | Author | Age | Files | Lines |
| |\
| |
| |
| |
| |
| | |
https://android.googlesource.com/platform/packages/modules/DnsResolver into u14.0
Android 14.0.0 Release 50 (AP2A.240605.024)
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
"num >= MAXADDRS" can never happen in the for-loop.
Test: 1. Modify system/etc/hosts to have over than MAXADDRS records, like
10.0.0.1 www.test.com
10.0.0.2 www.test.com
...
10.0.0.36 www.test.com
2. Trigger gethostbyname by "adb shell ping www.test.com"
3. Observe the result and there is no failure
Change-Id: I4347307be9479214c48492aee180d46e1b97d3f4
|
| | |
| |
| |
| |
| |
| |
| | |
Porting aosp/2856549 from bionic to DNS resolver.
Change-Id: I76999cbc352094055807aa7ded03b0363912c980
Test: presubmit
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The hosts file is normally searched linearly. This is very slow when
the file is large. To mitigate this, read the hosts file and sort the
entries in an in-memory cache. When an address is requested via
gethostbyname or getaddrinfo, binary search the cache.
In case where the cache is not available, return a suitable error code
and fall back to the existing lookup code.
This has been written to behave as much like the existing lookup code as
possible. But note bionic and glibc differ in behavior for some corner
cases. Choose the most standard compliant behavior for these where
possible. Otherwise choose the behavior that seems most reasonable.
Note: this change is the analogue of the bionic change of the same name.
Both should be kept in sync.
u14.0: Replace usage of MIN with std::min
Change-Id: I5926493864d4b1291ae83f8b601bf5dcc54085cd
|
| |/
|
|
| |
Change-Id: I0f5ab2ec4a6f1855abd65f371a8960087db49994
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Aosp/2566619 added Nonnull annotations in strcasecmp, which causes build
break in DNS resolver module and tests.
This commit:
1. Checks if a nullable variable is null before passing it to the
strcasecmp.
2. Adds a hacky way to avoid -Wnullable-to-nonnull-conversion errors.
Bug: 278513807
Test: presubmit
Change-Id: I146f5b91114dd7c934c9e3fb12477e4563005c5f
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Aosp/2522835 adds _Nullable/_Nonnull annotations which causes build
break in DNS resolver module and tests.
This commit tries to:
1. Check if a nullable variable is non-null before passing it to a
function with a non-null parameter annotation. This is necessary
because passing null pointers to memcpy(), strlen(), strdup(), etc is
undefined behavior.
2. Add a hacky way to avoid -Wnullable-to-nonnull-conversion errors.
Compiler is not smart enough to know if a variable is guaranteed
non-null from context.
Bug: 278513807
Test: presubmit
Change-Id: I2bcf887e31a2d9716c1da75431280ec29d4e5c34
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The ancient ALIGN() macros caused clang-tidy to complain:
packages/modules/DnsResolver/gethnamaddr.cpp:367:10: error: integer to
pointer cast pessimizes optimization opportunities
[performance-no-int-to-ptr,-warnings-as-errors]
bp = (char*) ALIGN(bp);
The new inline template align_ptr() sidesteps this issue as recommended
by the clang-tidy documentation:
https://clang.llvm.org/extra/clang-tidy/checks/performance-no-int-to-ptr.html
Furthermore, align_ptr() is used to replace this... surprising
piece of code:
bp += sizeof(align) - (size_t)((uintptr_t)bp % sizeof(align));
See the bug there? When bp is already aligned to a multiple of
sizeof(align), it will overalign! Also, 'align' was a union of a
uint32_t and a char, which is obviously the same alignment of a plain
uint32_t on any architecture ever created!
Bug: 182416023
Change-Id: Id39c3030025e4510feeb55723760a2950067cece
|
| |
|
|
|
|
|
|
| |
res_static was used by the non-reentrant legacy resolver calls to hold
a per-thread buffer for the hostent struct and its associated
8KB buffer, which is now stack allocated by the caller.
Change-Id: I01a2ea4c2e290d8e4f19fc3be3ebf827c8200b0e
|
| |
|
|
|
|
|
|
| |
Also stop including resolv_static.h from resolv_private.h, and
other minor fixes.
Test: m, flash, atest
Change-Id: I2ba6fdf10900ddbd5afed1cec14a91bfad862d43
|
| |
|
|
|
|
|
|
| |
- 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
|
| |
|
|
|
|
|
|
|
|
| |
In order to not rely on errno, remap the existing error code pair of EAI_SYSTEM
and errno to other EAI_* error codes. Unused errno is removed as well.
Test: built, flashed, booted
system/netd/tests/runtests.sh pass
Change-Id: I8a4450df3c27a12db790756ba545787bd0570402
|
| |
|
|
|
|
|
| |
Test: built, flashed, booted
system/netd/tests/runtests.sh pass
Change-Id: I9fd8735b2ea7565342b899715afef13b1c0692f6
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, DNS query returns error code which may consider rcode only. That may
not respond corresponding error what we need. For example, rcode NOERROR
doesn't really mean no error for the whole DNS query progress. DNS server may
respond a DNS packet without any answer for queried address. In this case,
return error code from h_errno NO_DATA rather than rcode NOERROR.
Changes:
1. Expose timeout error to netd.
2. Not only consider rcode for returning DNS query error code.
3. Enable the following test cases.
- ResolverTest.GetHostByName2_Dns64Synthesize
- ResolverTest.GetAddrInfo_Dns64QuerySpecified
- GetAddrInfoForNetContextTest.AlphabeticalHostname_NoData
Test: built, flashed, booted
system/netd/tests/runtests.sh pass
manual test with unmerged commit aosp/861310
Change-Id: I6723d133afbe56728ecaf35245d1037efc8d6da6
|
| |
|
|
|
|
|
|
|
|
| |
Using a thread-local variable to return an int to the caller is a hack and
adds a lot of complexity. Return error code with an int pointer instead.
Test: built, flashed, booted
system/netd/tests/runtests.sh pass
Change-Id: Ie9da1a6b18525967f0e8fe3d54b0df18e37d2b0e
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently function return address space size is reserved by the address
family. When Netd does IPv6 prefix synthesis on an IPv4 resource record,
hostent structure has no enough address space for synthesized IPv6 address.
Reserving enough address space for either IPv4 or IPv6 avoids buffer
overflow while doing address family remapping in Netd.
Be aware of that we don't reserve address space for family remapping in
numeric hostname query which returns a fake address from numeric hostname.
The reason is this case doesn't trigger DNS64 synthesis in Netd.
Bug: 78545619
Test: netd_{unit,integration}_test pass
Change-Id: I506026cfa38c107e06440806a3080dd8d52a3bf2
|
| |
|
|
|
| |
Test: atest netd_integration_test
Change-Id: I41d1de68296e6201e6b0f20d390eaf1d12aa49f9
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
This gets rid of several layers of obfuscation in between nsdispatch()
and the functions which actually lookup for a hostname in the hosts
file and dns.
This opens the way for even more cleanups, which I will leave for
another day; let's first rip off nsdispatch() from everywhere, which
lets us kill another dependency on an internal bionic header.
Test: atest netd_integration_test
Change-Id: I911fb254939ecc9661695d0ca5474c3caeb4c1d9
|
|
|
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
|