Commit Graph

739 Commits

Author SHA1 Message Date
Hungming Chen
0a7c8f1ec0 [BOT.5] Move class Ipv6ForwardingRule from IpServer to the coordinator am: b150b87fa9 am: b0f59dbbdf
Original change: undetermined

Change-Id: I3b54b2e2c0f9353367c6a096ccfebf17a47f5bc6
2020-06-02 00:13:45 +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
e5682257be [BOT.1] Add a class ForwardedStats in TetheringUtils am: d0216998a4 am: e624037dd3
Original change: undetermined

Change-Id: Ia1847c5b25a429b16ce1d2bae265b299ec31a8a9
2020-06-02 00:13:20 +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
Maciej Żenczykowski
b5898ad53a Stop reducing RA advertised ipv6 mtu by 16 - not needed.
This effectively reverts:

  commit da0fb1bca8
  Author: Maciej Żenczykowski <maze@google.com>
  Date:   Wed Feb 19 01:24:39 2020 -0800

      Reduce advertised ipv6 mtu by 16 to fit ethernet header

      This is a temporary hack to workaround the inability of current
      kernel's ebpf bpf_skb_change_mode() function to prefix a 14-byte
      ethernet header on to a packet without going over the upstream
      (source, rawip) interface's mtu *before* we bpf_redirect() to
      the downstream (destination, ethernet) interface.

      Test: build, atest, atest TetheringTests
      Bug: 149816401

Test: flashed a flame with new kernel and it works at 1500 mtu
Bug: 149816401
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I76a75a16fa27b47d78816b2f9379ef4bb68beb00
2020-05-30 03:04:11 +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
b150b87fa9 [BOT.5] Move class Ipv6ForwardingRule from IpServer to the coordinator
This is a preparation for moving adding/removing forwarding rules from
IpServer to BpfCoordinator.

Bug: 150736748
Test: atest IpServerTest
Change-Id: I85316ef09ff3c9389ded11dcc384493d699da48e
2020-05-29 20:23:40 +08: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
Hungming Chen
d0216998a4 [BOT.1] Add a class ForwardedStats in TetheringUtils
Used to record offload transmitted/received forwarded bytes/packets.

Bug: 150736748
Test: new test BpfTetheringCoordinatorTest
Change-Id: Ie8725f95c3ddd5fb3811d479de32d2c1f7dcb493
2020-05-29 20:23:14 +08: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
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
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
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
Mark Chien
916f0d9420 Merge "Adjust TTL for ipv6 tethering" am: 6d0a178a6b am: 23450e1fd1
Change-Id: I73c02d9ad80080a76e8d04d1d61467b434a68732
2020-05-25 02:04:59 +00:00
Mark Chien
6d0a178a6b Merge "Adjust TTL for ipv6 tethering" 2020-05-25 01:42:36 +00:00
markchien
d63c4f35de 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

Change-Id: I7f2696a642f96c6aafb5613b980bf5bcdd08bbda
2020-05-24 22:52:44 +08:00
Tyler Wear
6b94c31626 tethering: offload: Netlink Req
Send netlink request over fd for offload config before
completing init sequence. Provides existing conntrack
entries to IPA. Resolves issue where there are NAT
misses in IPA due to IPA only having the conntrack
entries added after tethering starts.

Bug: 149109043
Test: OffloadHardwareInterfaceTest
Change-Id: Iaf3e847e92f205b55f10fa85c17b9f3995d52099
2020-05-22 16:21:11 +00:00
Mark Chien
0454f82509 Merge "Fix TetheringServiceTest test WRITE_SETTINGS permission failure" am: 7e8b14abee am: b46dcf8317
Change-Id: I82825eeded51f779325291cc1142cb1d6111915b
2020-05-21 08:31:37 +00:00
markchien
f4394e83f8 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

Change-Id: I2a60c4d66ef30028f9663159f85464ea815248e2
2020-05-20 16:56:33 +08:00
Xiao Ma
654013479b Support MirrorLink DHCPDECLINE.
Add the specific implementation of onNewPrefixRequest callback
on IpServer side, also refactor some common code.

Bug: 130741856
Test: atest TetheringTests
Merged-In: If2871bf899cb5890bbfee18063a194c92b6f474e
Change-Id: If2871bf899cb5890bbfee18063a194c92b6f474e
2020-05-18 14:23:13 +00:00
Treehugger Robot
91b2bda682 Fix READ_DEVICE_CONFIG permission denied problem in TetheringTests
Bug: 156557122
Test: atest TetheringTests

