Commit Graph

739 Commits

Author SHA1 Message Date
Hungming Chen
67c14b549f [NFCT.TETHER.5] Migrate tetherOffloadSetInterfaceQuota from netd to mainline
A preparation for updating BPF map in mainline module.

Test: atest TetheringCoverageTests
Change-Id: I67dfba750c7303e4aeaf65f5086db1290d176b4d
2021-01-15 18:40:48 +08:00
Hungming Chen
5ea9c4b64a [NFCT.TETHER.4] Migrate tetherOffloadRuleRemove from netd to mainline
A preparation for updating BPF map in mainline module.

Test: atest TetheringCoverageTests
Change-Id: I969d6182a307f46c8ed0a30960deb460ecedd8ea
2021-01-15 18:40:40 +08:00
Hungming Chen
b350d7589f [NFCT.TETHER.3] Migrate tetherOffloadGetStats from netd to mainline
A preparation for updating BPF map in mainline module.

Test: TetheringCoverageTests
Change-Id: Ie73f7b4d9b191e62cfdfe2cfa3360cc7210f17e8
2021-01-15 17:11:12 +08:00
Hungming Chen
dd55b91228 [NFCT.TETHER.2] Migrate tetherOffloadRuleAdd from netd to mainline
A preparation for updating BPF map in mainline module.

Test: atest TetheringCoverageTests
Change-Id: I6f8667bf110dae3e2805c2752ff59e7284a7bce0
2021-01-15 17:10:58 +08:00
Hungming Chen
7d05e6fddd Follow-up CL to the change at aosp/1498277
1. Correct the API annotation.
2. The entry deletion failure causes the exception in cleanTestMap().
3. Use AtomicInteger to be the counter in the lambda.

Test: atest BpfMapTest
Change-Id: I4a56038881a38bda993ef5303b71f0e2a99f03d1
2021-01-12 19:08:15 +08:00
Nucca Chen
12067258b2 Merge "Provide a easy way to access bpf maps from java" 2021-01-12 08:06:03 +00:00
markchien
7052688dde Provide a easy way to access bpf maps from java
A wrapper for bpf map opening, reading/writing, and iteration.

Bug: 173167302
Test: atest BpfMapTest

Change-Id: I792b41978b322c9e4969cd7b6c35d6978ab86bc4
2021-01-11 17:43:27 +08:00
lucaslin
ee661dfb59 Move BaseNetdUnsolicitedEventListener to frameworks/libs/net
Move BaseNetdUnsolicitedEventListener to frameworks/libs/net and
create a new library - netd-client for using.
Also remove netd_aidl_interface-unstable-java since netd-client
links to the stable one.

Bug: 174837473
Test: Manual test and check the log.
Change-Id: Id65142b8c13a6cccbfe387d4ab757967497546e6
2021-01-08 01:55:53 +00:00
markchien
c233b1807e Put tether/untether calls into handler queue
BT tethering is the only user of #tether and #untether API.
Enable BT tethering may fail by race between interface status change
and #tether call. In starting BT tethering flow, tethering may receive
pan interface DOWN and UP then PanService call #tether to request for
processing its pan interface. Tethering put interface status change
event into handler queue but it process #tether and #unether calls
right away without order them by queue. It makes tethering handle
binder call #tether before pan interface DOWN even DOWN event arrived
eailer. This cause BT tethering bring down by interface DOWN event
unexpectedly. Although this still can't fix all the race cases of
tethering, but at lesat this could fix the race mentioned above.

Bug: 173310882
Test: manual ON/OFF bt tethering
      atest TetheringTests

Change-Id: I2411378aa36ad4371cca12423bb65542cb8df7a1
2020-12-29 01:04:17 +08:00
Treehugger Robot
561f38a799 Merge "Also update connected clients for local only tethering" 2020-12-23 11:36:34 +00:00
markchien
f50f05ebcb Also update connected clients for local only tethering
mForwardedDownstreams is the set of downstreams who wanted upstream.
In other word, it don't contains localOnly tethering(e.g. local only
hotspot, wifi p2p tethering). Changing the list from mForwardedDownstreams
to mNotifyList make both tethered and localOnly tethering have connected
clients callback.

