Commit Graph

722 Commits

Author SHA1 Message Date
Varun Anand
6cfd15e33e Remove ConnectivityManager and its usages from NetworkStatsService.
NSS needed it for getting VpnInfo[], NetworkState[] and
activeLinkProperties which it used to query via ConnectivityManager.

For VpnInfo[], this was racy as NSS may ignore intermediate changes to a
VPN's underlying networks. See http://b/123961098 for more context.

It may also lead to deadlocks b/w ConnectivityService and
NetworkStatsService. See http://b/126245192 for more info.

This change will ensure that NSS is never contending on any of
ConnectivityService locks.

Bug: 123961098
Bug: 126245192
Bug: 120145746
Test: atest FrameworksNetTests
Change-Id: I57e117bb4e9efe491b19d6b5a479f2d58d1c58e6
2019-02-28 13:43:02 -08:00
Remi NGUYEN VAN
a618134a1e Merge "Remove last NetworkStack usage of hidden APIs" am: 16ec5d038c am: e4675dcaab
am: ba3b82db1e

Change-Id: I2059d9cfa3015388301a74828255354b6dc23c23
2019-01-29 21:42:29 -08:00
Remi NGUYEN VAN
5db0919a0d Remove last NetworkStack usage of hidden APIs
Includes various small changes to stop using hidden APIs

Test: make NetworkStack
Test: flashed, booted, WiFi and tethering working
Bug: 112869080
Change-Id: Id2830795a444f484b377ed6437435a1cd833697a
2019-01-30 10:23:24 +09:00
Remi NGUYEN VAN
69281a355b Merge changes I1250730c,I7d00848c am: e693d49c0a am: fef17fd05f
am: ff1f9b78d4

Change-Id: Icc938491a9c4474cc27a4376ef03c954aac461b3
2019-01-23 09:01:09 -08:00
Remi NGUYEN VAN
63e61c427d Move IpClient to NetworkStack
Test: atest FrameworksNetTests NetworkStackTests
Bug: b/112869080
Change-Id: I7d00848c052382cd1b6ce458868bed6a1e9e8ec5
2019-01-23 16:44:21 +09:00
Mike SU
77c8591f9d fix getIfaceStats and getTotalStats bug
root cause: getIfaceStats and getTotalStats is directly reading
iface_stat_fmt or eBPF, not include tether stats.
solution: add tether stats to getIfaceStats and getTotalStats.

Clean cherry-pick of aosp/848934

Bug: 120039819
Test case1:
1. tether offload is enabled on phone, enable MHS on phone.
2. Use test app to check getMobileRxBytes->getIfaceStats
3. Download 10M file on MHS client
4. Use test app to check getMobileRxBytes->getIfaceStats again
result: getMobileRxBytes increased around 10M

Test case2:
1. tether offload is disabled on phone, enable MHS on phone.
repeat above step 2~4
result: getMobileRxBytes increased around 10M

Following CTS cases passed
run cts -m CtsNetTestCases --test android.net.cts.TrafficStatsTest
run cts -m CtsUsageStatsTestCases --test android.app.usage.cts.NetworkUsageStatsTest

Change-Id: I3d94acb71c142ec38b750e58822881ff383341cc
2019-01-21 20:55:06 +08:00
Mike SU
3657ce9690 fix getIfaceStats and getTotalStats bug
root cause: getIfaceStats and getTotalStats is directly reading
iface_stat_fmt or eBPF, not include tether stats.
solution: add tether stats to getIfaceStats and getTotalStats.

Bug: 120039819
Test case1:
1. tether offload is enabled on phone, enable MHS on phone.
2. Use test app to check getMobileRxBytes->getIfaceStats
3. Download 10M file on MHS client
4. Use test app to check getMobileRxBytes->getIfaceStats again
result: getMobileRxBytes increased around 10M

Test case2:
1. tether offload is disabled on phone, enable MHS on phone.
repeat above step 2~4
result: getMobileRxBytes increased around 10M

Following CTS cases passed
run cts -m CtsNetTestCases --test android.net.cts.TrafficStatsTest
run cts -m CtsUsageStatsTestCases --test android.app.usage.cts.NetworkUsageStatsTest

Change-Id: I3d94acb71c142ec38b750e58822881ff383341cc
2019-01-10 12:16:25 -06:00
Chenbo Feng
14c16b87a9 Merge "Adjust map names due to new bpfloader" am: 0317e9e374 am: 37cec67bdc
am: 50252f86f3

Change-Id: Iedbb541ba2fa5916048e3f40d5cc128a83d0dc6b
2019-01-09 11:34:54 -08:00
Chenbo Feng
37cec67bdc Merge "Adjust map names due to new bpfloader"
am: 0317e9e374

