Commit Graph

19 Commits

Author SHA1 Message Date
Motomu Utsumi 3af8f0e8d6 Add startSkDestroyListener flag to native_init
This CL prepares for upcoming CL.
Upcoming CL will add SkDestroyListener with Java BpfMap and switch
current C SkDestroyListener and new Java SkDestroyListener based on the
experiment flag.

Bug: 217624062
Test: atest SkDestroyListenerTest
Change-Id: I5ebb319d1b2262199d4ef6a3549894fee24c4ccf
2022-09-06 11:23:13 +09:00
Motomu Utsumi 7abeaa499c Support java BpfMap in BpfNetMaps#swapActiveStatsMap
Bug: 217624062
Test: atest BpfNetMapsTest
android.net.cts.NetworkStatsManagerTest
android.net.cts.TrafficStatsTest

Change-Id: I9cb673673d2ed1dda8fa14c0877e2fc683267791
2022-08-17 14:40:53 +00:00
Maciej Żenczykowski feb83ba675 Merge "fail *hard* if TrafficController::start() fails" 2022-08-08 17:41:57 +00:00
Maciej Żenczykowski 990635c6c0 fail *hard* if TrafficController::start() fails
Hitting this abort() likely means map initialization failed,
and basically things won't work correctly.

Another possibility detected on wembley is a kernel bpf bug
which prevents writes into index != 0 of bpf array maps.

But such a kernel bug will make TC useless.
Best to abort() and cause a mainline module rollback.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iddb9b32944f1cddc299d2af3dd8c2eb9c84f94a3
2022-08-08 10:04:53 +00:00
Motomu Utsumi 114cd9cf73 Revert "Remove unused codes that was used in setChildChain"
This reverts commit b1144d7671.

Reason for revert: We decided to have experiment and switch old code path and new code path based on a flag. So the codes removed by this CL is needed.

Bug: 217624062
Test: m

Change-Id: Icb8a353a74935ed97f8e102ba54020825676b817
2022-08-01 08:42:39 +00:00
Motomu Utsumi b1144d7671 Remove unused codes that was used in setChildChain
Previous commit update BpfNetMaps#setChildChain to use Java BpfMap.
This commit remove the code that is no longer used due to the previous
commit.

Bug: 217624062
Test: atest BpfNetMapsTest android.net.cts.ConnectivityManagerTest#testFirewallBlocking
Change-Id: I02656096c8752daf20d3578f209778c5adae9b0c
2022-06-24 09:11:58 +00:00
Motomu Utsumi 8b42e6d431 Remove LOCKDOWN from FirewallChain IntDef
LOCKDOWN_VPN was in the FirewallChain IntDef but this was not a right
place because LOCKDOWN_VPN was not a valid value for Connectivity APIs
that take an argument annotated with @FirewallChain(setUidFirewallRule,
setFirewallChainEnabled, replaceFirewallChain).

LOCKDOWN_VPN was in the FirewallChain IntDef because
BpfNetMaps#setUidRule was used to add/remove LOCKDOWN_VPN entries.
This commit adds BpfNetMaps#updateUidLockdownRule and uses this to
add/remove LOCKDOWN_VPN entries instead of BpfNetMaps#setUidRule and
removes LOCKDOWN from FirewallChain.

Bug: 206482423
Test: atest TrafficControllerTest ConnectivityServiceTest
PermissionMonitorTest HostsideVpnTests#testBlockIncomingPacket

Change-Id: Iff9b9792fc0f208f153e10e396c6d5034b412d7c
2022-06-10 02:49:25 +00:00
Maciej Żenczykowski 932ef5b220 BpfNetMaps - minor jni code fixups
(a) jni static methods take 'jclass clazz' as 2nd argument,
while non-static methods take 'jobject this/thiz/self'

(b) use a macro for error handling to remove duplicate code

(c) also fix some whitespace

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2773617dc7129efb87e28266f97ec3e01a35efc3
2022-05-24 16:01:12 +00:00
Motomu Utsumi b08654ca04 Block incoming packets in VPN Lockdown mode.
Currently, even when VPN Lockdown mode is enabled, incoming packets are
not dropped if VPN is not connected.

This commit fixed this issue.
After this commit, If VPN Lockdown mode is enabled, incoming packets
are dropped regardless of the VPN connectivity.

Bug: 206482423
Test: atest TrafficControllerTest ConnectivityServiceTest PermissionMonitorTest
Change-Id: If52ece613c8aac1073355e43b6fb9cb3fcc87d1d
2022-05-16 10:40:59 +00:00
Wayne Ma 5545291ef5 Address comment from aosp/1948169
Bug: 202086915
Test: m; flash; boot;
Change-Id: I9bd627cc4ec77e1ab6da3e3acc7d4d8bba7d43de
2022-02-18 14:18:06 +08:00
Ken Chen e6d511f785 Support "dumpsys connectivity trafficcontroller"
Enable ConnectivityService to dump BPF maps from libtraffic_controller.

Bug: 202086915
Test: adb shell dumpsys connectivity trafficcontroller
Test: atest CtsNetTestCases:ConnectivityManagerTest#testDumpBpfNetMaps
Test: run CTS in I021789813f116940d581e2c4a1fd357ff47bfa08
Change-Id: Ib0e935ee2b714ac61daceba6d13fa7a20f97f68f
2022-02-17 16:58:47 +08:00
Wayne Ma 622c72ea49 Merge "Address comment from aosp/1948169" 2022-02-15 10:33:23 +00:00
Wayne Ma 510c2f463f Address comment from aosp/1948169
Bug: 202086915
Test: m; flash; boot;
Change-Id: Ic989fa2a58edb15155fba175d4cdf8952b511ae7
2022-02-15 14:54:45 +08:00
markchien 4dd5be6606 Remove unused BpfNetMap jni function
native_deleteTagData and native_setCounterSet is replaced as BpfMap java
implementation inside NetworkStatsService.java

Test: atest traffic_controller_unit_test
Change-Id: Ic33ca9d9887380d39becbd0dc3a0e159b3dc82a2
2022-02-11 08:04:55 +00:00
Patrick Rohr 83fb6742ac Fix BpfNetMap error logging
Log result code in native_init and fix spelling in log messages.

Test: m
Change-Id: I39b429ba05c6d5ccf50d28b0592fa5241972aa1b
2022-02-01 17:39:11 +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