Commit Graph

662 Commits

Author SHA1 Message Date
Hungming Chen
d50f53b58a [BOT.2] Create a coordinator and stats provider to provide tether stats
Make BPF tethering offload coordinator, BpfCoordinator,
registers a network stats provider, BpfTetherStatsProvider, and
provide the tethering stats from the BPF map.

Bug: 150736748
Test: new test BpfCoordinatorTest

Original-Change: https://android-review.googlesource.com/1256189
Merged-In: I22e71f87b67668f7e733e4f215d93bf5b2c9380d
Change-Id: I22e71f87b67668f7e733e4f215d93bf5b2c9380d
2020-06-10 03:10:13 +00:00
Treehugger Robot
5a18fd3d2c Merge "Address comment from aosp/1232197" am: 7e6ff1bde1 am: a87d030207
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1318288

Change-Id: Iabdcc3b95239019a625e9823f70c30a9bded706a
2020-06-09 17:59:03 +00:00
Treehugger Robot
7e6ff1bde1 Merge "Address comment from aosp/1232197" 2020-06-09 17:19:33 +00:00
Treehugger Robot
fe3f85ba3d Merge "[BOT.6] Make BpfCoordinator to support data limit" am: 73dd6f71f8 am: 3e58ec268b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1302436

Change-Id: Icf64d856318173ad599a4f48295c9bdf591967f1
2020-06-09 13:28:38 +00:00
Treehugger Robot
73dd6f71f8 Merge "[BOT.6] Make BpfCoordinator to support data limit" 2020-06-09 12:58:20 +00:00
Hungming Chen
269c0886ed [BOT.6] Make BpfCoordinator to support data limit
The BPF tethering coordinator listens to the forwarding rule
changes for updating data limit which is applied in the following
conditions.
- After adding the first rule on a given upstream, add data limit.
- After removing the last rule on a given upstream, clear data limit.
- The service applies a new data limit on current upstream.

The reason for relying on rule changes is because the Tethering and
IpServer objects have multi-internal state machines. It is hard to
synchronize all of their states.

Note that the data limit cleanup for stopping or switching upstream
relies on offload rules are all removed as well.

Bug: 150736748
Test: manual
Change-Id: I829d36339973f9473fe6b616c48aa288f18d1c46
2020-06-09 17:33:03 +08:00
Lorenzo Colitti
6ae789f577 Merge "[BOT.9] Add unit test for data warning in BpfCoordinator" am: fd349683c9 am: dd9f16708c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1311658

Change-Id: I5db2504e87edf3389dced385191cc250b88e2da0
2020-06-09 02:55:52 +00:00
Lorenzo Colitti
fd349683c9 Merge "[BOT.9] Add unit test for data warning in BpfCoordinator" 2020-06-09 02:22:59 +00:00
Paul Hu
98a32f115d Merge "Make tether settings intent explicit" am: 51241a168c am: 913cd757d5
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1318286

Change-Id: I7eafc623fcd88b9544756295d84c936c2ab2507a
2020-06-08 16:20:55 +00:00
Paul Hu
51241a168c Merge "Make tether settings intent explicit" 2020-06-08 10:31:21 +00:00
Hungming Chen
b1406cf0d6 [BOT.9] Add unit test for data warning in BpfCoordinator
Bug: 150736748
Test: atest BpfCoordinatorTest
Change-Id: Ic1f37de75b064d7c8717e1b496e13174bb8693ec
2020-06-08 17:31:51 +08:00
paulhu
3fe5434d19 Make tether settings intent explicit
Currently tethering notification is sending a pending intent for
redirecting user to tether settings page. However, this intent
is implicit that only create with
Settings.ACTION_TETHER_SETTINGS. For security reasons, this
intetnt should specify an explicit component to be delivered to.
Thus, specify the settings package name to this intent.

Test: atest TetheringTests
Bug: 156353008
Change-Id: I49187aee8a004caa890e2a73c0a28d280215c7d4
2020-06-08 06:04:19 +00:00
TreeHugger Robot
905ad0070d Merge "Gate exemptFromEentitlementCheck by Network_STACK permission" into rvc-dev 2020-06-02 15:09:56 +00:00
Paul Duffin
672fa36bdd Merge "Switch to standard naming scheme" into rvc-dev am: f94d682a9b
Original change: undetermined

