DNS64: sort both synthesized IPv6 address and queried IPv4 address
Sort both synthesized AAAA records and queried A records if any
while getaddrinfo is called.
Bug: 159305929
Test: unit test
$ atest resolv_integration_test
doesn't test changing IPv4/IPv6 address sorting order in
integration test because test network is fake. use manual test for
testing sorting order.
Test: manual test:
query a domain name which has A record only
- Prepartion:
i. reboot
ii. connect to IPv6 only network (GoogleGuest)
iii. block ipv4.google.com AAAA dns query
$ adb shell "ip6tables -A OUTPUT -p udp --dport 53 -m string --algo bm --hex-string \"|04 69 70 76 34 06 67 6f 6f 67 6c 65 03 63 6f 6d 00 00 1c 00 01|\" -j DROP"
iv. build and push dnschk to device
$ make -j4 dnschk
$ adb push out/target/product/raven/system/bin/dnschk /data
$ adb shell chmod 755 /data/dnschk
- Test:
case A: default: IPv6 -> IPv4 (as expected)
$ adb shell /data/dnschk ipv4.google.com
# ipv4.google.com (via nethandle 0):
64:ff9b::8efb:2aee
142.251.42.238
case B: make only IPv4 address reachable
@@ -1372,7 +1372,7 @@ void resolv_rfc6724_sort(struct addrinfo* list_sentinel, unsigned mark, uid_t ui
..
- has_src_addr = _find_src_addr(cur->ai_addr, &elems[i].src_addr.sa, mark, uid);
+ has_src_addr = (cur->ai_addr->sa_family == AF_INET);
- B.1: dnschk - result order: IPv4 -> IPv6 (as expected)
$ adb shell /data/dnschk ipv4.google.com
# ipv4.google.com (via nethandle 0):
142.251.42.238
64:ff9b::8efb:2aee
- B.2: unit test is broken by reversed order (as expected)
$ atest resolv_integration_test
[67/155] ResolverTest#GetAddrInfo_Dns64Synthesize: FAILED (89ms)
STACKTRACE:
packages/modules/DnsResolver/tests/resolv_integration_test.cpp:3093: Failure
Value of: ToStrings(result)
Expected: has 2 elements where
element #0 is equal to "64:ff9b::102:304",
element #1 is equal to "1.2.3.4"
Actual: { "1.2.3.4", "64:ff9b::102:304" }, whose element #0 doesn't match
Change-Id: Ic7b8ea72aee285174cfe6533dab13157e7f3752f
Loading
Please register or sign in to comment