Change-Id: If97a15a7f7b6a066bbf46db3497270a8c9a81026
2019-01-09 10:53:22 -08:00
Treehugger Robot
0317e9e374 Merge "Adjust map names due to new bpfloader" 2019-01-09 18:34:49 +00:00
junyulai
579bf97659 DO NOT MERGE: Revert: use legacy way to get tcp packet count
In Q, legacy way to get tcp packet count is not planned to be
supported. Users who use this unsupported API e.g., data stall
detection are also planned to be removed.

Thus, this change reverts 0b4a66a1c2 which is the short term
solution in P.

Bug: 110443385
Test: atest FrameworksNetTests
Change-Id: Ia09f908edbf194b9aa873a3bdd5aee7b6fcb16bc
2019-01-09 10:38:32 +08:00
Chenbo Feng
150dc6f187 Adjust map names due to new bpfloader
With the new loader support added. The bpf map format is defined by bpf
kernel program as well. Change the netd bpf program to the new format.

Test: CtsUsageStatsTestCases
Bug: 112334572
Change-Id: I34e38e0a8cf0cca54dc52ec897771452f9d90525
2019-01-04 12:06:35 -08:00
Chenbo Feng
e817e16c32 Merge "Delete unused import" am: e726c2654d am: 76b4d2fba2
am: 6f97b16072

Change-Id: I577371244d45a3b93e3e5f4a02747a51fd42d363
2018-12-13 11:20:14 -08:00
Chenbo Feng
76b4d2fba2 Merge "Delete unused import"
am: e726c2654d

Change-Id: I8249bd4340b6e6e2e0a4fa687207198b534168b1
2018-12-12 22:18:40 -08:00
Treehugger Robot
ab3b396c45 Merge "DO NOT MERGE - Merge pie-platform-release (PPRL.181205.001) into master" 2018-12-13 05:45:20 +00:00
Chenbo Feng
f9eff38d9b Delete unused import
The hasBpfSupport() check from BpfUtils is not used by the native helper
in framework. Remove them.

Bug: 111441138
Test: Build without failure.
Change-Id: Icdd01bf1a03efd7883e4939d0d730303ec1004e7
2018-12-13 00:46:20 +00:00
Xin Li
6f9c73f8c9 DO NOT MERGE - Merge pie-platform-release (PPRL.181205.001) into master
Bug: 120502534
Change-Id: Idc8bfb6d97a869b76cfb87ca1a494201baf9e8bd
2018-12-11 14:13:44 -08:00
Xin Li
07ea8a407d DO NOT MERGE - Merge pie-platform-release (PPRL.181205.001) into stage-aosp-master
Bug: 120502534
Change-Id: I7351a1832c4bd2fd86324183ab83e9088d716822
2018-12-10 12:30:19 -08:00
Junyu Lai
83a52f5fb2 Merge "Refactoring of deleting stats in NetworkStats based on uids." am: c8dcfb8b4b am: 2d00948a0c
am: 2d79ef94f8

Change-Id: I29c57276424464afd54e184c369d30a5e9707f14
2018-12-10 03:10:15 -08:00
Junyu Lai
2d79ef94f8 Merge "Refactoring of deleting stats in NetworkStats based on uids." am: c8dcfb8b4b
am: 2d00948a0c

Change-Id: Icfe86f71f9416dcd5fcc9aafd8c346197cde7cff
2018-12-09 21:46:07 -08:00
Junyu Lai
c8dcfb8b4b Merge "Refactoring of deleting stats in NetworkStats based on uids." 2018-12-10 05:15:28 +00:00
junyulai
bbaddec5d7 Refactoring of deleting stats in NetworkStats based on uids.
In follow-up commits, current API would create new NetworkStats
every time when 464xlatAdjustment wants to filtered out some
uids.

This commit refactors it to delete stats in-place to get better
performance.

Bug: 118602783
Test: atest FrameworksNetTests
Change-Id: I858f95d1fa7733111786243b4e261ce8a70a068d
2018-12-06 19:01:17 +09:00
Luke Huang
1d7e968b14 Merge "Use ParcelFileDescriptor instead of FileDescriptor in INetd.aidl" am: d6c2dc5908 am: 7d5693279a
am: 0c54c1616d

Change-Id: I1dd010a0b4ec54c87b509c1e05185164fde9e4cb
2018-12-04 22:44:36 -08:00
Luke Huang
0c54c1616d Merge "Use ParcelFileDescriptor instead of FileDescriptor in INetd.aidl" am: d6c2dc5908
am: 7d5693279a

