Commit Graph

719 Commits

Author SHA1 Message Date
Junyu Lai
11e2cb862b Merge "Change types of fields of network stats reported to framework." am: 2c0a0092f1 am: 40de2a46a3
am: 979209a2a3

Change-Id: Iab166b8b06d3a744b8cfc83e0467c478642ce185
2018-11-13 02:03:05 -08:00
Junyu Lai
979209a2a3 Merge "Change types of fields of network stats reported to framework." am: 2c0a0092f1
am: 40de2a46a3

Change-Id: I0bf2bdc56f46928b94f0954e799d51196171fdc4
2018-11-13 01:53:45 -08:00
junyulai
6d49d8da7e Change types of fields of network stats reported to framework.
Currently, NetworkStats use int to handle uid, set and tag,
while native side using unsigned int mixing with signed int
with that. This commit make necessary changes in JNI part while
libnetdbpf unifying the types of fields.

Bug: 112226716
Test: 1. manually reconnect vpn
      2. update apps from playstore
      3. atest libnetdbpf_test
      4. runtest frameworks-net
      5. cts-tradefed run cts -m CtsUsageStatsTestCases -t \
              android.app.usage.cts.NetworkUsageStatsTest

Change-Id: I6c27124db8292e2825fba51b8994f013897cb566
2018-11-08 23:07:00 +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
Luke Huang
4f2898674e Merge "Refactor UidRange by using stable aidl structure" am: 55012f2249 am: 96c61c9fa2
am: 9a3586aa00

Change-Id: I82e06fe93a3ed88368b649ef8d3283322191ffe7
2018-10-28 18:06:15 -07:00
Luke Huang
9a3586aa00 Merge "Refactor UidRange by using stable aidl structure" am: 55012f2249
am: 96c61c9fa2

Change-Id: I09ac7fc6525948b76114ef936dc1b3d2d1bae0fb
2018-10-28 17:55:57 -07:00
Luke Huang
e67f2178dc Refactor UidRange by using stable aidl structure
Use stable aidl generated structure instead of UidRange

Test: runtest frameworks-net passes
Test: manual testing of UidRange related function works
Change-Id: Iaf1c10777dc1e71df2be2a57533a10257b12626b
2018-10-24 19:45:09 +09: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
Chenbo Feng
684c94973c Merge "Don't check qtaguid file unless using them" am: 0ce43570f5 am: 8eb31202df
am: b127d68ca2

Change-Id: Ibbb10778c6e12c64275c179c8d984306fcb27b4f
2018-09-28 12:52:12 -07:00
Chenbo Feng
b127d68ca2 Merge "Don't check qtaguid file unless using them" am: 0ce43570f5
am: 8eb31202df

Change-Id: I6be72bb22da1aeed8dfe5eb4bbb05d8cfd9b4257
2018-09-28 12:32:50 -07:00
Chenbo Feng
5c0232c572 Don't check qtaguid file unless using them
The proc file of xt_qtaguid module is not necessarily exist on future
devices. We should only check it if the device need to read the stats
file for network usage information.

Bug: 79938294
Test: NetworkUsageStatsTest TrafficStatsTest
Change-Id: I5ac6feef8b9a26daa68b381a985925e24b0d80af
2018-09-14 16:13:14 -07:00
Remi NGUYEN VAN
33ca705a18 Merge "Add DhcpServer" am: e3a0f42e8e am: 7f3130c488
am: fb294eb16e

Change-Id: I602efdb3cb4b3316dada80361381404af1c3615c
2018-08-28 20:51:09 -07:00
Remi NGUYEN VAN
fb294eb16e Merge "Add DhcpServer" am: e3a0f42e8e
am: 7f3130c488

Change-Id: Ic3b1cd87389ade162c1c7441132f3e0451f1b78c
2018-08-28 20:42:08 -07:00
Remi NGUYEN VAN
c9fc125bb4 Add DhcpServer
This first version can serve discover/request/release, although there
are some small behavior changes with current implementation which will
be addressed later.

Also removes final modifiers on start() and stop() in FdEventsReader, to
allow mocking the methods in tests with the current mockito lib.

Test: Added tests pass, manual: flashed a device using the server
Change-Id: I025366ff7d51c4ba31152af50f3dd2b5e280a54d
2018-08-28 12:50:47 +09:00
Mathew Inwood
add296617f Merge "Add @UnsupportedAppUsage annotations" am: 90660f8990
am: 7a5bf4e2dd

Change-Id: I99215dd5430968df2e2dd514d21b396b00c1403e
2018-08-16 03:29:58 -07:00
Mathew Inwood
b5d1f26d20 Merge "Add @UnsupportedAppUsage annotations" am: d08509363c
am: d825eeefa4