Merged-In: Id9c0397306f3872fc23520d1354f338035a96dc9
Change-Id: Id9c0397306f3872fc23520d1354f338035a96dc9
2020-05-14 17:16:39 +00:00
Treehugger Robot
dd8e64609a Merge "Fix READ_DEVICE_CONFIG permission denied problem in TetheringTests" am: fb2caff580 am: 61aba704a9
Change-Id: I246e4f0d90e95418cbf55db5b802997faf4eae66
2020-05-14 16:33:30 +00:00
Treehugger Robot
fb2caff580 Merge "Fix READ_DEVICE_CONFIG permission denied problem in TetheringTests" 2020-05-14 16:00:27 +00:00
markchien
74174690d1 Fix READ_DEVICE_CONFIG permission denied problem in TetheringTests
Bug: 156557122
Test: atest TetheringTests

Change-Id: Id9c0397306f3872fc23520d1354f338035a96dc9
2020-05-14 16:42:22 +08:00
Xiao Ma
cad22f9192 Merge "Support MirrorLink DHCPDECLINE." am: cc755bf9fc am: b80b1e09bc
Change-Id: I415ba816492a329d5632e49025284d700b3c14da
2020-05-14 06:52:59 +00:00
Xiao Ma
cc755bf9fc Merge "Support MirrorLink DHCPDECLINE." 2020-05-14 06:27:16 +00:00
Mark Chien
73260a5564 Merge "Make members final in TetheringService" into rvc-dev 2020-05-14 05:48:24 +00:00
Treehugger Robot
7e2180f019 Merge "Make members final in TetheringService" 2020-05-13 16:04:58 +00:00
markchien
bd2cbe6c73 Make members final in TetheringService
1. Move isTetheringSupport logic from TetheringService to Tethering.
2. Small readability improvement in TetheringTest. Also change
config_tether_upstream_automatic from false to true in TetheringTest.
So TetheringTests would default run automatic select upstream flow
instead of selecting by legacy perferred network type list.

Bug: 153609486
Test: atest TetheringTest
Change-Id: I5a82a6347f62d3a7031db5c56e8e0c8530dafd8f
Merged-In: I5a82a6347f62d3a7031db5c56e8e0c8530dafd8f
(cherry picked from commit 569870320a)
2020-05-13 15:07:00 +00:00
Nucca Chen
8517d037e5 Merge "A minor followup change for BPF offload device option stuff" into rvc-dev 2020-05-13 14:58:34 +00:00
Xiao Ma
4455d6b1bd Support MirrorLink DHCPDECLINE.
Add the specific implementation of onNewPrefixRequest callback
on IpServer side, also refactor some common code.

Bug: 130741856
Test: atest TetheringTests
Change-Id: If2871bf899cb5890bbfee18063a194c92b6f474e
2020-05-13 23:29:49 +09:00
markchien
c96e106d68 Make members final in TetheringService
1. Move isTetheringSupport logic from TetheringService to Tethering.
2. Small readability improvement in TetheringTest. Also change
config_tether_upstream_automatic from false to true in TetheringTest.
So TetheringTests would default run automatic select upstream flow
instead of selecting by legacy perferred network type list.

Bug: 153609486
Test: atest TetheringTest
Change-Id: I5a82a6347f62d3a7031db5c56e8e0c8530dafd8f
Merged-In: I5a82a6347f62d3a7031db5c56e8e0c8530dafd8f
2020-05-13 22:12:15 +08:00
markchien
1da5f7d499 Make members final in TetheringService
1. Move isTetheringSupport logic from TetheringService to Tethering.
2. Small readability improvement in TetheringTest. Also change
config_tether_upstream_automatic from false to true in TetheringTest.
So TetheringTests would default run automatic select upstream flow
instead of selecting by legacy perferred network type list.

Bug: 153609486
Test: atest TetheringTest
Change-Id: I5a82a6347f62d3a7031db5c56e8e0c8530dafd8f
Merged-In: I5a82a6347f62d3a7031db5c56e8e0c8530dafd8f
2020-05-13 12:25:15 +00:00
Maciej Żenczykowski
fd8b4bbe35 A minor followup change for BPF offload device option stuff
- Correct description and spelling in the code and xml files.
- Add a TODO for refactoring the IpServer constructor.
- Refine the if-statement for starting IP neighbor monitor.

