This code/logic is spurious, because the majority of packets
are translated by eBPF, so whether the daemon runs or not,
usually just doesn't matter - bpf will handle them anyway.
As such what we actually care about is that the daemon
is terminated at the same time as the bpf map configuration
is removed. This is done by jni native code stopClatdProcess()
which is called from ClatCoordinator java code immediately
after maybeStopBpf().
Additionally on ipv6 address change we don't even terminate
the daemon - we simply stop the event loop, but still block
in main() until we receive SIGTERM/SIGKILL.
(This was done a while ago to fix a bunch of issues with
daemon dieing and being killed racing with each other)
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I86d203a244838166ed1fbec1bc48a680e433f9fa
Maciej Żenczykowskicommited 2023-03-16 09:36:10 +00:00
The clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling
check gave more warnings in gnu11 mode and they are not suitable
for Android. This check is disabled in AOSP global default, and
local projects should not enable it or should change source code
to avoid those warnings.
Use tidy_checks_as_errors instead of tidy_flags to specify
the checks to be treated as errors.
Bug: 227361697
Test: make with global default set to gnu11
Change-Id: I09f7aa562ab51d3f536cd48184d430212d67b51b
Chih-Hung Hsiehauthored and Chih-hung Hsiehcommited 2022-04-04 12:03:23 +00:00
Since clatd is modularized and shipped in apex,
migrate the clat vendor property to netd.
Bug: 182333299
Bug: 212345928
Test: manual
Change-Id: I73b06547d8443abc749a4ccfe5c7b16b1ed32586
Used for allocating clatd under $(apex_path)\bin\for-system\clatd
Bug: 212345928
Test: manual test
1. Connect to ipv6-only wifi.
2. Try IPv4 traffic.
$ ping 8.8.8.8
Change-Id: Ibfb83db738a67d266856966042486edc57473649
replacing "libcutils" with "libcutils_headers" can save the apex size
~356KiB (libbase.so + libcutils.so). clatd only needs the definition
AID_CLAT in the libcutils exported headers. It would be more
appropriate for using libcutils_headers.
before:
$ deapexer extract out/target/product/raven/system/apex/com.google.android.tethering.apex apex_with_clat_uses_libcutils
$ ls -all out/target/product/raven/system/apex/com.google.android.tethering.apex
-rw-r--r-- 1 nuccachen primarygroup 4083712 Jan 3 21:51 out/target/product/raven/system/apex/com.google.android.tethering.apex
after:
$ deapexer extract out/target/product/raven/system/apex/com.google.android.tethering.apex apex_with_clat_uses_libcutils_headers
$ ls -all out/target/product/raven/system/apex/com.google.android.tethering.apex
-rw-r--r-- 1 nuccachen primarygroup 3719168 Jan 5 18:40 out/target/product/raven/system/apex/com.google.android.tethering.apex
Both libbase.so and libcutils.so are removed from the apex
which is using clatd with libcutils_headers:
$ diff -r apex_with_clat_uses_libcutils apex_with_clat_uses_libcutils_headers
Only in apex_with_clat_uses_libcutils/lib64: libbase.so (263.4 kB)
Only in apex_with_clat_uses_libcutils/lib64: libcutils.so (91.0 kB)
Bug: 212345928
Test: atest clatd_test
Change-Id: Ia286c1d50be758685e92a6e86faa57b675e9cc54
Hungming Chenauthored and Nucca Chencommited 2022-01-05 13:32:49 +00:00
Removed for reducing the libaray dependency.
MARK_UNSET is going to be removed because the mark doesn't need to be an
argument of cli now. libnetd_client_headers is not required as well.
Bug: 212345928
Test: atest clatd_test
Change-Id: Ia81287dcfa2a48a89187b21d4bc721570c0d1e0f
libnl is not required anymore. remove all related files.
Bug: 212345928
Test: atest clatd_test and manual test
1. Connect to ipv6-only wifi.
2. Try IPv4 traffic.
$ ping 8.8.8.8
Change-Id: Ic4725ef01667576f2a958f38d458374c2e749569
libipchecksum is becoming its own library in
frameworks/libs/net and its include files are no longer under
netutils/. Adjust clatd code accordingly.
Also reorder some include files as suggested by clang-format.
Test: m
Test: atest clatd_test
Test: connects to IPv6-only wifi, testipv4.com shows 10/10
Change-Id: I5e4c73065ce828123aef7e8851227f9bdf444ff9
Lorenzo Colittiauthored and Maciej Żenczykowskicommited 2021-12-14 03:19:12 +00:00
clatd depends on libnetutils but it only actually uses the
IP checksumming functions. Depend on libipchecksum instead.
The unit test still depends on libnetutils because it uses
libnetd_test_tun_interface, which calls into libnetutils.
Test: m
Test: atest clatd_test
Test: builds, boots, connects to IPv6-only wifi
Change-Id: I4f12e09f78a01d6df8b11a0c9e92c25c9d7a1248
Lorenzo Colitticommited 2021-12-09 17:42:28 +09:00
With clat ebpf offload of the receive path on 4.9+ P+ devices
this just doesn't matter any more.
Additionally:
- this is *much* simpler,
- reduces memory consumption,
- eliminates the need for memory locking privs,
- and allows us to increment max supported packet size,
which fixes a long outstanding terrible bug wrt. GRO'ed
packets being oversize and simply dropped.
So, win, win, win.
Test:
git grep '(^|[^t])ring[.][ch]'
git grep 'TP_FRAME_SIZE|TP_BLOCK_SIZE|TP_FRAMES|TP_FRAME_GAP|TP_NUM_BLOCKS|packet_ring|ring_create|ring_read'
come up empty
Verified ipv4 ping works on a flame device on an ipv6 only wireless network.
Bug: 130253220
Test: atest clatd_test netd_integration_test
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I676dfd16ffd2961f14a4e8fcd707c6f9f484e024
Maciej Żenczykowskicommited 2021-11-09 19:32:33 +00:00
This change enables Async mode ARM MTE in clatd on compatible
hardware and has no effect otherwise.
Bug: 181603044
Test: atest under external/android-clat
Change-Id: Ib3c23381e2c7ef84499b26672347468b30c6209a
Added SPDX-license-identifier-Apache-2.0 to:
Android.bp
Bug: 68860345
Bug: 151177513
Bug: 151953481
Test: m all
Exempt-From-Owner-Approval: janitorial work
Change-Id: Ib768b2a4d3461e352c0f8577a0d7cb43eb5e3d89
This has been unused since Q, when the NAT64 prefix started being
detected and passed in by netd instead. Many things depend on the
prefix being correct, including clat BPF offload and DNS64
synthesis, and doing DNS64 detection in clatd provides no way to
make these work. Additionally, R now supports getting the NAT64
prefix via the RA, which makes DNS64 detection in clatd even less
useful.
This CL removes all the DNS64 detection code. The new code parses
the prefix in main.c, and if the prefix is not valid, refuses to
start.
This also lets us remove the -n <netid> parameter which was only
used for DNS64 detection.
It also removes a dependency on dnsproxyd_protocol_headers, which
should be depended on by as few parts of the system as possible.
Test: m
Bug: 144730808
Bug: 151895202
Test: IPv6-only wifi continues to work
Change-Id: I892f364d6cbfe76277686387e35c04d3d6eb5ecc
Lorenzo Colittiauthored and Maciej Żenczykowskicommited 2020-06-01 06:46:24 +00:00
NETID_USE_LOCAL_NAMESERVERS is no longer in libnetd_client_headers
Bug: 151895202
Test: build
Change-Id: I064f60fa4edf5a1b2ad7f8a127ab531f0ab0c52c
Merged-In: I064f60fa4edf5a1b2ad7f8a127ab531f0ab0c52c
Luke Huangauthored and Maciej Żenczykowskicommited 2020-05-30 19:05:11 -07:00
In the era of ebpf offload the speed of writing packets via
tun and reading via udp socket aren't all that important.
Test: builds
Bug: 144730808
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie2b49c8b109052b9212d3b21fd16784a464e2a1b
Maciej Żenczykowskicommited 2019-11-26 22:59:18 -08:00
Test: atest clatd_test, built and installed on aosp_blueline device
connected to ipv6-only wifi network: ping 8.8.8.8 still works
and it is via v4-wlan0 clat tun interface
Bug: 65674744
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8c9e235e9a5bf1a1436e8dc3af8d0aa86f6dc1a5
Maciej Żenczykowskicommited 2019-05-08 00:52:22 -07:00
Enable the same warnings used elsewhere in the tree, and fix two
warnings it found (a safe use of strcpy, and a missing O_CLOEXEC
when opening the tun device node.
Test: builds, boots, clatd works
Test: m clatd clatd_test clatd_microbenchmark && atest clatd_test
Change-Id: I9a5ea4de5f31d3c495871250a6493b07535a604b
Lorenzo Colitticommited 2019-04-10 23:50:39 +09:00
This allows us to use it elsewhere, for example, in netd.
Bug: 65674744
Test: builds, boots
Test: atest clatd_test clatd_microbenchmark
Change-Id: Ic2cea1cd658ffd23ba9fbe45cb6b28e3b5312005
Lorenzo Colitticommited 2019-01-20 12:08:33 +09:00
This allows us to unit test methods that are in clatd.c.
Also simplify the build file, adding a defaults stanza and
grouping files in a filegroup so that both the code and the unit
test have the same source files.
Test: atest clatd_test
Test: builds, boots, 464xlat works
Change-Id: I544c3ee846abd3e38b80a2d9a4db5497fd9beb0c
Lorenzo Colitticommited 2019-01-04 19:08:45 +09:00
See build/soong/README.md for more information.
Test: cd external/android-clat; mma
Test: atest clatd_test
Change-Id: Ib9691dd8f3ee899743751e72ea35ef106b03de92