summaryrefslogtreecommitdiff
path: root/service/native/TrafficControllerTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* switch netd_configuration_map from hash map to arrayMaciej Żenczykowski2022-06-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This eliminates the need for netd_updatable BpfHandler.cpp to initialize the hash map with a zero. On startup the map will be freshly initialized and thus zero. On restart it might not be empty, but it doesn't matter to netd. Furthermore the mainline component of the system server will re-initialize it again anyway: see service/native/TrafficController.cpp initMaps() This does remove the ability to call deleteValue on a key, since that would always return -EINVAL, but since we don't currently do that, that's really a feature. (It does suggest though that we should have a BpfMapNonNullable class which is writeable, but without a deleteValue() function) Additionally BpfMap arrays are more efficient for the kernel bpf jit compiler, as - on newer kernels - it can optimize the read/write into a simple memory access (as opposed to a bpf helper call). Before: $ adb shell ls -l /sys/fs/bpf/netd_shared/map_netd_configuration_map -rw-rw---- 1 root net_bw_acct 0 2022-06-11 08:20 /sys/fs/bpf/netd_shared/ map_netd_configuration_map After: $ adbz shell ls -l /sys/fs/bpf/netd_shared/map_netd_configuration_map -r--rw---- 1 root net_bw_acct 0 2022-06-16 15:03 /sys/fs/bpf/netd_shared/map_netd_configuration_map Bug: 218408035 Bug: 235590615 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I21730e4fa22fbf0c94ab0ca5c5db03aa000b7680 (cherry picked from commit b10e055f4b63ef5ae12585069481558b93ecd87f) Merged-In: I21730e4fa22fbf0c94ab0ca5c5db03aa000b7680
* Merge changes from topic ↵Lorenzo Colitti2022-06-081-23/+14
|\ | | | | | | | | | | | | | | | | "cherrypicker-L06100000954878020:N56300001270177780" into tm-dev * changes: tests: simplify BpfMap.reset(createMap()) -> BpfMap.resetMap() TrafficControllerTest - trivial simplification simplify bpf tests and check type correctness
| * tests: simplify BpfMap.reset(createMap()) -> BpfMap.resetMap()Maciej Żenczykowski2022-06-081-12/+7
| | | | | | | | | | | | | | | | | | | | | | | | BpfMap.reset(createMap()) is equivalent to newly added BpfMap.resetMap(), except that the latter makes it impossible to screw up the Key/Value sizes. Bug: 235286176 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I290986e9ae8660f3fc6f73b086d33f4ab93d6095 (cherry picked from commit 439bac2e566eb8b52981a229e4be88a05b58149c) Merged-In: I290986e9ae8660f3fc6f73b086d33f4ab93d6095
| * TrafficControllerTest - trivial simplificationMaciej Żenczykowski2022-06-081-1/+1
| | | | | | | | | | | | | | | | | | Bug: 235286176 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I25158126c968707f44f595f731547a8bd9bb503d (cherry picked from commit ced3531ad5124234909b2e29d46b222197739134) Merged-In: I25158126c968707f44f595f731547a8bd9bb503d
| * simplify bpf tests and check type correctnessMaciej Żenczykowski2022-06-081-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We notice that: BpfMap.reset(dupFd_with_cloexec(BpfMap.getMap()) is equivalent to BpfMap = BpfMap due to the current implementation of the BpfMap assignment operator. Except the latter also verifies BpfMap<K,V> template types match. Bug: 235286176 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I99fcf77bc6aa360b6a19e22c2cd58d67a1e62976 (cherry picked from commit 55ab87aa4937f562e6952c5b88e90eae6eca41c4) Merged-In: I99fcf77bc6aa360b6a19e22c2cd58d67a1e62976
* | Add 3rd deny firewall chain for OEMMotomu Utsumi2022-06-071-0/+2
|/ | | | | | | | | | | Bug: 208371987 Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest#testFirewallBlocking ConnectivityServiceTest Change-Id: Ib521fa02f6a19270cb88a3d85321bda822516c78 (cherry picked from commit 1d9054ba5fbbf86c821e0a74a5a2f9d3c9865e67) Merged-In: Ib521fa02f6a19270cb88a3d85321bda822516c78
* Add deny firewall chain for OEMMotomu Utsumi2022-06-031-0/+4
| | | | | | | | | | | | Bug: 207773349 Bug: 208371987 Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest#testFirewallBlocking --iterations 50 && atest ConnectivityServiceTest --iterations 10 Change-Id: I60d5540821abcced03356f366775f16ee369d7f9 (cherry picked from commit d980149817948d11de0631caee8aee3172e4e159) Merged-In: I60d5540821abcced03356f366775f16ee369d7f9
* Support more than 8 firewall chains / match types.Lorenzo Colitti2022-06-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | In the BPF code, per-UID network access (e.g., for doze mode, standby, etc.) is stored in UidOwnerValue structures. Each of these stores that UID's rules in a 32-bit bitmask of UidOwnerMatchType values, so the code can support ~31 match types. However, which match types are enabled is stored in configuration_map at index UID_RULES_CONFIGURATION_KEY, and configuration_map only stores 8-bit values. So it's not possible to define more than 7 match types. Widen configuration_map to from 8 to 32 bits to match the width of UidOwnerValue.rule. This doesn't impact memory because configuration_map only has 2 entries. Bug: 208371987 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I7e1eee2daedd66d27965a2dd4ce6b4c3667892f7 (cherry picked from commit 60cbed385dcf3c640674c48b7cd4d60967047cf0) Merged-In: I7e1eee2daedd66d27965a2dd4ce6b4c3667892f7
* Block incoming packets in VPN Lockdown mode.Motomu Utsumi2022-05-171-0/+65
| | | | | | | | | | | | | | | 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 (cherry picked from commit b08654ca0450d021da709a762ab509a8d4f87d40) Merged-In: If52ece613c8aac1073355e43b6fb9cb3fcc87d1d
* Remove unused BpfNetMap jni functionmarkchien2022-02-111-164/+0
| | | | | | | | native_deleteTagData and native_setCounterSet is replaced as BpfMap java implementation inside NetworkStatsService.java Test: atest traffic_controller_unit_test Change-Id: Ic33ca9d9887380d39becbd0dc3a0e159b3dc82a2
* Add Low Power Standby support to TrafficControllerRobert Horvath2022-02-021-0/+2
| | | | | | Bug: 190822356 Test: atest TrafficControllerTest Change-Id: I84a95081ab6e6a86543fe2cddf0efdab16c90d72
* Move netlink_listener_test into TrafficControllerTestPatrick Rohr2022-02-011-0/+129
| | | | | | | | 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
* [NETD-TC#13] Make TrafficControllerTest as traffic_controller_unit_testWayne Ma2022-01-231-27/+36
| | | | | | | | | | 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
* Delete dead codes within TrafficController in mainline moduleWayne Ma2022-01-211-139/+1
| | | | | | | | Delete tagSocket(), privilegedTagSocket() and untagSocket() since they are moved out of TrafficController in aosp/1849156. Test: m Change-Id: I6162c758446f597eb79734e00348dc8b1fe2d422
* Move TrafficController relevant files from netd to mainline moduleWayne Ma2022-01-211-0/+879
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