Change-Id: I8b89e88d1db96581ab91d649e5af621c499669ed
2018-12-04 22:35:32 -08:00
Luke Huang
d913fb44ad Use ParcelFileDescriptor instead of FileDescriptor in INetd.aidl
Stable aidl won't support FileDescriptor but ParcelFileDescriptor.
In order to migrate to stable aidl, replace all FileDescriptor in
INdetd.aidl.

Test: runtest frameworks-net passes
Change-Id: Icdf37aed0e0cce0352070a437066e77c0f2fd85a
2018-11-28 13:41:58 +08:00
Benedict Wong
a041d6fb80 Merge changes from topic "xfrmi-support" am: f928c1e4b9 am: 719761f60c
am: 0cfc49485c

Change-Id: I9c543d38c88181b12cdbc7bdb93d7e38f1dfd425
2018-11-25 19:38:35 -08:00
Benedict Wong
0cfc49485c Merge changes from topic "xfrmi-support" am: f928c1e4b9
am: 719761f60c

Change-Id: I13a826f5ae3c4cb700be789b369848685da1bc41
2018-11-25 19:26:26 -08:00
Benedict Wong
c6fcedd779 Cleanup and update comments SA mark disabling comments
This commit cleans up and upates comments with regard to changes in
aosp/721999, clarifying the restrictions and potential pitfalls we would
see with regards to IPsec tunnel mode without updatable SAs.

Bug: 111854872
Test: Compiles, comment-only change
Change-Id: I07b0063987463c1a3cf42e112839a31739947c80
2018-11-21 22:50:52 -08:00
Benedict Wong
5d74984c24 Add XFRM-I support to IpSecService
This change adds support for XFRM-I to all IpSecService netd calls.
Fallback logic is in netd, and thus both VTI and XFRM-I parameters are
always passed down to IpSecService.

Bug: 78589502
Test: All java, CTS tests passing
Change-Id: Ie4186f0ad7e50763b21831f6fa411b5ee436de78
2018-11-21 08:34:54 -08:00
Benedict Wong
683441d87a Disable attempted updating of SA marks
SA marks are never updated during the UPDSA call. This change disables
the attempts to update the specified SAs, ensuring that the config
stored in IpSecService matches that of the allocated kernel resources.

Bug: 111854872
Test: Unit, CTS tests passing
Change-Id: Ic1fb862c8021ffa260c3e262ec698d8af0a826d9
2018-11-21 08:34:54 -08:00
Junyu Lai
0ab82da19f Merge "Fix negative uid stats caused by 464xlat adjust when eBPF is on." am: 0d63da86e2 am: a38302f84f
am: fcb523e095

Change-Id: I9d0d8b67ed0159ba2a71059620ebe5698eb79ccb
2018-10-30 19:56:01 -07:00
Junyu Lai
fcb523e095 Merge "Fix negative uid stats caused by 464xlat adjust when eBPF is on." am: 0d63da86e2
am: a38302f84f

Change-Id: I3ee791e4b6fdd9d508807810183dc02c69bd2c0b
2018-10-30 19:46:18 -07:00
junyulai
7d412d0b46 Fix negative uid stats caused by 464xlat adjust when eBPF is on.
When using xt_qtaguid to count per uid stats,
NetworkStatsService needs to adjust the 464xlat traffic since
iptables module would double count for ipv4 and ipv6 packet.
But for eBPF, the per uid stats is collected in a different
hook, so the adjustment on root uid would only be needed in tx
direction.

Bug: 112226716
Test: 1. Make ipv4 traffic in ipv6-only network and check data
         usage.
      2. Make ipv4 traffic in a client which connect to
         ipv6-only hotspot.
      3. runtest frameworks-net
      4. cts-tradefed run cts -m CtsNetTestCases -t \
                 android.net.cts.TrafficStatsTest
      5. cts-tradefed run cts -m CtsUsageStatsTestCases

Change-Id: Ic9a84f5446eddc943c255d5f3b89dad171f53cac
2018-10-30 21:23:38 +08:00
Olivier Gaillard
ff57484594 Update a few runnable/handler to use a static class instead of a
runnable.

It will help collecting better data for handler stats (we can get a
fully qualified class name).

Test: tested manually
Change-Id: I674cf03909153fd87d97f600e246e04800cbb624
2018-10-24 10:18:35 +01:00
Chenbo Feng
9a7e9521fd Merge "Move bpf project to system/bpf" am: 1006d271cc am: d271be0e1c
am: e6278480b9

Change-Id: I4126f4e184975a387a82ada2b4f432cf20cabbb8
2018-10-18 09:13:56 -07:00
Chenbo Feng
e6278480b9 Merge "Move bpf project to system/bpf" am: 1006d271cc
am: d271be0e1c