Change-Id: I52585645e23519cfc6d216e344710ad76aeea9e8
2018-08-16 03:10:41 -07:00
Mathew Inwood
90660f8990 Merge "Add @UnsupportedAppUsage annotations" 2018-08-15 15:41:26 +00:00
Mathew Inwood
98639c2c19 Merge "Add @UnsupportedAppUsage annotations" 2018-08-15 11:36:32 +00:00
Mathew Inwood
ce3a48c05f Add @UnsupportedAppUsage annotations
For packages:
  android.net.wimax
  android.net.wifi.p2p.nsd
  android.net.wifi.p2p
  android.net.wifi.hotspot2.pps
  android.net.wifi.hotspot2.omadm
  android.net.wifi.hotspot2
  android.net.wifi.aware
  android.net.wifi
  android.net.util
  android.net.sip
  android.net.rtp
  android.net.nsd
  android.net.metrics
  android.net.lowpan
  android.net.http
  android.net.captiveportal
  android.net

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: Ie25423113ee1a8071cd5039382c00de6ce0af7fd
Merged-In: I520be7a4c79e68310c12e4f55bf66acaa94145a1
2018-08-14 14:44:29 +01:00
Mathew Inwood
ac005192ea Add @UnsupportedAppUsage annotations
For packages:
  android.net.wimax
  android.net.wifi.p2p.nsd
  android.net.wifi.p2p
  android.net.wifi.hotspot2.pps
  android.net.wifi.hotspot2.omadm
  android.net.wifi.hotspot2
  android.net.wifi.aware
  android.net.wifi
  android.net.util
  android.net.sip
  android.net.rtp
  android.net.nsd
  android.net.metrics
  android.net.lowpan
  android.net.http
  android.net.captiveportal
  android.net

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: I520be7a4c79e68310c12e4f55bf66acaa94145a1
2018-08-14 14:39:24 +01:00
Mathew Inwood
cf9b6cd10a Add @UnsupportedAppUsage annotations
For packages:
  android.app.usage
  android.app.trust
  android.app.timezonedetector
  android.app.timezone
  android.app.timedetector
  android.app.job
  android.app.backup
  android.app.assist
  android.app.admin
  android.app

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: I5d15d50344d7178617418846917f693cfabf006b
Merged-In: I618c5dc4462ae990d9df45c3e9ed3f092cc5138c
2018-08-14 14:25:44 +01:00
Mathew Inwood
ed334ebbd1 Add @UnsupportedAppUsage annotations
For packages:
  android.app.usage
  android.app.trust
  android.app.timezonedetector
  android.app.timezone
  android.app.timedetector
  android.app.job
  android.app.backup
  android.app.assist
  android.app.admin
  android.app

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: I618c5dc4462ae990d9df45c3e9ed3f092cc5138c
2018-08-14 14:17:44 +01:00
kopriva
5ea1eb31f0 docs: added Android P behavior change note to untagSocket reference am: c134e24a77
am: bc81ceab91

Change-Id: Ib4bb5d2d1b3f33bab69b5e109b23978a5f90da13
2018-07-26 17:25:49 -07:00
kopriva
bc81ceab91 docs: added Android P behavior change note to untagSocket reference
am: c134e24a77

Change-Id: I814224210475078c4ab01f53e42202a538c8a444
2018-07-26 17:17:16 -07:00
kopriva
c134e24a77 docs: added Android P behavior change note to untagSocket reference
staged here:
https://android-dot-devsite.googleplex.com/reference/android/net/TrafficStats#untagSocket(java.net.Socket)

Test: make ds-docs

Exempt-From-Owner-Approval: Docs-only change

Bug: 110484513
Change-Id: I24575e6f4451a019b60c5bf60e17e14a928c6cc3
2018-07-26 20:29:39 +00:00
Neil Fuller
8b95a1f8f7 Merge "Track constructor changes in libcore/" am: f94eb29500 am: 33a26e3ee4
am: fa52de540c

Change-Id: I7e7115799180d17e4ad6468e155aed79fc8600cb
2018-07-05 05:34:45 -07:00
Neil Fuller
33a26e3ee4 Merge "Track constructor changes in libcore/"
am: f94eb29500

Change-Id: I344d9210bd173f78651318366c852f65afe969d6
2018-07-05 05:14:26 -07:00
Neil Fuller
4b6b8dee0d Track constructor changes in libcore/
The 2-arg constructor is being removed.