Bug: 172290164
Test: atest TetheringTests
Change-Id: I58fdb28efc616b00d63a1c237ea93aee4d8f2dcd
2020-12-22 23:23:09 +08:00
Chalard Jean
d2df5729f6 Move module utils to the module package.
Test: FrameworksWifiTest FrameworksNetTest
Merged-In: Ib04bebb061dc64d6d685116b596fb3179d5b959a
Change-Id: I9118da3898d864c7bf0ed7bc9d94b94343c4a084
2020-12-16 11:44:34 +09:00
paulhu
862c8a1ea0 Fix tethering doesn't turn off issue
When user restriction turns on, all tethering functions should
be disabled. But tethering functions still work after
restrication is on. Because tethering request would be removed
from mActiveTetheringRequests after starting tethering that
will result in Tethering#isTetheringActive() always returns
false. Thus, update the design to check tethered interface to
ensure that any of tethering function is working.

Bug: 169596583
Test: atest TetheringTests
Test: Manually test that tethering function would be disabled
      and notification would show to user after restriction
      was on.
Change-Id: Icb9649a5ecdec2d029ac763b5b9b80042ad50eb9
2020-11-10 16:47:52 +08:00
markchien
4607c5535b Add the flag and default enable selectAllPrefixRange
Also add MtsTetheringTest which only run if tethering mainline
module is installed.

Bug: 166057846
Bug: 170265597
Test: atest TetheringTests
Change-Id: I434dda81eb5fab700d873a8ff3429b4222f0c7e6
2020-10-19 16:50:29 +08:00
markchien
634f0a8ec1 Fix miss tracking downstream problem in PrivateAddressCoordinator
The downstream do not be tracked if PrivateAddressCoordinator just
return cached address. Then, PrivateAddressCoordinator would not notify
that downstream if conflict happen.

Also remove the null check in getDownstreamPrefix because:
- An IpServer is only added to mDownstreams by requestDownstreamAddress.
- That method will only add the IpServer to mDownstreams if it has an
IPv4 address.
- As soon as that method returns, the IpServer sets mIpv4Address to the
address that was returned.
- When an IpServer is torn down, mIpv4Address is set to null after
releaseDownstream is called.

So it should never be possible for this to return null.

Bug: 168169687
Test: atest CtsTetheringTest
      atest TetheringTests
Change-Id: Ide5206b013acdc499344e1c839a830c5b245af41
2020-10-15 16:21:12 +08:00
markchien
d9acdccbd3 Allow tethering pick prefix from all of private address range
Currently tethering only pick prefix from 192.168.0.0/16. There is no
aviable tethering address if the upstream address is 192.168.x.y/16.
This change allow tethering to pick prefix from any private address
rnages. Now it still pick from 192.168.0.0/16 only to avoid behavior
change. Will have follow up commit to change the configuration.

Bug: 166057846
Bug: 170265597
Test: atest TetheringTests
      atest CtsTetheringTest

Change-Id: Ib6304eb8b4788e9196d0af48e72f00a6bda73a5f
2020-10-13 16:45:09 +08:00
markchien
a2ffad84c7 Make the IP subnet persistent till reboot
Make the IP subnet persistent if it do not conflict with upstream.
It allow client to reuse its IP that usually reduce DHCP procedure.

Bug: 168169687
Test: atest TetheringTests
Change-Id: Iddc5304730dce7b11c5d124b7eddce057d752bbd
2020-10-06 20:25:19 +08:00
Treehugger Robot
0b1e7d8956 Merge "Make PrivateAddressCoordinator ignore vpn network" 2020-10-05 04:10:48 +00:00
Tyler Wear
7f70074abc tethering: offload: Netlink Req NfGen
Add the netfilter generic message header to
the netlink req. This is needed so the kernel
won't ignore the request for invalid params.