Change-Id: I57cffc68409c2e9b795b0c8732fecc9bbf33e113
2020-06-02 11:58:50 +00:00
Paul Duffin
6812c1b1ee Switch to standard naming scheme
Removes use of the special framework-modules naming scheme.

Bug: 155164730
Test: m java
Exempt-From-Owner-Approval: Build cleanup.
Change-Id: I3b78fcbcacc3df787e171d6eedeef1e51b087615
Merged-In: I0c31e2183353dfb5bd49f04f3455cb7b10be6866
(cherry picked from 8b864fb45ce79051437f13c2a19510718ea3b7aa)
2020-06-02 06:53:53 +00:00
markchien
03b52fcfd5 Gate exemptFromEentitlementCheck by Network_STACK permission
Shell has TETHER_PRIVILEGED permission. To avoid any service to adopt
shell identity by lunching service with Shell process, gate
exemptFromEentitlementCheck by NETWORK_STACK.

Bug: 157702014
Test: atest TetheringCoverageTests
Change-Id: I6ddfda23d36ea9981e3e1eb5a87767f452a65852
Merged-In: I6ddfda23d36ea9981e3e1eb5a87767f452a65852
2020-06-02 14:46:06 +08:00
Treehugger Robot
507e5320f1 Merge "Gate exemptFromEentitlementCheck by Network_STACK permission" am: 650c23fdc2 am: dc1e33c9b3
Original change: undetermined

Change-Id: Ic64b4551e70338bb1b81f9d9471f85cfa1c30bf3
2020-06-02 04:01:09 +00:00
Treehugger Robot
650c23fdc2 Merge "Gate exemptFromEentitlementCheck by Network_STACK permission" 2020-06-02 03:31:24 +00:00
Hungming Chen
a3c8a7503c [BOT.3] Add unit test for polling network stats in the coordinator am: 7997d691fe am: 5fd9fcce13
Original change: undetermined

Change-Id: Ib9ad6e1ab139295ef603e7c8ec86d689ea9801af
2020-06-02 00:13:40 +00:00
Hungming Chen
8bebb8eaa5 [BOT.2] Create a coordinator and stats provider to provide tether stats am: 68f1c2a63f am: eba638f4a9
Original change: undetermined

Change-Id: Ic7fe1a8c0d16c8b435269a1973687655a9c7412b
2020-06-02 00:13:26 +00:00
Hungming Chen
5fd9fcce13 [BOT.3] Add unit test for polling network stats in the coordinator am: 7997d691fe
Original change: undetermined

Change-Id: Ic3b56365d7f1dbde23e0d1b902a21a3de3ad7327
2020-06-01 23:52:56 +00:00
Hungming Chen
eba638f4a9 [BOT.2] Create a coordinator and stats provider to provide tether stats am: 68f1c2a63f
Original change: undetermined

Change-Id: I21fe5385b8cdfe2ce2ff982884d72a398183bde3
2020-06-01 23:52:53 +00:00
Nucca Chen
4155d2a6ad Merge changes from topic "tether_offload_data_limit"
* changes:
  Make tethering module to use netd_aidl_interface-unstable-java
  [BOT.5] Move class Ipv6ForwardingRule from IpServer to the coordinator
  [BOT.3] Add unit test for polling network stats in the coordinator
  [BOT.2] Create a coordinator and stats provider to provide tether stats
  [BOT.1] Add a class ForwardedStats in TetheringUtils
2020-06-01 23:33:24 +00:00
Paul Hu
aac3b2ead0 Merge "Use Class#getSimpleName instead of KClass#getSimpleName" 2020-06-01 06:43:13 +00:00
Mark Chien
2ecd333f59 Tethering: ensure downstream prefix do not conflict with upstream
- Add New class PrivateAddressCoordinator to coordinate the private
  address conflict problem.
- Downstream prefix would be random in 192.168.0.0/24 ~
  192.168.255.0/24.
- If new upstream prefix is conflict with existing downstream prefix,
  downstream would be kicked out and it would request a new one.
