Commit Graph

464 Commits

Author SHA1 Message Date
Nucca Chen
f8ed984e9c Merge changes Ie826477d,I5125a3ac
* changes:
  [CLATJ#26] ClatCoordinator: reword clatd starting failure logging
  [CLATJ#25] ClatCoordinator: stop clatd process gracefully
2022-01-26 14:50:11 +00:00
Hungming Chen
6fb21144b8 [CLATJ#26] ClatCoordinator: reword clatd starting failure logging
Bug: 212345928
Test: build
Change-Id: Ie826477d27db26cc49d113ec8bfacaaa3006e26e
2022-01-26 12:23:45 +00:00
Hungming Chen
1ff914a543 [CLATJ#25] ClatCoordinator: stop clatd process gracefully
Send SIGTERM with timeout first, if fail, SIGKILL.

Bug: 212345928
Test: connect/disconnect to IPv6 only network and ping 8.8.8.8
      repeat 3 times
Change-Id: I5125a3ac7e8ab6d4e8ae7fc7134b8ac8e42ce5dd
2022-01-26 12:23:22 +00:00
Chiachang Wang
317be96553 Merge "Send exclude local routes value to netd for VPN network" 2022-01-26 02:09:35 +00:00
Maciej Żenczykowski
43f9729e90 Merge changes from topic "preparation_fork_clatd_from_system_server"
* changes:
  [CLATJ#24] ClatCoordinatorTest: add basic unit tests
  [CLATJ#23] Close the file descriptor manually
  [CLATJ#22] ClatCoordinator: stop clatd
  [CLATJ#21] ClatCoordinator: start clatd
2022-01-26 00:26:48 +00: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
Hungming Chen
d7b63f8f93 [CLATJ#23] Close the file descriptor manually
ParcelFileDescriptor rely on garbage collection to close handler.
When there is any error during starting clat or quick on/off
IPv6 only network, the file descriptor may not be able to be closed
before next clatStart is called. This may be problematic. For
example, the same v4- tun interface has not closed yet and clatStart
has been called again.

Test: connect/disconnect to IPv6 only network and ping 8.8.8.8
      repeat 10 times
Change-Id: I8e1c66206dc221827a039213ecc86d5cbd777dff
2022-01-25 20:32:11 +08:00
Hungming Chen
9d11ddfd5c [CLATJ#22] ClatCoordinator: stop clatd
provide clatd stop function which stops clatd by pid.

Bug: 212345928
Test: flash and boot
Run "atest ClatCoordinatorTest" in a follow commit.

Change-Id: Icd9c4f9038bf75113fbc5608f213145e58a061d9
2022-01-25 18:44:09 +08:00
Hungming Chen
9625caa8e5 [CLATJ#21] ClatCoordinator: start clatd
launch clatd with the given cli arguments.

Bug: 212345928
Test: flash and boot
- run "atest ClatCoordinatorTest" in a follow commit.
- manual test
  1. Connect to ipv6-only wifi.
  2. Try IPv4 traffic.
     $ ping 8.8.8.8

Change-Id: Ie57a7c7a9d3d77396e91fa9f94c02f1ad05487c1
2022-01-25 18:43:59 +08:00
Paul Hu
eead25d263 Merge "Add jarjar rules for service-connectivity-tiramisu-pre-jarjar" 2022-01-25 04:15:41 +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
Sooraj Sasindran
0311ea0bc6 Merge "Add support for Multiple enterprise slice" 2022-01-24 16:26:03 +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
paulhu
824b001b74 Add jarjar rules for service-connectivity-tiramisu-pre-jarjar
- Add rule for modules-utils-statemachine lib.

Bug: 206893064
Test: m
Change-Id: Ia70a86be0f52f9aecddd9716d3a3a266aef35bc8
2022-01-24 10:56:29 +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
Sooraj Sasindran
f4a58dcd45 Add support for Multiple enterprise slice
Bug: 194332512
Test: unit test
CTS-Coverage-Bug: 211133973
Change-Id: Ie8be08a7cfa9155168d1da146d02fd1643248bdc
2022-01-22 14:39:40 -08:00
Hungming Chen
fb676b58e0 [CLATJ#20] ClatdCoordinator: stop bpf for clat
Remove eBPF offload at clat stopping if possible.

Bug: 212345928
Test: build only
because need to test with clatd launched

Change-Id: I6ace77694c0e6fe68d16e80e3c8198aa41385fd2
2022-01-22 20:07:30 +08:00
Hungming Chen
b1d3ccbeb6 [CLATJ#19] ClatdCoordinator: configure bpf for clat
Configure eBPF offload at clat starting if possible.

Bug: 212345928
Test: connect to ipv6 only network and check bpf entries
$adb shell dumpsys netd --short | grep Clat -A10
  ClatdController
    Trackers: iif[iface] nat64Prefix v6Addr -> v4Addr v4iif[v4iface] [fwmark]
    BPF ingress map: iif(iface) nat64Prefix v6Addr -> v4Addr oif(iface)
      47(wlan0) 64:ff9b::/96 2a00:79e1:abc:6f02:b7aa:ff3c:9220:595c -> 192.0.0.4 52(v4-wlan0)
    BPF egress map: iif(iface) v4Addr -> v6Addr nat64Prefix oif(iface)
      52(v4-wlan0) 192.0.0.4 -> 2a00:79e1:abc:6f02:b7aa:ff3c:9220:595c 64:ff9b::/96 47(wlan0) ether

Change-Id: I8ff77a2e3e86bfe6dbf43f4181414e444ba0da32
2022-01-22 20:07:24 +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
0c155199c0 Merge changes from topic "clean_move_and_delete"
* changes:
  Delete dead codes within TrafficController in mainline module
  Move TrafficController relevant files from netd to mainline module
2022-01-21 17:10:07 +00: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
Sooraj Sasindran
499117f279 Ability to specify which all applications fall under enterprise slice.
Bug: 194332512
Test: unit test
Change-Id: I94549a41aaa717add22b0a3e5035beacf6f1b8f2
2022-01-21 01:05:12 -08:00
Wayne Ma
0ea3bdc88b [NETD-TC#10] Create BpfNetMaps class
BpfNetMaps provide interfaces and native methods for
manipulating BPF maps by calling jni library of traffic controller.

DO NOT TOUCH BpfNetMaps before aosp/1945136 and aosp/1948169 get merged.

Bug: 202086915
Test: build and flash
Change-Id: Iaff8ac71100b3f76b444f3b83616556d0ee6eadf
2022-01-21 13:19:29 +08:00
Hungming Chen
050b6529c4 [CLATJ#16] Rename JNI/Dependencies function and improve JNI error handling
- rename JNI functions with prefix native_*
- throw exception while JNI function gets invalid address argument
- throw exception while JNI function returns invalid address

Bug: 212345928
Test: flash and boot
Run "atest ClatCoordinatorTest" in a followup commit

Change-Id: I6745a61525c6f72a61fbde0b21b3f7abcdf2446a
2022-01-20 22:50:13 +08:00
Hungming Chen
847b2ce4f9 [CLATJ#15] ClatCoordinator: add socket filter to packet socket
Update our packet socket filter to reflect the new 464xlat IP address

Bug: 212345928
Test: flash and boot
Run "atest ClatCoordinatorTest" in a followup commit

Change-Id: Ic50dc122731f311ad00ab8bff5472cb3bc41f5f1
2022-01-20 22:50:13 +08:00
Hungming Chen
2c3acb01c9 [CLATJ#14] ClatCoordinator: add anycast to raw socket
Start translating packets to the new prefix.

Bug: 212345928
Test: flash and boot
Run "atest ClatCoordinatorTest" in a followup commit.

Change-Id: I38729c23fce72428919b33ac531ede9593337a0a
2022-01-20 22:50:13 +08:00
Hungming Chen
d292f45e16 [CLATJ#13] ClatCoordinator: open raw socket
Move the raw socket initialization from netd to mainline because
mainline module is going to launch clatd. Need to provide raw
socket for writing local 464xlat IPv6 packets.

Bug: 212345928
Test: flash and boot
Run "atest ClatCoordinatorTest" in a followup commit.

Change-Id: I6d1da4f1b400eeed87771ae8197b0c58ec50804b
2022-01-20 22:50:13 +08:00
Hungming Chen
79d34befb1 [CLATJ#12] ClatCoordinator: open packet socket with a given mark
Move the packet socket initialization from netd to jni because
mainline module is going to launch clatd. Need to provide packet
socket for reading local 464xlat IPv6 packets.

Bug: 212345928
Test: flash and boot
Run "atest ClatCoordinatorTest" in a followup commit.

Change-Id: I1cef6e099403f883d668081fb5e917863f5a3c2a
2022-01-20 22:50:13 +08:00
Hungming Chen
397ca65abb [CLATJ#11] ClatCoordinator: config tun interface and bring up
Apply mtu and selected IPv4 address to tun interface.
Then, bring up the tun interface.

Bug: 212345928
Test: flash and boot
Run "atest ClatCoordinatorTest" in a followup commit.

Change-Id: I24a2a91e2b084be28820a7a63b265c5f56293334
2022-01-20 22:50:13 +08:00
Hungming Chen
7de1c49b74 [CLATJ#10] ClatCoordinator: detect mtu
Detect the available mtu for clat. The native mtu detect function
is moved from netd to libclat which is called by jni. The java
adjust mtu function is moved from netd native code.

Bug: 212345928
Test: flash and boot
Run "atest ClatCoordinatorTest" in a followup commit.

Change-Id: Icf5f57c7e7b947997b76152722e46acdd9d95c1a
2022-01-20 22:50:13 +08:00
Hungming Chen
46bbee1bfe [CLATJ#9] ClatCoordinator: open tun interface
Open the v4-... tun interface for clat. The native function
is moved from netd to jni.

Bug: 212345928
Test: flash and boot
Run "atest ClatCoordinatorTest" in a followup commit.

Change-Id: I3f3c587275125ce3fc7481006947211f17dbb2d4
2022-01-20 22:50:13 +08:00
Hungming Chen
884c0a122c [CLATJ#8] ClatCoordinator: select IPv6 address with checksum-neutral IID
Select a local 464xlat IPv6 address for clatd. The IPv6 address has
checksum-neutral IID. The native function is moved from netd to
libclat. Its test is moved from netd as well.

Bug: 212345928
Test: flash and boot
Run "atest ClatCoordinatorTest" in a followup commit.

Change-Id: I11520e5c086e475999847d829dd6341b14199b39
2022-01-20 22:50:13 +08:00
Hungming Chen
e2cf055590 [CLATJ#7] ClatCoordinator: select IPv4 address for clatd
Introduce ClatCoordinator to replace netd/ClatdController.
This is a startup commit. Starting clatd needs to prepare local
464xlat ipv4 address, local 464xlat ipv6 address, tun interface,
clat read/write sockets. These will be implemented from this
and followup commits. This commit implements that prepare local
464xlat ipv4 address.

Bug: 212345928
Test: flash and boot
Run "atest ClatCoordinatorTest" in a followup commit.

Change-Id: I486db8aef0181ee1aedd7cd7702f95d5a1cef812
2022-01-20 22:50:13 +08: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
Paul Hu
a77cad355b Merge "Build framework-connectivity-tiramisu library" 2022-01-20 03:02:56 +00:00
Chiachang Wang
9164c10b67 Send exclude local routes value to netd for VPN network
Bug: 184750836
Test: atest FrameworksNetTests
Change-Id: I40ce741b6e918db7bf62cb5f29d9be1b16a94902
2022-01-18 17:45:30 +08:00
Mark Chien
21f0d58294 Merge "Add swapActiveStatsMap API for NetworkStatsFactory" 2022-01-14 05:35:25 +00:00
Mark Chien
094de6b7c4 Merge "Add replaceFirewallChain API" 2022-01-14 05:33:58 +00:00
Mark Chien
9bba8e8c78 Merge "Add setFirewallChainEnabled API" 2022-01-14 05:33:38 +00:00
Mark Chien
c65ecacd6f Merge "Add updateFirewallRule API" 2022-01-14 05:33:22 +00:00
markchien
9c8061134c Add swapActiveStatsMap API for NetworkStatsFactory
This CL should be reverted before T sdk finalized.
This API is temporary added for the NetworkStatsFactory which is platform
code but will be moved into connectivity (tethering) mainline module.

Bug: 209935649
Test: atest CtsHostsideNetworkTests
Change-Id: I5894450f3089b2ea105722a18ddf8f1eed1c28a0
2022-01-14 10:23:26 +08:00
markchien
00a0bed534 Add replaceFirewallChain API
To deprecated firewallReplaceUidChain netd binder and move the
functionality to tethering (connectivity) mainline module, expose
replaceFirewallChain to support the caller outside the module.
Currently the API are still call to netd. Will replace with the
implementation inside tethering (connectivity) module.

Bug: 209935649
Test: atest CtsHostsideNetworkTests
Change-Id: If7a87548b0a3acda00a1455da4e4ff24a630ddc7
2022-01-14 10:23:21 +08:00
markchien
98a6f95d0f Add setFirewallChainEnabled API
To deprecated firewallEnableChildChain netd binder and move the
functionality to tethering (connectivity) mainline module, expose
setFirewallChainEnabled to support the caller outside the module.
Currently the API are still call to netd. Will replace with the
implementation inside tethering (connectivity) module.

Bug: 209935649
Test: atest CtsHostsideNetworkTests
Change-Id: I9b64c9d12260521489a87fbeae5afbee2a8ea8f6
2022-01-14 10:23:15 +08:00