Bug: 149109043
Test: ConntrackSocketTest
Change-Id: I1757fdeb11a0cac5821021a22323cbd74fe22bdc
2020-09-30 15:07:47 +09:00
markchien
1a2163b972 Make PrivateAddressCoordinator ignore vpn network
If vpn app make its netmask as 0, PrivateAddressCoordinator
would not able to find suitable address for tethering downstream.
Since tethering do not support vpn as upstream, just ignore vpn
in PrivateAddressCoordinator.

Bug: 166365863
Test: atest TetheringTests
      atest CtsTetheringTest
Change-Id: Iabe265467044fea9fa437674ca29ffc7bcdefe3b
2020-09-28 17:22:19 +08:00
Treehugger Robot
18ee591257 Merge "Fix TetheredClient callback fail in InProcessTethering" 2020-09-28 08:53:53 +00:00
markchien
84ec4a397a Fix TetheredClient callback fail in InProcessTethering
TetheredClient callback would additional check whether caller has
NETWORK_SETTINGS or {MAINLINE_}NETWORK_STACK permission, but it do not
grant for self accessing. InProcessTethering run in system server, so
the services in system server would fail to call TetheredClient callback.
Grant permission for self process.

Bug: 169231588
Test: atest CtsTetheringTest
Change-Id: Ic04e44aef4df772c718ff25ed331bf02f5940c1d
2020-09-24 10:11:51 +08:00
Remi NGUYEN VAN
72e81859f8 Merge "tethering: DAD Proxy Daemon" 2020-09-23 04:57:42 +00:00
Tyler Wear
90e4063fd2 tethering: DAD Proxy Daemon
DAD proxy daemon responsible for forwarding NS/NA between
tethered iface and upstream iface.

Change-Id: I2e58e10e7fa7dba6a6f63ad03b000549f3afc37e
2020-09-22 11:58:49 -07:00
Xin Li
82a71b8f72 Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507
Merged-In: I3d92a6de21a938f6b352ec26dc23420c0fe02b27
Change-Id: Ifdb80563ef042738778ebb8a7581a97c4e3d96e2
2020-08-31 21:21:38 -07:00
Chalard Jean
827a8abfb5 Revert "Revert "Move Inet[4]AddressUtils to libs/net"" am: 78701646dd
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1382497

Change-Id: Ia5e7e926bc3a9af8b03f8970738e6abe4c6d15b6
2020-08-07 06:59:26 +00:00
Chalard Jean
78701646dd Revert "Revert "Move Inet[4]AddressUtils to libs/net""
This patch is still needed and should go in now that the
error is fixed.
The patch was submitted into rvc-dev and is already in
rvc-dev-plus-aosp (patch in in ag/11923559, revert
skipped in ag/12072199). A follow-up will remove the
unused services.net-module-wifi target.

Test: originally tested in aosp/1324109
Test: m; manual: flashed, wifi and telephony working
Test: atest NetworkStackCoverageTests
Change-Id: I1074eedb0b0f156a1135e11210ec102de15ea674
Merged-In: Icd141a992c46290c74929785e261a1cd57bc001b
2020-08-07 03:31:04 +00:00
Mark Chien
d2af4d9e2a Merge "Allow wifi p2p to use legacy dedicated address" 2020-08-05 06:01:37 +00:00
markchien
eb8fec2111 Allow wifi p2p to use legacy dedicated address
Some exsting applications may expect wifi p2p use legacy
"192.168.49.1/24" address. Have a configuration for wifi p2p to
decide whether to use legacy dedicated address or random address.

Bug: 161520826
Test: atest TetheringTests
Change-Id: If79973416a6780ee19ee785c65772b1a2dc1fbf7
2020-08-05 11:03:46 +08:00
Chiachang Wang
e66098036f Merge "Update language to comply with Android's inclusive language guidance" 2020-07-30 02:49:44 +00:00
Chiachang Wang
14aaefcb12 Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code
for reference.

Test: m ; atest TetheringTests
Bug: 161896447
Change-Id: Idc58697c72fb00896bee00185fefc50c1a24dd35
2020-07-29 12:05:04 +08:00
markchien
af2670f427 Always stop dhcp server even it is obsolete
If dhcp server is obsolete, explicitly stop it to shut down its thread.