- The last conflict upstream prefixes would be blacklist. Avoid to
select downstream prefix which is conflict with prefixes in blacklist.

Bug: 130879722
Test: -build, flash, boot
      -atest TetheringTests

Merged-In: Ib45b87bcd9eeb5da03fb7ec90b1af9ca53998cf5
Change-Id: Ib45b87bcd9eeb5da03fb7ec90b1af9ca53998cf5
2020-05-30 03:42:57 +00:00
Mark Chien
0e1a1f4c68 Merge "Tethering: ensure downstream prefix do not conflict with upstream" am: 7bf51619d8 am: 3cefc6e048
Change-Id: Ib70a471603d850069aae029dea7fc09a9b28f4bc
2020-05-29 22:07:37 +00:00
Hungming Chen
7997d691fe [BOT.3] Add unit test for polling network stats in the coordinator
Verify that the coordinator could fetch tether stats from BPF maps and
report the network stats to the service.

Bug: 150736748
Test: atest BpfCoordinatorTest
Change-Id: Ib1756159a2047c5db7d31359b0f288f840bd1bb1
2020-05-29 20:23:31 +08:00
Hungming Chen
68f1c2a63f [BOT.2] Create a coordinator and stats provider to provide tether stats
Make BPF tethering offload coordinator, BpfCoordinator,
registers a network stats provider, BpfTetherStatsProvider, and
provide the tethering stats from the BPF map.

Bug: 150736748
Test: new test BpfCoordinatorTest

Change-Id: I22e71f87b67668f7e733e4f215d93bf5b2c9380d
2020-05-29 20:23:22 +08:00
Chalard Jean
601193a68e Merge "Use Class#getSimpleName instead of KClass#getSimpleName" into rvc-dev am: 88c69840cd
Change-Id: Ice90dba6408eca9c031592fd4933a107fdbbec2f
2020-05-29 09:24:53 +00:00
Chalard Jean
88c69840cd Merge "Use Class#getSimpleName instead of KClass#getSimpleName" into rvc-dev 2020-05-29 09:16:28 +00:00
markchien
9e790873d9 Gate exemptFromEentitlementCheck by Network_STACK permission
Shell has TETHER_PRIVILEGED permission. To avoid any service to adopt
shell identity by lunching service with Shell process, gate
exemptFromEentitlementCheck by NETWORK_STACK.

Bug: 157702014
Test: atest TetheringCoverageTests
Change-Id: I6ddfda23d36ea9981e3e1eb5a87767f452a65852
2020-05-29 06:46:22 +00:00
Mark Chien
40a9eb779b Merge "Extend timeout for requesting tethered interface" into rvc-dev 2020-05-29 06:11:12 +00:00
Mark Chien
7bf51619d8 Merge "Tethering: ensure downstream prefix do not conflict with upstream" 2020-05-29 03:34:45 +00:00
markchien
df503d4bd1 Address comment from aosp/1232197
1. Call maybeRemoveDeprecatedUpstreams from Tethering rather than inside
PrivateAddressCoordinator because the building logic of this method based
on implementation details of Tethering.
2. Fix typo

Bug: 130879722
Test: -build, flash, boot
      -atest TetheringTests

Change-Id: I7584253b728bc17fc648fc19e492ca9f7ad2ff46
2020-05-29 11:24:08 +08:00
paulhu
086f24626c Use Class#getSimpleName instead of KClass#getSimpleName
KClass#getSimpleName need refer to kotlin-reflect.jar which need
include it in Andorid.bp. However, it's not necessary to use
KClass#getSimpleName but use Class#getSimpleName instead.

Test: atest TetheringTests
Bug: 157527499
Change-Id: I49bc336a276d30152402eba926cc583bc81e8e5c
Merged-In: I49bc336a276d30152402eba926cc583bc81e8e5c
2020-05-29 00:29:22 +08:00
Paul Duffin
2dae272903 Switch framework-tethering to use java_sdk_library
The names of the individual modules do not quite follow the pattern
that java_sdk_library uses so this temporarily sets the following:
    naming_scheme: "frameworks-modules"

That causes java_sdk_library to use a naming scheme that matches the
one used by the individual modules of this. It will be cleaned up
later.

