Commit Graph

25 Commits

Author SHA1 Message Date
Patrick Rohr
445dede4eb Merge changes I50417e69,I6892d81c,Id8846844,Ib22da8d4,Iad66f0d4
* changes:
  jni - dynamically link C++ - saves 43 kB
  libservice-connectivity - dynamically link c++ - saves 600 kB
  link libbase & libnetdutils dynamically - save ~17.5 kiB
  remove spurious headers
  libclat only depends on libbase_headers not libbase itself
2022-02-03 19:19:11 +00:00
Maciej Żenczykowski
dcae351663 link libbase & libnetdutils dynamically - save ~17.5 kiB
Before:
  $ adbz root && adbz wait-for-device && adbz shell ls -l /apex/com.android.tethering/{bin/for-system,lib,liv64}
  /apex/com.android.tethering/bin/for-system:
= -rwsr-sr-x 1 clat clat 18412 1969-12-31 16:00 clatd

  /apex/com.android.tethering/lib:
= -rw-r--r-- 1 system system  64560 1969-12-31 16:00 libandroid_net_connectivity_com_android_net_module_util_jni.so
= -rw-r--r-- 1 system system 713636 1969-12-31 16:00 libc++.so
= -rw-r--r-- 1 system system  13596 1969-12-31 16:00 libframework-connectivity-jni.so
d -rw-r--r-- 1 system system 212624 1969-12-31 16:00 libnetd_updatable.so
d -rw-r--r-- 1 system system 948044 1969-12-31 16:00 libservice-connectivity.so

After:
  $ adbz root && adbz wait-for-device && adbz shell ls -l /apex/com.android.
  /apex/com.android.tethering/bin/for-system:
= -rwsr-sr-x 1 clat clat 18412 1969-12-31 16:00 clatd

  /apex/com.android.tethering/lib:
= -rw-r--r-- 1 system system  64560 1969-12-31 16:00 libandroid_net_connectivity_com_android_net_module_util_jni.so
+ -rw-r--r-- 1 system system 251404 1969-12-31 16:00 libbase.so
= -rw-r--r-- 1 system system 713636 1969-12-31 16:00 libc++.so
= -rw-r--r-- 1 system system  13596 1969-12-31 16:00 libframework-connectivity-jni.so
d -rw-r--r-- 1 system system  45584 1969-12-31 16:00 libnetd_updatable.so
+ -rw-r--r-- 1 system system  95872 1969-12-31 16:00 libnetdutils.so
d -rw-r--r-- 1 system system 749980 1969-12-31 16:00 libservice-connectivity.so

Delta: -212624-948044+251404+45584+95872+749980 == -17828

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id88468442c4f3f24d5bca96b75effb69f20038bf
2022-02-02 18:03:23 -08:00
Maciej Żenczykowski
2f7dac1bad remove spurious headers
bpf_connectivity_headers already pulls in bpf_headers,
which already pulls in bpf_syscall_wrappers.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib22da8d433bd3187349f06f41ec064360c38982f
2022-02-02 16:38:36 -08:00
Maciej Żenczykowski
0bbe3d2ce4 libclat only depends on libbase_headers not libbase itself
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iad66f0d4bed4100261e8aa7d135e62336cdd1ae8
2022-02-02 16:38:36 -08:00
Robert Horvath
d945bf0b4f Add Low Power Standby support to TrafficController
Bug: 190822356
Test: atest TrafficControllerTest
Change-Id: I84a95081ab6e6a86543fe2cddf0efdab16c90d72
2022-02-02 22:54:21 +01:00
Patrick Rohr
61e9467fa6 Move netlink_listener_test into TrafficControllerTest
netlink_listener_test tests the socket destroy listener, so it makes
sense to just merge it into the TrafficControllerTest.

Test: atest traffic_controller_unit_test
Change-Id: Ibc0b483203150aa2d7898a761fa4715dce6f4218
2022-02-01 21:13:30 +01:00
Patrick Rohr
2b1b2c7206 Revert "Prevent native_init from starting TrafficController"
We are ready to remove traffic controller from netd, so
TrafficController::start() should be called from the system server.

This reverts commit c2984fdca8.

Test: atest FrameworksNetTests FrameworksNetIntegrationTests
CtsNetTestCases:android.net.TrafficStatsTest NetworkUsageStatsTest
CtsHostsideNetworkTests

Change-Id: Ic324ad0c064271977ab35d7f55badee00098e196
2022-02-01 17:38:57 +01:00
Patrick Rohr
c2984fdca8 Prevent native_init from starting TrafficController
TrafficController is currently still started by netd, and this should
not happen in two places. Instead, native_init should init (open) the
maps.

Test: atest FrameworksNetTests
Change-Id: Ifd6be50aa5f62e59a5b1c5c0a97550389fd0e7e1
2022-01-31 18:18:21 +01:00
Patrick Rohr
313bc6c2d3 Remove libutils dependency from libservice-connectivity
Remove libutils dependency.

Test: m
Change-Id: I857e40c984bcce2931b5068b3b96d2c9dd69693c
2022-01-31 18:18:21 +01:00
Patrick Rohr
361b859b00 Merge libtraffic_controller_jni into libservice-connectivity
There is not really a point to separate these two as they are all used
in ConnectivityService.
As a future TODO, we might want to rename libservice-connectivity to
libcom_android_server_jni to be more inline with the jarjar'ed jni lib
versions.