Bug: 161418295
Test: atest CtsTetheringTest
Change-Id: Ic5b876bd23711ec8d832879a7baee0495246b218
2020-07-29 09:55:29 +08:00
Chalard Jean
6b66d70ba1 Revert "Move Inet[4]AddressUtils to libs/net"
This reverts commit cf86031c12.

Reason for revert: Breaks the build b/160390899

Merged-In: Icd141a992c46290c74929785e261a1cd57bc001b
Change-Id: Ie10e66f61393602f17fbb61bf17230b176bf1f44
2020-07-02 23:47:35 +00:00
Remi NGUYEN VAN
cf86031c12 Move Inet[4]AddressUtils to libs/net
The classes should not be picked up from frameworks/base, as they are
part of several mainline modules.

Also refine comments in DhcpResults following feedback in previous
change.

(cherry-pick from internal branch skipping wifi classes; no other
conflict)

Bug: 151052811
Test: m; manual: flashed, wifi and telephony working
Test: atest NetworkStackCoverageTests
Merged-In: I7074651c6a2a7a6b11bcf13cc4bb03833d7d655f

Change-Id: I7074651c6a2a7a6b11bcf13cc4bb03833d7d655f
2020-07-02 10:52:31 +09:00
Paul Hu
b6958b47d9 Merge "Correct PendingIntent#getActivity() flags" am: 6b2b4e6514 am: 7a87bc4742
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1329013

Change-Id: I67e2d4facd77f978255a10423a9baff231ac0695
2020-06-29 12:17:07 +00:00
Paul Hu
6b2b4e6514 Merge "Correct PendingIntent#getActivity() flags" 2020-06-29 11:53:18 +00:00
paulhu
67aeab2eee Correct PendingIntent#getActivity() flags
TetheringNotificationUpdater create a PendingIntent with
Intent#FLAG_ACTIVITY_NEW_TASK flag. But this flag is used for
Intent only. Thus, move this flag into Intent.

Bug: 158639789
Test: atest TetheringTests
Change-Id: I4c3af75c87b797bcde9356a94c835c7422dac1c6
2020-06-29 00:32:19 +08:00
Lorenzo Colitti
4d2944cda4 Merge "tethering: offload: Netlink Req" am: b90c974174 am: d45fd82ad0
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1290954

Change-Id: I5f976d70d87ef25ebb8e1483532781ac3d42425b
2020-06-24 03:44:31 +00:00
Lorenzo Colitti
b90c974174 Merge "tethering: offload: Netlink Req" 2020-06-24 03:11:26 +00:00
Mark Chien
fdf89ee7fb Merge "Tethering: Add WiGig support" am: 65fadfc134 am: 6c5b5b0803
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1177323

Change-Id: Ib48182d51cc6e4586cb43f8ca51ea673ee14d1d7
2020-06-22 23:43:43 +00:00
Dedy Lansky
6896f6193f Tethering: Add WiGig support
This change is a combination of following changes:

1) Tethering: add TETHERING_WIGIG type
   Currently both WIFI and WIGIG use the same tethering type,
   TETHERING_WIFI. This causes conflicts between the frameworks,
   when both WIFI and WIGIG SoftAPs are started, one or both will
   not work.
   Fix this by using a seperate tethering type for WIGIG.

2) Tethering: remove TETHERING_WIGIG state machine on interface down
   The wigig state machine relies on a TETHERING_STATE_CHANGED broadcast
   that is sent when the tethering state machine is first created, during
   interface up. Currently the tethering state machine is not removed
   on interface down except for TETHERING_BLUETOOTH, and as a result
   wigig tethering only works the first time SoftAP is started.
   In order to fix this, remove the tethering state machine on interface
   down for TETHERING_WIGIG as well.

Bug: 143356416
Test: TetheringCoverageTests