Test: build / boot
Bug: 111055375
Change-Id: I72413a8c7885f9514a88f59deb649fa755deff92
2018-07-03 19:22:45 +01:00
Nathan Harold
d21e909fd3 Rework Exception Handling for IpSecManager
In order to properly support EOPNOTSUPP this CL
applies a consistent approach to handling Exceptions.
Hereafter, all exceptions that aren't of a special
method-specific type (such as SpiUnavailableException)
will all be returned to the calling process unchanged.
At the API call site, the ServiceSpecificException,
which is really an Errno, will be inspected and either
converted to an unchecked exception for types we know,
or it will be converted to an IOException in cases where
that method can return a checked exception. In cases
where we do not expect an errno, we will simply throw
a generic RuntimeException. This means all API calls
will now properly throw UnsupportedOperationException
and may be CTS tested accordingly.

Bug: 72420898
Test: runtest frameworks-net
Merged-In: I4a00e221618896223fcdb4b4279fb14cd14e34d8
Change-Id: I4a00e221618896223fcdb4b4279fb14cd14e34d8
(cherry picked from commit beed0b61b7)
2018-06-07 18:42:52 -07:00
Benedict Wong
b25e678b4b Update IpSecManager to use InetAddress and prefixLen
LinkAddress constructors are currently @hide; this change updates
IpSecManager to use InetAddress and prefixLen, and then construct a
LinkAddress internally. LinkAddress is used over the binder interface to
IpSecService to ensure validity.

Bug: 77528639
Test: CTS, Java unit tests ran on walleye
Merged-In: I19e124adef6d9f4992d8293db3190bcf74c95848
Change-Id: I19e124adef6d9f4992d8293db3190bcf74c95848
(cherry picked from commit d39837f7e2)
2018-06-07 18:42:52 -07:00
Nathan Harold
cac8775b2a Add AppOps Checks for MANAGE_IPSEC_TUNNELS
Adds support for a new AppOp to permit services to
use IpSec tunnel mode. The IpSecService now needs
a context so change the service mode to a cached
service rather than a static service.

Bug: 66955045
Test: runtest frameworks-net
Merged-In: I17a4a286225b432c3e15ea1587d946189931b4f4
Change-Id: I17a4a286225b432c3e15ea1587d946189931b4f4
(cherry picked from commit 65ef843176)
2018-06-07 18:42:52 -07:00
Nathan Harold
b9df8b1fca Add MANAGE_IPSEC_TUNNELS Permission
Add a new MANAGE_IPSEC_TUNNELS permission and
protect all IPsec Tunnel mode APIs with it.
This permission is only granted to the system or
through an AppOp.

Bug: 66955045
Test: compilation
Merged-In: I0f618373b500c493ef2211bece681f74652a1833
Change-Id: I0f618373b500c493ef2211bece681f74652a1833
(cherry picked from commit 00e77247eb)
2018-06-07 18:42:52 -07:00
Jeff Sharkey
d811e74b93 Merge "Last-ditch clamping of negative NetworkStats." into pi-dev am: 0026f5eb18
am: eecce38819

Change-Id: I572ef538dafb59d8947958df8eac155e890d08f0
2018-05-23 17:43:05 -07:00
Jeff Sharkey
d631c5836d Last-ditch clamping of negative NetworkStats.
We've seen reports of negative values flowing through to attempt
being recorded, which will outright crash.  This change does one
last-ditch check to see if we're about to work with negative values,
reporting any trouble and clamping them to zero so we don't crash.

This gives us the data we need to continue investigating without
triggering runtime restarts in the field.

Bug: 80057433
Test: atest android.net.NetworkStatsTest
Change-Id: I8174391c6cf5dadc2c2c10a8d841ee07e1f7d934
2018-05-22 11:35:32 -06:00
android-build-team Robot
4b561abcaa Merge changes from topic "ifaceStatsDetail" into pi-dev
* changes:
  Remove the unused file parsing function
  Use eBPF map data for per iface stats
2018-05-02 19:17:27 +00:00
android-build-prod (mdb)
868479ce7b Merge changes from topic "am-b4a6d70f84a44081adc7240053891656" into pi-dev-plus-aosp
am: 5e5a150dbd

Change-Id: Ice5d3c6c975c0945785332c09a876754441d536d
2018-05-01 20:11:28 -07:00
android-build-prod (mdb)
93f2f28a66 Merge changes from topic "ifaceStats" am: eab28ef97c
am: b86d2b4b84

Change-Id: I460bc25806182bc2dc5fcc2512ab01e776a0e8e6
2018-05-01 19:53:30 -07:00
Chenbo Feng
3654e617c0 Use eBPF map data for per iface stats am: 2dc99dc445
am: 2e13ecc88d