Test: atest FrameworksNetTests:ConnectivityServiceTest
Change-Id: I1b9f4fde345038bda6b3ffcf8e3f47cf9262e052
2022-01-31 16:18:51 +01:00
Bob Badour
e7ebed2849 [LSC] Add LOCAL_LICENSE_KINDS to packages/modules/Connectivity
Added SPDX-license-identifier-Apache-2.0 to:
  service/native/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Change-Id: Ibfaed81348fca9e5cf313a4d29fd0b72bc746e06
2022-01-27 10:45:30 -08:00
Maciej Żenczykowski
e1f8ad4d59 Merge changes from topic "libnetworkstats"
* changes:
  Rename libnetdbpf to libnetworkstats
  Copy libnetdbpf from system/net to tethering module
2022-01-25 23:52:06 +00:00
Maciej Żenczykowski
f807ec7da7 Merge changes from topic "configure_bpf_for_clat"
* changes:
  [CLATJ#20] ClatdCoordinator: stop bpf for clat
  [CLATJ#19] ClatdCoordinator: configure bpf for clat
  [CLATJ#18] libclat: move clat tc and bpf utilis from netd
  [CLATJ#17] bpf_connectivity_headers visible to libclat
2022-01-24 19:14:35 +00:00
Ken Chen
f426b2b287 Rename libnetdbpf to libnetworkstats
Two reason for renaming:
1. Avoid module name collision in sc-mainline-prod branch.
2. The libnetdbpf was misnamed before.

Bug: 202086915
Test: atest libnetworkstats_test FrameworksNetTests
      ConnectivityCoverageTests FrameworksNetSmokeTests
      CtsAppOpsTestCases
Change-Id: I87fcf4b1a9d58780a45743a9aa91b9b936e54266
2022-01-24 11:53:59 +08:00
Wayne Ma
790c83e387 [NETD-TC#14] Add traffic controller JNI to tethering module
This CL provides native methods to access BPF maps via a native library.

Bug: 202086915
Test: m; flash; boot;
Change-Id: I2e5d03d0c2e31ba11996d1b28ead9b552397fe29
2022-01-24 00:22:26 +08:00
Wayne Ma
7be6bce52d [NETD-TC#13] Make TrafficControllerTest as traffic_controller_unit_test
Delete tagSocket(), privilegedTagSocket() and untagSocket() revelant
test cases since thay are moved out of TrafficController in
aosp/1849156.

Bug: 202086915
Test: atest traffic_controller_unit_test passed
Change-Id: I605577ee4d7076f0c8ad75888a4d32bff90f6104
2022-01-23 21:26:09 +08:00
Hungming Chen
8ebdb6f1fe [CLATJ#18] libclat: move clat tc and bpf utilis from netd
Move native functions from ClatdController and TcUtils to libclat
for jni ClatdCoordinator.

Bug: 212345928
Test: atest libclat_test
Change-Id: Ia4b344b07537d57c3e4ff1285b0e7b17e0c63c3e
2022-01-22 20:07:19 +08:00
Wayne Ma
a9716ffcb8 [NETD-TC#11] Make TrafficController as libtraffic_controller into
Tethering module.

Delete tagSocket(), privilegedTagSocket() and untagSocket() since
they are moved out of TrafficController in aosp/1849156.

Bug: 202086915
Test: m; flash; boot;
Change-Id: Ifeaeb060fbf1add9f06748e7846b9e11e0345bda
2022-01-22 12:33:49 +08:00
Wayne Ma
92d80790d3 Delete dead codes within TrafficController in mainline module
Delete tagSocket(), privilegedTagSocket() and untagSocket() since
they are moved out of TrafficController in aosp/1849156.

Test: m
Change-Id: I6162c758446f597eb79734e00348dc8b1fe2d422
2022-01-21 15:45:09 +00:00
Wayne Ma
4d69233e63 Move TrafficController relevant files from netd to mainline module
git diff packages/modules/Connectivity/service/native/TrafficController.cpp system/netd/server/TrafficController.cpp
git diff packages/modules/Connectivity/service/native/TrafficControllerTest.cpp system/netd/server/TrafficControllerTest.cpp
git diff packages/modules/Connectivity/service/native/include/TrafficController.h system/netd/server/TrafficController.h

Test: m
No-Typo-Check: clean move
BYPASS_INCLUSIVE_LANGUAGE_REASON= clean move
Change-Id: I7c0200e28e5e4459477d370912277fa1281b786b
2022-01-21 15:37:34 +00:00
Hungming Chen
8ff032b990 [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
2022-01-20 22:50:12 +08:00
Hungming Chen
86a56de609 [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
2022-01-20 22:50:12 +08:00
Hungming Chen
2f623f381c [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
2022-01-20 22:50:12 +08:00
Hungming Chen
6139d87623 [CLATJ#3] libclat: move generateIpv6Address() from netd to apex
generateIpv6Address() 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: I42e152e6fe3ad577a0274e1d55e737318f61176d
2022-01-20 22:50:12 +08:00
Hungming Chen
ed7b4602b5 [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
2022-01-20 22:50:08 +08:00