247 Commits

Author SHA1 Message Date
Lorenzo Colitti
2de4925f5c Add an API hint for metered multipath traffic.
This allows an application that knows how to provide seamless
network connectivity (e.g., using QUIC multipath) to find out if
doing so is desired.

Test: builds, boots, runtest frameworks-net passes.
Bug: 34630278
Change-Id: Ic7fd0b9e1cd879fdfaf84009d7125391895e9087
2017-02-01 17:02:29 +09:00
Lorenzo Colitti
e45952c825 Rename AvoidBadWifiTracker to MultinetworkPolicyTracker am: 58ebe1c6f1 am: 0bc8070fce am: 338241de94
am: d526434f05

Change-Id: I5aefc453c022286e6ee2332a53e6c9f36472e9a5
2017-02-01 03:17:19 +00:00
Lorenzo Colitti
d526434f05 Rename AvoidBadWifiTracker to MultinetworkPolicyTracker am: 58ebe1c6f1 am: 0bc8070fce
am: 338241de94

Change-Id: I91f1338f3488cfc60eef0c2147aa7b1d61107cdd
2017-02-01 02:59:42 +00:00
Lorenzo Colitti
58ebe1c6f1 Rename AvoidBadWifiTracker to MultinetworkPolicyTracker
Rename the class and ensure that all code related to bad wifi
avoidance has names that reflect its purpose.  This will allow us
to reuse most of the the code for other purposes in future CLs.

Test: runtest frameworks-net passes
Bug: 34630278
Change-Id: Ida190e5a79e7a12f4eec07e1a3e4d9d138e83bcd
2017-01-31 15:42:57 +09:00
Hugo Benichi
db11740a01 Merge "ApfTest: fix flaky testApfFilterRa." am: c2e8588396 am: 60e1375f79 am: 811f6c86da
am: 488ffdc784

Change-Id: Ib4223b548b434211dda4e750f660eb68a30a9d96
2017-01-31 06:16:43 +00:00
Hugo Benichi
488ffdc784 Merge "ApfTest: fix flaky testApfFilterRa." am: c2e8588396 am: 60e1375f79
am: 811f6c86da

Change-Id: Idd738e1a4c9f0a865f5b84270535a94c492341ce
2017-01-31 06:11:35 +00:00
Hugo Benichi
4456f33a95 ApfTest: fix flaky testApfFilterRa.
testApfFilterRa is failing with probabiliy 1/10 ~ 1/15 on the following
assert: assertDrop(program, packet, lifetime/6), for lifetime values
that are multiple of 6, where 6 is the hardcoded fraction of RA lifetime
to filter in ApfFilter.java.

When the lifetime is not a multiple of 6, the remainder of 1 to 5
seconds gives enough margin so that when the APF program is simulated
the faked lifetime of the program is less than lifetime/6 away and the
packet is dropped.

However for lifetimes which are exact multiples of 6, this margin is
always 0s and that result in nondeterminism in the result. This is
consistent with the obervation that the only failed assert was for a
lifetime of 300s, the only multiple of 6.

This can be observed by detecting the age limit at which the filter
stops dropping packet oscillating between lifetime/6 and lifetime/6 + 1
for lifetimes which are multiple of 6.

This patch fixes the flakyness by freezing the flow of time in tests so
that the expected filter age threshold is consistent and stable.

Test: no failure observed in 1000 runs.
Bug: 32561414
Change-Id: I5251d047039f34b82ce8a5d20ae46563e1e0cce8
2017-01-31 11:13:44 +09:00
Hugo Benichi
4c0b7cc776 DO NOT MERGE ApfFilter: use elapsedRealTime for RA lifetime
This patch replaces System.currentTimeMillis() with
SystemClock.elapsedRealTime() to make RA lifetime computation more
resilient to various external events inducing jumps in
currentTimeMillis().

Test: ApfTest passes.

(cherry picked from commit 305af8e98a4fce712c1a93daf3b050dac2e8b91a)

Change-Id: Idbde700025fecfecefb8162d66b94194a87829d5
2017-01-23 14:53:22 +09:00
Hugo Benichi
c81837495d DO NOT MERGE ApfFilter: systematically use u8, u16, u32 getters
This patch adds a getUint8 getter for ByteBuffers and changes ApfFilter
to make uses of getUint8/16/32 everywhere.