Change-Id: If4944a4a5a0c49235731afb4ae3220cf72240a83
2018-05-01 19:49:53 -07:00
Chenbo Feng
d8dfd8c175 Remove the unused file parsing function
With the new xt_bpf support for iface stats. We no longer need to parse
the per interface stats from /proc/net/dev. And since the old xt_qtaguid
code path also not depend on it, we can completly remove that helper
function since no caller is depending on it now.

Bug: 72111305
Test: runtest frameworks-net -c com.android.internal.net.NetworkStatsFactoryTest
Change-Id: Icb7eaeef0eeb9fdffd32a90316c76ee05bafffbe
Merged-In: Icb7eaeef0eeb9fdffd32a90316c76ee05bafffbe
(cherry picked from aosp commit b815c978b81eee4b1494bd0b9d25bfad52f08b72)
2018-05-01 19:48:03 -07:00
Chenbo Feng
c34a67b18c Use eBPF map data for per iface stats
After adding the xt_bpf module and ifaceStatsMap, eBPF tool can now
support reading per interface data. So networkStatsFactory should move
away from parsing proc/net/dev and use the eBPF map stats instead.

Bug: 72111305
Test: atest com.android.server.net.NetworkStatsServiceTest
Change-Id: Ibcc6150d00835b3bd33af22a72e4a86e172581cf
Merged-In: Ibcc6150d00835b3bd33af22a72e4a86e172581cf
(cherry picked from aosp commit dcc56783f5b945b16c9f5e50333fba557a7c3603)
2018-05-01 19:46:09 -07:00
Chenbo Feng
1f37112a51 Remove the unused file parsing function
With the new xt_bpf support for iface stats. We no longer need to parse
the per interface stats from /proc/net/dev. And since the old xt_qtaguid
code path also not depend on it, we can completly remove that helper
function since no caller is depending on it now.

Bug: 72111305
Test: runtest frameworks-net -c com.android.internal.net.NetworkStatsFactoryTest
Change-Id: Icb7eaeef0eeb9fdffd32a90316c76ee05bafffbe
2018-05-01 14:13:55 -07:00
Chenbo Feng
2dc99dc445 Use eBPF map data for per iface stats
After adding the xt_bpf module and ifaceStatsMap, eBPF tool can now
support reading per interface data. So networkStatsFactory should move
away from parsing proc/net/dev and use the eBPF map stats instead.

Bug: 72111305
Test: atest com.android.server.net.NetworkStatsServiceTest
Change-Id: Ibcc6150d00835b3bd33af22a72e4a86e172581cf
2018-05-01 14:13:48 -07:00
Nathan Harold
3a287d585e Merge "Rework Exception Handling for IpSecManager" into pi-dev am: 16c671dc9a
am: 86238ee312

Change-Id: Ic1f560070d12f3bdeb5c07316aad7ebed9719f6f
2018-04-25 12:01:34 -07:00
Nathan Harold
beed0b61b7 Rework Exception Handling for IpSecManager
In order to properly support EOPNOTSUPP this CL
applies a consistent approach to handling Exceptions.
Hereafter, all exceptions that aren't of a special
method-specific type (such as SpiUnavailableException)
will all be returned to the calling process unchanged.
At the API call site, the ServiceSpecificException,
which is really an Errno, will be inspected and either
converted to an unchecked exception for types we know,
or it will be converted to an IOException in cases where
that method can return a checked exception. In cases
where we do not expect an errno, we will simply throw
a generic RuntimeException. This means all API calls
will now properly throw UnsupportedOperationException
and may be CTS tested accordingly.

Bug: 72420898
Test: runtest frameworks-net
Change-Id: I4a00e221618896223fcdb4b4279fb14cd14e34d8
2018-04-24 19:04:08 -07:00
Jeff Sharkey
5a0df01ad7 Give CTS a way to force-poll network stats.
Collecting network statistics is pretty heavy, which is why we're
throttling callers.  However, to keep CTS running fast, we provide a
way for tests to force a poll event, instead of making them wait for
the throttle timeout.

Bug: 77908520
Test: atest cts/tests/tests/app.usage/src/android/app/usage/cts/NetworkUsageStatsTest.java
Change-Id: Ia792f0cd495023366ff8c4839df54e7da2ae8331
2018-04-20 12:18:23 -06:00
Nathan Harold
8732487ce6 Merge "[DO NOT MERGE] - Hide Tunnel Mode IpSec API" into pi-dev 2018-04-11 17:09:07 +00:00