Commit graph android_packages_modules_Co.../Android.bp
Message SHA1
clatd: remove ipv6 address monitoring
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 Żenczykowski   commited 2023-03-16 09:36:10 +00:00
ca9466c768
Suppress tidy checks that block migration to gnu11
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 Hsieh   authored and   Chih-hung Hsieh   commited 2022-04-04 12:03:23 +00:00
3abac000c0
Merge "[RFCLAT#16] remove drop_root_and_caps"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-01-19 13:09:39 +00:00
95cbf3217f
Move vendor-464xlat.rc from external to netd
Since clatd is modularized and shipped in apex,
migrate the clat vendor property to netd.

Bug: 182333299
Bug: 212345928
Test: manual
Change-Id: I73b06547d8443abc749a4ccfe5c7b16b1ed32586

Hungming Chen   commited 2022-01-16 17:49:01 +08:00
07461b9532
[RFCLAT#16] remove drop_root_and_caps
gid and uid of clatd binary has been set by apex
canned_fs_config. don't need drop_root_and_caps()
anymore.

Bug: 212345928
Test: manual test
1. Connect to ipv6-only wifi.
2. Make IPv4 traffic.
   $ ping 8.8.8.8

Check uid and uid is AID_CLAT(1029) in process status:
$ adb shell ps | grep clat
clat          9743   740 10826108  2264 0              0 S clatd-wlan0
$ adb shell cat /proc/9743/status | egrep -i '^(Uid|Gid|Groups):|^Cap'
Uid:	0	1029	1029	1029
Gid:	0	1029	1029	1029
Groups:	3005
CapInh:	00000000000074ef
CapPrm:	00000000000074ef
CapEff:	0000000000000000
CapBnd:	00000000000074ef
CapAmb:	0000000000000000

Change-Id: I8f7a9c50368d5c789621ea39b39d9242adfb0fcc

Hungming Chen   commited 2022-01-14 18:32:06 +08:00
f752bb4bb7
Set relative_install_path to "for-system"
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

Hungming Chen   commited 2022-01-11 17:04:40 +08:00
ef9f62b076
[RFCLAT#15] Static link libc++
Static link libc++ can save the apex size 700KiB+ (libc++.so).

before:
$ deapexer extract out/target/product/raven/system/apex/com.google.android.tethering.apex apex_default
$ 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

after:
$ deapexer extract out/target/product/raven/system/apex/com.google.android.tethering.apex apex_stl_static
$ ls -all out/target/product/raven/system/apex/com.google.android.tethering.apex
-rw-r--r-- 1 nuccachen primarygroup 2998272 Jan  6 22:50 out/target/product/raven/system/apex/com.google.android.tethering.apex

libc++.so is removed from the apex which uses clatd with static link
libc++:
$ diff -r apex_default/ apex_stl_static/
Only in apex_default/lib64: libc++.so

$ ls -all apex_default/lib64/libc++.so
-rw-r--r-- 1 nuccachen primarygroup 716664 Jan  1  1970 libc++.so

Bug: 212345928
Bug: 213123047
Test: atest clatd_test
Change-Id: I7f71eac09e659355781ecd275fcc70bef262f3d0

Hungming Chen   authored and   Nucca Chen   commited 2022-01-07 11:12:44 +00:00
03486e0f35
[RFCLAT#14] replace "libcutils" with "libcutils_headers"
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 Chen   authored and   Nucca Chen   commited 2022-01-05 13:32:49 +00:00
98e86faad9
[RFCLAT#12] Add apex_available and min_sdk_version to clatd
Used to package clatd binary into tethering apex.

Bug: 212345928
Test: atest clatd_test
Change-Id: I94f7272e088e8b16fa906585a8dfe430c6ba4631

Hungming Chen   commited 2021-12-30 22:55:49 +08:00
0712561538
[RFCLAT#11] remove libnetd_client_headers and netid_client.h
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

Hungming Chen   commited 2021-12-30 22:55:41 +08:00
935a5ee67c
[RFCLAT#10] remove libnl related files
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

Hungming Chen   commited 2021-12-30 22:55:34 +08:00
396b5e7b92
Clatd changes for move of libipchecksum.
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 Colitti   authored and   Maciej Żenczykowski   commited 2021-12-14 03:19:12 +00:00
0cd5aa5403
Depend on libipchecksum, not libnetutils.
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 Colitti   commited 2021-12-09 17:42:28 +09:00
a4e9681c88
switch from using packet ring to normal read
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 Żenczykowski   commited 2021-11-09 19:32:33 +00:00
50303534ce
Enable Async MTE in android-clat.
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

Evgenii Stepanov   commited 2021-05-21 16:34:01 -07:00
afe05e1fdf
Merge "Copy the 464xlat vendor property to an AOSP property."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-03-10 16:53:41 +00:00
1934063f20
Copy the 464xlat vendor property to an AOSP property.
Test: manual
Bug: 182333299
Change-Id: I88d570911d4afd0c4123ca7f50c6e7cf3b40b42b

Lorenzo Colitti   commited 2021-03-10 14:58:05 +09:00
929287213d
[LSC] Add LOCAL_LICENSE_KINDS to external/android-clat
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

Bob Badour   commited 2021-02-12 14:17:41 -08:00
370808d269
cleanup - remove config.c
Test:
  git grep 'config[.]c'
  comes up empty

Bug: 144730808
Test: atest clatd_test netd_integration_test
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8500881852f1255a69b49eba6354777883fe438f

Maciej Żenczykowski   commited 2020-06-02 15:57:08 -07:00
5ce6cdae6d
cleanup - remove clatd.conf
Test:
  git grep clatd.conf
  comes up empty

(this needs changes in other projects though)

Bug: 144730808
Test: atest clatd_test netd_integration_test
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0d8a24f80c07ca95eb0aae4f4f67ac291ac78c1f

Maciej Żenczykowski   commited 2020-06-02 15:56:33 -07:00
069b0c7427
Remove DNS64 detection code from clatd.
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 Colitti   authored and   Maciej Żenczykowski   commited 2020-06-01 06:46:24 +00:00
27da0ad045
Use dnsproxyd_protocol_headers instead of libnetd_client_headers for NETID_USE_LOCAL_NAMESERVERS
NETID_USE_LOCAL_NAMESERVERS is no longer in libnetd_client_headers

Bug: 151895202
Test: build
Change-Id: I064f60fa4edf5a1b2ad7f8a127ab531f0ab0c52c
Merged-In: I064f60fa4edf5a1b2ad7f8a127ab531f0ab0c52c

Luke Huang   authored and   Maciej Żenczykowski   commited 2020-05-30 19:05:11 -07:00
c12af098cd
Derive mtu from ipv6 route to ipv4 /96 prefix instead of device
Test: builds, atest, still needs testing on real network
  x86 clatd_test
  --------------
  clatd_test (19 Tests)
  ...
  [6/19] ClatdTest#DetectMtu: PASSED (0ms)
  ...
Bug: 147935930
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3d11ba082dabf70089867146acd84f6436953663

Maciej Żenczykowski   commited 2020-01-20 20:36:43 -08:00
b00113f49a
remove clatd_microbenchmark.c
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 Żenczykowski   commited 2019-11-26 22:59:18 -08:00
badfbedcad
clatd_test - add 'require_root: true'
Bug: 141272654
Bug: 141307514
Test: now passes
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5598b3f5acdbd098043c6f9513995f288ae4c142

Maciej Żenczykowski   commited 2019-09-19 14:41:47 -07:00
76f4b74309
clatd: change to pass in tun filedescriptor via command line
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 Żenczykowski   commited 2019-05-08 00:52:22 -07:00
716518d9b9
Enable clang-tidy for clatd.
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 Colitti   commited 2019-04-10 23:50:39 +09:00
6a095dfa6b
Move checksum code from clatd to libnetutils.
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 Colitti   commited 2019-01-20 12:08:33 +09:00
98de5958cf
Add clatd_test to presubmit.
Following the instructions at:
https://source.android.com/compatibility/tests/development/test-mapping

Test: cd external/android-clat; atest
Change-Id: Ifca302f53b38d47200d6a1651280391297f14edc

Lorenzo Colitti   commited 2019-01-06 11:22:16 +09:00
3335193003
Move main() out of clatd.c.
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 Colitti   commited 2019-01-04 19:08:45 +09:00
eb92f48b1d
Convert to Android.bp
See build/soong/README.md for more information.

Test: cd external/android-clat; mma
Test: atest clatd_test
Change-Id: Ib9691dd8f3ee899743751e72ea35ef106b03de92

Dan Willemsen   commited 2018-11-16 12:52:08 -08:00
1e562182f9