The return types of getUint16 is also changed from long to int, which
will expand gracefully to long as an unsigned int as it is guaranteed to
be positive after getUint16.

Test: ApfTest passes

(cherry picked from commit 995dd94673005b43d32456e2de5fda0090b23576)

Change-Id: Idde3c9d03d39fbdf6f9b84d398f3fe8ea371483d
2017-01-23 14:49:16 +09:00
Treehugger Robot
e7128b10a8 Merge "Don't loop forever on zero-length ICMPv6 ND options." 2017-01-20 08:47:17 +00:00
Lorenzo Colitti
1eda5b25ce Don't loop forever on zero-length ICMPv6 ND options.
Bug: 33828433

(cherry picked from commit 2f157c421a9fa15660b8f1bc0c64b1ebb45fa64a)

Change-Id: Icc03f0fcbf40d87e0b9c69e1172802ffcc85531b
2017-01-20 15:48:21 +09:00
Jeff Sharkey
619a511d4f StrictMode to detect untagged network traffic.
Network usage is tracked by the kernel at the UID level, which is
granular enough for normal apps, but large components (such as the
system server) are impossible to debug without adding additional
socket tagging to help identify subsystems within a UID.

To help ensure that system components tag all their network traffic,
this change offers a new StrictMode option to detect and report
untagged sockets.

Test: builds, boots, all common traffic tagged
Bug: 30943431, 30414041
Change-Id: I825c7941076054732264690247de2863342638e2
2017-01-19 20:52:05 -07:00
Erik Kline
5de1615266 Eschew unspecified IP addresses for DNS servers am: a19f9f281a
am: b2331e9c34

Change-Id: I22641f3cd329fd332aa7e717cbfedce0fe6b83e4
2017-01-19 08:07:13 +00:00
Erik Kline
b2331e9c34 Eschew unspecified IP addresses for DNS servers
am: a19f9f281a

Change-Id: I3ff187ffc0c3bab4b51a1176c26647637c6224cf
2017-01-19 08:02:11 +00:00
Erik Kline
fed4194af0 Eschew unspecified IP addresses for DNS servers
Test: as follows
    - built
    - flashed
    - booted
    - runtest frameworks-wifi passes (though no test covers this code yet)
Bug: 34210527
Change-Id: I2d44445982dfb3221f7b6394daf0479c1fa8a6e1
2017-01-19 17:01:46 +09:00
Erik Kline
a19f9f281a Eschew unspecified IP addresses for DNS servers
Test: as follows
    - built
    - flashed
    - booted
    - runtest frameworks-wifi passes (though no test covers this code yet)
Bug: 34210527
Change-Id: I2d44445982dfb3221f7b6394daf0479c1fa8a6e1
2017-01-19 15:27:08 +09:00
Hugo Benichi
17586f7f1f DO NOT MERGE: Add fuzzing tests to ApfFilter RA processing
Test: added new unit tests

(cherry picked from commit 8acea76a2b7555b3bd5ca1170cca9d09e979fafc)

Change-Id: I4e6633984075d87c4e22466bc881629436359f7f
2017-01-18 19:07:57 +09:00
Lorenzo Colitti
6e22c50d7b Don't loop forever on zero-length ICMPv6 ND options. am: 2f157c421a
am: 9bfda163e2

Change-Id: Ice002fa65828eb738323425597dec1549c0f9a42
2016-12-23 08:32:03 +00:00
Lorenzo Colitti
9bfda163e2 Don't loop forever on zero-length ICMPv6 ND options.
am: 2f157c421a

Change-Id: Id8fbe5361b8a826677638213eed565be333f2c4d
2016-12-23 08:26:29 +00:00
Lorenzo Colitti
2f157c421a Don't loop forever on zero-length ICMPv6 ND options.
Bug: 33828433
Change-Id: Ie1905167126c8c8f3896eaa5e36cd006ca354e99
2016-12-23 13:54:50 +09:00
Erik Kline
0663d88344 Have IpManager track L2-L4 signaling traffic required for IP connectivity. am: 473355f96b
am: eff558cd30