Part of the purpose of the java_sdk_library is to hide the
implementation code and force users of the library to depend on stubs
for a well defined API. Ideally, it would allow access to the
implementation in those cases where it is safe, e.g. from within the
same APEX, or from tests for the implementation. Unfortunately, due to
limitations in the build it does not yet have enough information to
make that decision correctly which means that any code that needs to
compile against the implementation is broken which would prevent us
from converting the module to java_sdk_library.

However, the only way to provide the additional information to allow
the implementation to be correctly exposed is to convert the modules
to java_sdk_library; a cycle.

In order to break that cycle the java_sdk_library creates a special
<module>.impl target which is used directly by tests and any other code
that needs it. Once all the modules have been converted to a
java_sdk_library then we can resolve the limitations in the build and
remove the direct references to <module>.impl.

Test: m update-api
Bug: 155164730
Merged-In: If5c115f482751f9f4b5f047e9e401a18e36799ef
Merged-In: Id1c2e848430c49a2da7402244814cd084f5da77c
Change-Id: Id1c2e848430c49a2da7402244814cd084f5da77c
2020-05-28 13:14:52 +00:00
Paul Duffin
6216a6904e Merge "Switch framework-tethering to use java_sdk_library" into rvc-dev am: 5e988a656f
Change-Id: Icf8a3b8eed7e85065d54f2f48d8cb6f05974de00
2020-05-28 13:09:48 +00:00
Paul Duffin
cbac8e0b63 Switch framework-tethering to use java_sdk_library
The names of the individual modules do not quite follow the pattern
that java_sdk_library uses so this temporarily sets the following:
    naming_scheme: "frameworks-modules"

That causes java_sdk_library to use a naming scheme that matches the
one used by the individual modules of this. It will be cleaned up
later.

Part of the purpose of the java_sdk_library is to hide the
implementation code and force users of the library to depend on stubs
for a well defined API. Ideally, it would allow access to the
implementation in those cases where it is safe, e.g. from within the
same APEX, or from tests for the implementation. Unfortunately, due to
limitations in the build it does not yet have enough information to
make that decision correctly which means that any code that needs to
compile against the implementation is broken which would prevent us
from converting the module to java_sdk_library.

However, the only way to provide the additional information to allow
the implementation to be correctly exposed is to convert the modules
to java_sdk_library; a cycle.

In order to break that cycle the java_sdk_library creates a special
<module>.impl target which is used directly by tests and any other code
that needs it. Once all the modules have been converted to a
java_sdk_library then we can resolve the limitations in the build and
remove the direct references to <module>.impl.

Test: m Tethering InProcessTethering checkapi
Bug: 155164730
Merged-In: If5c115f482751f9f4b5f047e9e401a18e36799ef
Change-Id: Id1c2e848430c49a2da7402244814cd084f5da77c
2020-05-28 12:50:04 +01:00
paulhu
6c633de59e Use Class#getSimpleName instead of KClass#getSimpleName
KClass#getSimpleName need refer to kotlin-reflect.jar which need
include it in Andorid.bp. However, it's not necessary to use
KClass#getSimpleName but use Class#getSimpleName instead.

Test: atest TetheringTests
Bug: 157527499
Change-Id: I49bc336a276d30152402eba926cc583bc81e8e5c
2020-05-28 19:17:45 +08:00
Treehugger Robot
9c9c600c16 Extend timeout for requesting tethered interface
Extend the timeout to lower the EthernetTetheringTest flaky.

Besides, also explicitly exempt entitlement check in
EtetherntTetheringTest because it do not test tethering upstream
currently. Thus, the tests would not be interrupted by entitlement
check if test SIM is entitlement required.

Bug: 156713866
Test: TetheringCoverageTests, CtsTehteringTest

Merged-In: I45e8e8d737486def9d0de8943ec7f09ca0942a0b
Change-Id: I45e8e8d737486def9d0de8943ec7f09ca0942a0b
2020-05-28 09:17:28 +00:00
Treehugger Robot
99466515f8 Merge "Extend timeout for requesting tethered interface" am: 95386f9ebd am: 0c71ef1a6f
Change-Id: I577127f79391a4859dc7324b8cc47729a807a165
2020-05-28 08:50:08 +00:00
Treehugger Robot
95386f9ebd Merge "Extend timeout for requesting tethered interface" 2020-05-28 08:19:10 +00:00
markchien
908518d8e2 Extend timeout for requesting tethered interface
Extend the timeout to lower the EthernetTetheringTest flaky.