Change-Id: Ic4d3aca0ed69234093af7f0206dab3335938c52a
2020-06-22 21:17:46 +08:00
markchien
4c9428a135 Protect invalid entitlement app configuration
There is a protection in Settings that Settings would gray out if
tethering requires entitlement check but the entitlement app is
invalid. Tethering resource is moved from framework to tethering
module, so Settings can not fetch entitlement app name anymore.

In this change, tethering module would check whether entitltement app
package name is exsited if entitlement check is needed. Tethering would
be not supported (Settings tethering option would be hidded) if
entitlement app is not installed.

After moving the protection into tethering module,
TetherUtil#isProvisioningNeeded is no longer needed. Because The
only use case is Settings wants to gray out tethering setting
when entitltement check is needed but entitlement app is invalid.

Bug: 146918263
Test: atest TetheringCoverageTests
Change-Id: I9a5ff5dbc1db3f3be7fcd7146862a16b373507e6
Merged-In: I9a5ff5dbc1db3f3be7fcd7146862a16b373507e6
2020-06-20 10:19:25 +08:00
markchien
902043f5c3 Pass entitlement configuration to Settings for entitlement check
Tethering resource configuration is move from framwork to tethering
module. Since tethering resource would not be accessible from outside
of tethering module, EntitlementManager would tell Settings the
entitlement configuration via intent extra when run entitlement check.

Bug: 146918263
Test: atest TetheringTests
Change-Id: I6f23553bb1da5f0b767f920b32a86fafb9e00b9e
Merged-In: I6f23553bb1da5f0b767f920b32a86fafb9e00b9e
2020-06-20 10:19:21 +08:00
Mark Chien
0d3aeb6139 Merge "Let only Ethernet manage ethernet interface up and down" am: ac8445ca3b am: eb4a072814
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1317394

Change-Id: Ifc233eff24c893ca542e75b683be0628eafba37f
2020-06-19 06:25:12 +00:00
Mark Chien
ac8445ca3b Merge "Let only Ethernet manage ethernet interface up and down" 2020-06-19 05:55:35 +00:00
Milim Lee
9807816e09 Let only Ethernet manage ethernet interface up and down
When LAN link is changed for using ethernet interface from Ethernet tethering to Ethernet,
there is confiict as Ethernet Tethering is trying to make ethernet link down and Ethernet is trying to make ethernet link up.

So, this would make Ethernet only manage ethernet interface link state.

Test: manual
Bug: 130840861
Change-Id: I1cd40ae764bdeecbb59e3889e9399b7f4b05f9cc
2020-06-19 12:44:22 +09:00
Remi NGUYEN VAN
2e342b8676 Merge "Move Inet[4]AddressUtils to libs/net" into rvc-dev am: e7afe55beb
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11846903

Change-Id: Icd141a992c46290c74929785e261a1cd57bc001b
2020-06-19 01:08:48 +00:00
Remi NGUYEN VAN
e7afe55beb Merge "Move Inet[4]AddressUtils to libs/net" into rvc-dev 2020-06-19 00:49:29 +00:00
Lorenzo Colitti
51229ef8f0 Merge "Memory leak due to no stop for IpNeighborMonitor." am: 4cc7532355 am: 1e488831bd
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1343440

Change-Id: Idef540bd66d193eb9b7071374736633c7d0323d7
2020-06-18 16:36:32 +00:00
h.zhang
d244bd097c Memory leak due to no stop for IpNeighborMonitor.
1. When Wi-Fi enabled, ap0 interface is added and IpNeighborMonitor's
   start() is invoked in IpServer's constructor.
2. There's no stop for IpNeighborMonitor when IpServer stop.
3. During overnight test for Wi-Fi, networkstack is too slow to
   process request due to memory leak in IpNeighborMonitor and
   binder buffer is blocked causing exception.
Solution: Invoke IpNeighborMonitor.stop() in UnavailableState.enter().

Bug: 159097215
Test: automatic, turn on and off Wi-Fi every 6 seconds overnight
Change-Id: I8f60c13706f05306e8f25a15f7861d7ecabbc10e
2020-06-18 23:51:16 +09:00