Change-Id: Iccd81c5d722a14409fc4f22bc34c3607bca653da
2016-12-15 10:21:08 +00:00
Erik Kline
eff558cd30 Have IpManager track L2-L4 signaling traffic required for IP connectivity.
am: 473355f96b

Change-Id: Ie95309464d8f368f5040c74b59daba9700191e86
2016-12-15 10:13:36 +00:00
Erik Kline
ade3a8ccb0 Have IpManager track L2-L4 signaling traffic required for IP connectivity.
Test: as follows
    - built and flashed
    - observed logcat
    - observed "dumpsys wifi ipmanager"
    - runtest BlockingSocketReaderTest passes
    - runtest ConnectivityPacketSummaryTest passes
Bug: 21859053
Bug: 26101306
Bug: 31742572
Bug: 31707128
Bug: 33531488

Change-Id: Ibecaf809dcc1813924b25749e8ba8eb2d4bdf114
2016-12-15 19:09:49 +09:00
Erik Kline
473355f96b Have IpManager track L2-L4 signaling traffic required for IP connectivity.
Test: as follows
    - built and flashed
    - observed logcat
    - observed "dumpsys wifi ipmanager"
    - runtest BlockingSocketReaderTest passes
    - runtest ConnectivityPacketSummaryTest passes
Bug: 21859053
Bug: 26101306
Bug: 31742572
Bug: 31707128
Bug: 33531488

Change-Id: Ibecaf809dcc1813924b25749e8ba8eb2d4bdf114
2016-12-15 17:16:48 +09:00
Erik Kline
c8585b9742 More correct startup and shutdown procedures.
During IpManager startup, anything sending messages to the state machine
must not begin doing so until after the state machine has been started.
Reorder the constructor accordingly.

During shutdown, AvoidBadWifiTracker needs to unregister the registered
BroadcastReceiver and might as well also unregister the ContentObserver.

Test: backport from internal
Bug: 33388922
Change-Id: I58e07f7ccddaab160c153bcfb69fd45f50bb8710
2016-12-15 10:43:41 +09:00
Erik Kline
fdce10985c More correct startup and shutdown procedures. am: 6c0782f1ae
am: 20cad0821d

Change-Id: I5096f6a6f3d42bd55b9d3c80e279f2ee2fb0a795
2016-12-14 11:46:26 +00:00
Erik Kline
20cad0821d More correct startup and shutdown procedures.
am: 6c0782f1ae

Change-Id: Ib488e0cb49da2d3f655e189600f839721ea73358
2016-12-14 11:39:36 +00:00
Erik Kline
6c0782f1ae More correct startup and shutdown procedures.
During IpManager startup, anything sending messages to the state machine
must not begin doing so until after the state machine has been started.
Reorder the constructor accordingly.

During shutdown, AvoidBadWifiTracker needs to unregister the registered
BroadcastReceiver and might as well also unregister the ContentObserver.

Bug: 33388922
Change-Id: I58e07f7ccddaab160c153bcfb69fd45f50bb8710
2016-12-14 18:53:26 +09:00
Erik Kline
4539fb1884 Merge "DHCPv4 anonymity profile: support skipping hostname option" am: eef38717b9 am: 94e328c22f am: 68700dc757
am: 6ba22b5d19

Change-Id: I3b3cade76fa364899f7e177483b42020238bf691
2016-12-14 03:42:47 +00:00
Erik Kline
6ba22b5d19 Merge "DHCPv4 anonymity profile: support skipping hostname option" am: eef38717b9 am: 94e328c22f
am: 68700dc757

Change-Id: I7e587b8b45a722c085a1081321357b2f8e9e73c8
2016-12-14 03:35:45 +00:00
Erik Kline
94e328c22f Merge "DHCPv4 anonymity profile: support skipping hostname option"
am: eef38717b9

Change-Id: Id0eff1bdb60f1895fa6dd6c619071994efd79939
2016-12-14 03:22:12 +00:00
Erik Kline
511818ffb3 DHCPv4 anonymity profile: support skipping hostname option
Per https://tools.ietf.org/html/rfc7844#section-3.7

   When using the anonymity profile, DHCP clients SHOULD NOT send the
   Host Name option.

Once the net.hostname property is removed and ensured unset via CTS
this option will no longer be sent.