Bug: 149997301
Test: atest IpServerTest
Original-Change: https://android-review.googlesource.com/1309273
Merged-In: If9c8bc6f785fa80575db56de4e223292e9807ace
Change-Id: If9c8bc6f785fa80575db56de4e223292e9807ace
2020-05-13 10:06:47 +00:00
Mark Chien
7c23d31127 Add test for OffloadHardwareInterface
Bug: 145490751
Test: atest TetheringTests

Merged-In: Ia402a6caaa0dfaa05d25a02101c515bbd884d33f
Change-Id: Ia402a6caaa0dfaa05d25a02101c515bbd884d33f
2020-05-13 10:06:26 +00:00
Nucca Chen
0bbfe12d92 Add tether BPF offload config to device config and resource
The tether bpf offload can be enabled by resource config and
device config. The device config has higher priority and it
could override this config which is set by resource config.

Bug: 149997301
Test: -build, flash, boot
      -atest TetheringConfigurationTest
Original-Change: https://android-review.googlesource.com/1276007

Use device option to control BPF offload features

If BPF offload device config is not enabled:
- Does not add/remove offload forwarding rules through disabling IP
  neighbor monitor.
- Does not apply the RA MTU reduction.

Bug: 149997301
Test: atest IpServerTest
Original-Change: https://android-review.googlesource.com/1284578
Merged-In: I2d6f80f0229f580c4b16243a064e889a6c37f77a
Change-Id: I2d6f80f0229f580c4b16243a064e889a6c37f77a
2020-05-13 09:41:31 +00:00
Mark Chien
2de076ce41 Merge "Add test for OffloadHardwareInterface" am: 37b52321ee am: 9f6a0496d2
Change-Id: I0e6939d5983c87f6e47d9f4cb398aa2e2ef00818
2020-05-13 09:13:59 +00:00
Mark Chien
37b52321ee Merge "Add test for OffloadHardwareInterface" 2020-05-13 08:39:32 +00:00
markchien
bcaf0d61ce Add test for OffloadHardwareInterface
Bug: 145490751
Test: atest TetheringTests

Change-Id: Ia402a6caaa0dfaa05d25a02101c515bbd884d33f
2020-05-13 14:36:42 +08:00
Maciej Żenczykowski
f243a65531 Merge "A minor followup change for BPF offload device option stuff" am: 88536883e2 am: 03c8d55456
Change-Id: Ia148434de4f497e2e90b207845ee037a65c98a02
2020-05-12 19:04:39 +00:00
Nucca Chen
2cc2f3b424 Merge changes I2d6f80f0,I9c26852d am: 50522024a1 am: 6151bb7aed
Change-Id: I52c3ba5b46dc6e52307f68c9201fc19b0a368a09
2020-05-12 11:34:28 +00:00
Hungming Chen
5bc3af9a57 A minor followup change for BPF offload device option stuff
- Correct description and spelling in the code and xml files.
- Add a TODO for refactoring the IpServer constructor.
- Refine the if-statement for starting IP neighbor monitor.

Test: atest IpServerTest
Change-Id: If9c8bc6f785fa80575db56de4e223292e9807ace
2020-05-12 19:15:24 +08:00
Nucca Chen
50522024a1 Merge changes I2d6f80f0,I9c26852d
* changes:
  Use device option to control BPF offload features
  Add tether BPF offload config to device config and resource
2020-05-12 11:00:04 +00:00
markchien
dc3b82db70 Allow to exempt from entitlement check
To exempt from entitlement check, caller need to hold TETHER_PRIVILEGED
permission.

Bug: 141256482
Test: atest TetheringTests

Change-Id: I2eb37f5e92f5f5150a7fb7c25b945e28704d27a0
Merged-In: I2eb37f5e92f5f5150a7fb7c25b945e28704d27a0
2020-05-08 23:13:30 +08:00
Mark Chien
fa0384ea72 Merge "Allow to exempt from entitlement check" am: 469314ecc8 am: ec7cf5e356
Change-Id: I34a405492bd2e80aa731e5ac5d56034f7a80cd45
2020-05-08 12:47:48 +00:00
Mark Chien
0dafa92b93 Address the comment of aosp/1288493
Bug: 141256482
Test: atest TetheringTests
Merged-In: I0cf337625cee31a47879c59e9b18657ea7624eb4
Change-Id: I0cf337625cee31a47879c59e9b18657ea7624eb4
2020-05-08 11:57:57 +00:00