Besides, also explicitly exempt entitlement check in
EtetherntTetheringTest because it do not test tethering upstream
currently. Thus, the tests would not be interrupted by entitlement
check if test SIM is entitlement required.

Bug: 156713866
Test: TetheringCoverageTests, CtsTehteringTest

Change-Id: I45e8e8d737486def9d0de8943ec7f09ca0942a0b
2020-05-28 12:13:14 +08:00
markchien
c9daba32f7 Tethering: ensure downstream prefix do not conflict with upstream
- Add New class PrivateAddressCoordinator to coordinate the private
  address conflict problem.
- Downstream prefix would be random in 192.168.0.0/24 ~
  192.168.255.0/24.
- If new upstream prefix is conflict with existing downstream prefix,
  downstream would be kicked out and it would request a new one.
- The last conflict upstream prefixes would be blacklist. Avoid to
select downstream prefix which is conflict with prefixes in blacklist.

Bug: 130879722
Test: -build, flash, boot
      -atest TetheringTests

Change-Id: Ib45b87bcd9eeb5da03fb7ec90b1af9ca53998cf5
2020-05-27 21:36:01 +08:00
Treehugger Robot
369fd25f79 Remove platform cert from Tethering tests
Bug: 156866746
Test: atest TetheringTests, TetheringCoverageTests
Merged-In: I7c539f1f4a447b5913164b222601c6113c6fe645
Change-Id: I7c539f1f4a447b5913164b222601c6113c6fe645
2020-05-27 09:27:27 +00:00
Treehugger Robot
b4d272b13e Merge "Remove platform cert from Tethering tests" am: a5e8d3f73d am: e88c5146da
Change-Id: I51317f3769d60393a21ced8a194f253f97ef9ffd
2020-05-27 04:17:44 +00:00
markchien
e79e02e5c4 Remove platform cert from Tethering tests
Bug: 156866746
Test: atest TetheringTests, TetheringCoverageTests
Change-Id: I7c539f1f4a447b5913164b222601c6113c6fe645
2020-05-26 09:31:16 +08:00
Mark Chien
cd309138ce Adjust TTL for ipv6 tethering
If upstream is cellular, set the TTL in Router Advertisements to
"network-set TTL - 1" for carrier requirement. For other non-cellular
upstream, set TTL as "network-set TTL + 1" to preventing arbitrary
distinction between tethered and untethered traffic.

Bug: 154776299
Test: atest TetheringTests

Merged-In: I7f2696a642f96c6aafb5613b980bf5bcdd08bbda
Change-Id: I7f2696a642f96c6aafb5613b980bf5bcdd08bbda
2020-05-25 13:27:35 +00:00
Mark Chien
5026370372 Merge "TetheringServiceTest: test caller permission" into rvc-dev 2020-05-25 10:40:03 +00:00
markchien
5232658de2 TetheringServiceTest: test caller permission
Bug: 154869719
Test: atest TetheringTests
Original-Change: https://android-review.googlesource.com/1288503

Fix TetheringServiceTest test WRITE_SETTINGS permission failure

AdoptShellPermissionIdentity can not pass permission check by
Settings#checkAndNoteWriteSettingsOperation. It would compare the caller
uid and its package name. See error below:
1. java.lang.SecurityException:
Specified package com.android.shell under uid 10239 but it is really 2000
2. java.lang.SecurityException:
uid 10245 does not have android.permission.UPDATE_APP_OPS_STATS.

Override the method and test if caller hold WRITE_SETTINGS directly.

Bug: 154869719
Test: TetheringTests, TetheringCoverageTests, NetworkStackNextTests,
NetworkStackCoverageTests
Original-Change: https://android-review.googlesource.com/1313806

Change-Id: I7beea3f011d930e433443ed62d772a3f8cce5d78
Merged-In: I7beea3f011d930e433443ed62d772a3f8cce5d78
2020-05-25 12:07:06 +08:00