Test: as follows
    - build, flashed
    - connected to v4-only and dualstack networks, verified v4 works
    - android.net.dhcp.DhcpPacketTest passes
    - setprop net.hostname "" and verified no hostname option
Bug: 30979015
Change-Id: Ieab3f04ea38e176d9147bb788742a5397762c2e4
2016-12-13 18:14:44 +09:00
Hugo Benichi
0cc49bb5bc DO NOT MERGE APF: also drop any ICMPv6 RSs
Test: new unit test + $ runtest franeworks-net
Bug: 32833400

(cherry picked from commit f98182ef5e80ede5de7f2c2a5f40fc92a46c9704)

Change-Id: I4c46304b9dc8105123fc02a29f99dbc835248eb0
2016-12-09 16:08:52 +09:00
Hugo Benichi
02428988ad DO NOT MERGE: APF: also drop any ICMPv6 RSs
Test: new unit test + $ runtest franeworks-net
Bug: 32833400

(cherry picked from commit f98182ef5e80ede5de7f2c2a5f40fc92a46c9704)

Change-Id: Ifaf6e778c811c7d865c790a293b1fce3f43cad1c
2016-12-09 13:59:19 +09:00
Hugo Benichi
dafc44ea11 DO NOT MERGE: ApfFilter: use elapsedRealTime for RA lifetime
This patch replaces System.currentTimeMillis() with
SystemClock.elapsedRealTime() to make RA lifetime computation more
resilient to various external events inducing jumps in
currentTimeMillis().

Test: ApfTest passes.

(cherry picked from commit 305af8e98a4fce712c1a93daf3b050dac2e8b91a)

Change-Id: If19011fc0c905948f2e42b975cfcc5f8672a95fb
2016-12-08 17:13:33 +09:00
Hugo Benichi
94dcb3c3fd DO NOT MERGE: Do not synchronize boolean reads/writes
This patch removes the synchronization around the private variable
mRunning inside of IpReachabilityMonitor and instead qualifeis the field
as volatile.

Synchronization is not needed for reads/writes on native fields or
object references because they are already guaranteed to be atomic.

Synchronization here was used for enforcing memory visibility across
concurrent threads indirectly through monitor acquire/release.
The volatile keyword achieves this in a more explicit way.

Also, this patch changes the way that probeAll() copies the
IpReachabilityMonitor's mIpWatchList by temporary holding mIpWatchList
keys into an ArrayList instead of a more expensive HashSet. Since Java
HashSet are just degenerated HashMaps, and that key iteration order is
based on key hash, the iteration order over this temporary collection
will be consistent for the same mIpWatchList.

Test: refactoring CL. Existing unit tests still pass.

(cherry picked from commit b0f1186c034c4df9eb54ed29944d16ce6d7ade56)

Change-Id: I48d2b4d837a459150cd431b400ec01b87b48c014
2016-12-08 17:13:32 +09:00
Hugo Benichi
4104ff9220 DO NOT MERGE: ApfFilter: systematically use u8, u16, u32 getters
This patch adds a getUint8 getter for ByteBuffers and changes ApfFilter
to make uses of getUint8/16/32 everywhere.

The return types of getUint16 is also changed from long to int, which
will expand gracefully to long as an unsigned int as it is guaranteed to
be positive after getUint16.

Test: ApfTest passes

(cherry picked from commit 995dd94673005b43d32456e2de5fda0090b23576)

Change-Id: I606ebc5aedfcacde400d27cc6bc37145769b122c
2016-12-08 17:13:32 +09:00
Hugo Benichi
0668a61d82 DO NOT MERGE: Add fuzzing tests to ApfFilter RA processing
Test: added new unit tests

(cherry picked from commit 8acea76a2b7555b3bd5ca1170cca9d09e979fafc)

Change-Id: I847d7e4895766042043c0bba1c9b9a698a705d87
2016-12-08 17:13:31 +09:00
Erik Kline
b406666cf5 Handle IpReachabilityMonitor errors better.
If construction of a new IpReachabilityMonitor throws an IAE then
log it and immediately call onProvisioningFailure().

Test: runtest frameworks-wifi
      passes, except for selectQualifiedNetworkDoesNotChooseDeletedEphemeral()
      which fails with an NPE for unrelated reasons.