Change-Id: I9c0592365844836dc644d6e090def32af3edf678
2018-10-18 08:12:41 -07:00
Chenbo Feng
4a259ab940 Move bpf project to system/bpf
The bpf project now have a new project directory in system/bpf instead
of inside netd. The network related bpf library is renamed to
libnetdbpf. Fix the dependency issue in framework to make sure no
regression.

Test: -m CtsNetTestCases -t android.net.cts.TrafficStatsTest
Bug: 112334572
Change-Id: Ibd477bf17d18d516aa520fb1569f4a395ef9abf0
2018-10-17 03:46:35 +00:00
Yan Yan
7fec7d15d3 Merge changes I10c01f2b,Ie05bc535 am: 8e3ad8b525 am: 7947437af7
am: b950e8b81c

Change-Id: I074056f861332835adaed32ad7d43ed36667ffa3
2018-10-05 12:35:56 -07:00
Yan Yan
b950e8b81c Merge changes I10c01f2b,Ie05bc535 am: 8e3ad8b525
am: 7947437af7

Change-Id: I5501ba7eb04493b5de84feaeadb53b57de89e8d2
2018-10-05 12:13:20 -07:00
Yan Yan
8e3ad8b525 Merge changes I10c01f2b,Ie05bc535
* changes:
  Check to ensure UDP-encap is used only for IPv4
  Add UDP encapsulation tests for IpSecService.
2018-10-05 17:38:41 +00:00
evitayan
43d93a0c78 Check to ensure UDP-encap is used only for IPv4
This commit checks if UDP-encapsulation is used
for unsupported address family and throws
IllegalArgumentException when it happens.

Bug: 74213459
Test: Tests added in testCreateTransportModeTransformWithEncap
      and testCreateTunnelModeTransformWithEncap.
      Command: runtest frameworks-net
      Verified on taimen.
Change-Id: I10c01f2bad6aca23430849ea9ef6c1eb157ae131
2018-10-04 11:44:00 -07:00
Chalard Jean
df7d98e7a4 Merge "Delay global alerts by 1s for high thresholds" am: a31118e420 am: dc6e65b3f0
am: b06e8f4f34

Change-Id: Ie0ba5c1d1a2139606e63fcfe46ec77a89accd8d9
2018-10-04 02:18:19 -07:00
Chalard Jean
b06e8f4f34 Merge "Delay global alerts by 1s for high thresholds" am: a31118e420
am: dc6e65b3f0

Change-Id: Iaabb31586e9e747871a526dc7ebb7deeb65d8f83
2018-10-04 01:57:53 -07:00
Treehugger Robot
a31118e420 Merge "Delay global alerts by 1s for high thresholds" 2018-10-04 08:17:11 +00:00
Chalard Jean
d966e8cf28 Delay global alerts by 1s for high thresholds
By skipping updates if an alert is already scheduled, this avoids firing
the global alert too often on devices with high transfer speeds and high
quota.

Test: with tethering watching videos. Also runtest frameworks-net
Bug: 117243748
Change-Id: Idce6059832db7a0e4a7117bbb3e424ec62ae3b21
2018-10-04 01:30:43 +00:00
Benedict Wong
92334a78e0 Merge "Re-enable checks for MANAGE_IPSEC_TUNNELS" am: 4f94cbe619 am: e2778b09ad
am: 319d308884

Change-Id: Ifa46c8e45f307d924c2ea589345957736dee0db0
2018-09-19 17:33:21 -07:00
Benedict Wong
319d308884 Merge "Re-enable checks for MANAGE_IPSEC_TUNNELS" am: 4f94cbe619
am: e2778b09ad

Change-Id: I6f6e3d2a43172459ef5bc88b6fc3d3fbbfd04a2f
2018-09-19 17:23:54 -07:00
Benedict Wong
4f94cbe619 Merge "Re-enable checks for MANAGE_IPSEC_TUNNELS" 2018-09-19 21:46:05 +00:00
Benedict Wong
2b6a14ecf3 Re-enable checks for MANAGE_IPSEC_TUNNELS
This patch ensures that creation and modification of IPsec tunnels
requires the MANAGE_IPSEC_TUNNELS appop.

Bug: 115685048
Test: IpSecManagerTunnelTest fails without appops set
Change-Id: I6c60a2573ca521717877f36e28a392b0d3b62754
2018-09-13 16:50:35 -07:00
Benedict Wong
126f4ee3f5 Merge "Use UID as requestID" am: 583f3632e5 am: 0372703a46
am: 52bdf5bad9

Change-Id: I36f1f6ab5e43abfadcba972bc89bbb4caa902074
2018-09-12 16:23:43 -07:00