Commit graph android_packages_modules_Co.../service/native/libs/libclat/clatutils_test.cpp
Message SHA1
Remove service/native/include/Common.h
Move the remaining contents of Common.h to clatutils_test.cpp and remove
Common.h

Bug: 217624062
Test: TH
Change-Id: Ie0615b42a3a1bf4c07e9196128fe0850a448fb35

Motomu Utsumi   commited 2023-11-08 16:58:59 +09:00
3b477129dd
clat: use AF_PACKET/SOCK_RAW not SOCK_DGRAM sockets
This switches incoming packets from L3 to L2,
ie. they now include the ethernet header for non-rawip cases
(like wifi)

Note: depends on userspace clatd change to offset packet
processing index by tpacket_auxdata->tp_net L3 header offset,
an increase in the read buffer size,  and on change to use
IPv6 header relative cBPF for ingress packet filtering!

Test: TreeHugger, atest libclat_test, ping 1.1.1.1 on v6-only wifi
Bug: 265591307
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie5893d18b0dd796751f95150680a0d4cd5f64c3c

Maciej Żenczykowski   commited 2023-03-14 00:50:18 +00:00
2460294974
Bypass VPN lockdown for clat initialization
This allows clat to initialize properly when VPNs are configured
with "Block connections without VPN", rather than to error out with
"no IPv6 addresses were available for clat".

This issue primarily affects particular mobile networks configured
with NAT64 (without direct IPv4 connectivity).

Bug: 255040839
Change-Id: I4a8ee0295e0f5d1e330f7529856347b8bd10360c

t-m-w   authored and   Maciej Żenczykowski   commited 2022-10-25 01:54:51 +00:00
130e75b0ab
ClatUtils: add test GenerateIpv6AddressFailWithUlaSocketAddress
Used for increasing the test coverage of generateIpv6Address.

For now, generateIpv6Address test coverage: 0% (0/27 lines)
https://blackbox.googleplex.com/testsuite?branch=git_tm-mainline-prod-daily-release&target=mainline_modules_x86_coverage_r_released&testsuite=coverage%2Fmts_tethering_native_t_on_t&type=coverage

This is not a realistic test. The generateIpv6Address functionality is
not real verified. See also test MakeChecksumNeutral.

TODO: remove this test once EthernetTetheringTest can
test on mainline test coverage branch.

Test: atest ClatUtils

Change-Id: I8e4fbc5af2cd0dd0a1bb181388ea0d4b200baed3

Hungming Chen   commited 2022-06-05 22:37:57 +08:00
2477caa08b
[CLATJ#6] libclat: move configure_packet_socket() from netd to apex
configure_packet_socket() is moved from ClatdController. Only change
the failure return value from errno to -errno. The remaining parts
are the same.

The test is modified from ClatdControllerTest::ConfigureIpv6Address.
Simply set socket filter to an interface and check that the packet
socket is bound to the interface. We can't check the socket filter
because there is no way to fetch it from the kernel.

Bug: 212345928
Test: build and boot
      atest libclat_test
Change-Id: Ia33c21051b040829c7d2aa55ed5b7de8766c98c5

Hungming Chen   commited 2022-01-20 22:50:12 +08:00
8ff032b990
[CLATJ#5] libclat: move detect_mtu() from netd to apex
detect_mtu() is moved from ClatdController without behavior
change. The unique_fd for socket fd is replaced by primitive int
because libbase is not supported in mainline.

Bug: 212345928
Test: build and boot
      atest libclat_test
Change-Id: Ib9c1a9d4b9e1c141d88164e8489c5044fdf70685

Hungming Chen   commited 2022-01-20 22:50:12 +08:00
86a56de609
[CLATJ#4] libclat: move selectIpv4Address() and isIpv4AddressFree() from netd to apex
isIpv4AddressFree() is moved from ClatdController without behavior
change.

selectIpv4Address() and its test are moved from ClatdController as well.
They have been refactored slightly for testing because function pointer
of isIpv4AddressFreeFunc is not a global variable anymore. We can't set
global function pointer to change selectIpv4Address() behavior for
testing. Instead isIpv4AddressFree is sent as an argument of function
pointer. For public caller, selectIpv4Address() has no behavior change.
For test caller, they can call an internal selectIpv4AddressInternal
(.., fn) to change isIpv4AddrFreeFn function pointer for testing.

Bug: 212345928
Test: build and boot
      atest libclat_test
Change-Id: Iab5e6fd5ebbccf10e7b3be2251b45949cf3f3464

Hungming Chen   commited 2022-01-20 22:50:12 +08:00
2f623f381c
[CLATJ#1] libclat: move makeChecksumNeutral() from netd to apex
Introduce the library libclat to implement clat functions for jni.
It is helpful for unit test.

makeChecksumNeutral() and its test are moved from ClatdController
without behavior change.

Bug: 212345928
Test: build and boot
      atest libclat_test

Change-Id: I1c0981d98141fc1cc07b2d3a0f3cbddf38683ff3

Hungming Chen   commited 2022-01-20 22:50:08 +08:00
ed7b4602b5