Bug: 31038971
Bug: 31742703
Change-Id: Ie91b8bdd509d06ad54d062bf446e74c092eb096c
(cherry picked from commit e4526604664cb66ecdcbeca4d8f64e8c94750c31)
2016-12-07 16:23:26 +09:00
Hugo Benichi
f98182ef5e APF: also drop any ICMPv6 RSs
Test: new unit test + $ runtest franeworks-net
Bug: 32833400
Change-Id: Ibd7ce2e3565eab74043fe9604fe2b23abd53a2eb
2016-12-03 14:38:58 +09:00
Erik Kline
5f4a37c9aa Handle IpReachabilityMonitor errors better. am: e452660466
am: d8a06fa28a

Change-Id: I820f887205de7565bbf70fe66de66680fa571475
2016-11-09 02:48:22 +00:00
Erik Kline
e452660466 Handle IpReachabilityMonitor errors better.
If construction of a new IpReachabilityMonitor throws an IAE then
log it and immediately call onProvisioningFailure().

Test: runtest frameworks-wifi
      passes, except for selectQualifiedNetworkDoesNotChooseDeletedEphemeral()
      which fails with an NPE for unrelated reasons.

Bug: 31038971
Bug: 31742703
Change-Id: Ie91b8bdd509d06ad54d062bf446e74c092eb096c
2016-11-08 16:02:24 +09:00
Hugo Benichi
9059566276 Merge "Add SafetyNet logging to DHCP packet parsing" 2016-10-25 02:10:28 +00:00
Hugo Benichi
a028989471 Add SafetyNet logging to DHCP packet parsing
Test: unit test passes
Bug: 31850211
Change-Id: I47f9db1f2c50ccd4fc90b80a9ffc1e9e43078f5f
2016-10-24 15:40:10 +09:00
TreeHugger Robot
5bc2953f6e Merge "Do not synchronize boolean reads/writes" 2016-10-17 11:14:17 +00:00
TreeHugger Robot
8b928c23a2 Merge "ApfFilter: use elapsedRealTime for RA lifetime" 2016-10-17 11:13:45 +00:00
Hugo Benichi
305af8e98a ApfFilter: use elapsedRealTime for RA lifetime
This patch replaces System.currentTimeMillis() with
SystemClock.elapsedRealTime() to make RA lifetime computation more
resilient to various external events inducing jumps in
currentTimeMillis().

Test: ApfTest passes.
Change-Id: I4876064638df78d72bbd9057cfdf3309f8e27f68
2016-10-17 14:23:27 +09:00
Hugo Benichi
b0f1186c03 Do not synchronize boolean reads/writes
This patch removes the synchronization around the private variable
mRunning inside of IpReachabilityMonitor and instead qualifeis the field
as volatile.

Synchronization is not needed for reads/writes on native fields or
object references because they are already guaranteed to be atomic.

Synchronization here was used for enforcing memory visibility across
concurrent threads indirectly through monitor acquire/release.
The volatile keyword achieves this in a more explicit way.

Also, this patch changes the way that probeAll() copies the
IpReachabilityMonitor's mIpWatchList by temporary holding mIpWatchList
keys into an ArrayList instead of a more expensive HashSet. Since Java
HashSet are just degenerated HashMaps, and that key iteration order is
based on key hash, the iteration order over this temporary collection
will be consistent for the same mIpWatchList.

Test: refactoring CL. Existing unit tests still pass.
Change-Id: I86ca6d54cb41ec78281e224a8d8ffd7155451132
2016-10-13 15:00:34 +09:00
Hugo Benichi
995dd94673 ApfFilter: systematically use u8, u16, u32 getters
This patch adds a getUint8 getter for ByteBuffers and changes ApfFilter
to make uses of getUint8/16/32 everywhere.

The return types of getUint16 is also changed from long to int, which
will expand gracefully to long as an unsigned int as it is guaranteed to
be positive after getUint16.

Test: ApfTest passes
Change-Id: Id3c2817b949e9817e2bb60e0ec8fe2d6fd8d787c
2016-10-13 10:16:31 +09:00
Hugo Benichi
8acea76a2b Add fuzzing tests to ApfFilter RA processing
Test: added new unit tests
Change-Id: Ie352eb1514b762e032b9140d633abc06180d0ade
2016-10-11 10:04:42 +09:00