259 Commits

Author SHA1 Message Date
Joel Scherpelz
5e1eb40c8f Merge "Set accept_ra_rt_info_max_plen to 64 before enabling IPv6 interfaces" am: 52f8421b77 am: b8933942fc
am: f9cd5cd81b

Change-Id: I5ebbe1a63da43f28b0d582bc7e6480ffe74195b7
2017-03-17 03:05:45 +00:00
Joel Scherpelz
b8933942fc Merge "Set accept_ra_rt_info_max_plen to 64 before enabling IPv6 interfaces"
am: 52f8421b77

Change-Id: I5b5d5460f9fe7ed228ab32b2c63cb601be5e1edb
2017-03-17 02:53:11 +00:00
Joel Scherpelz
25870a2c9e Set accept_ra_rt_info_max_plen to 64 before enabling IPv6 interfaces
This patch tries to change accept_ra_rt_info_max_plen to 64 from its
default value of 0 on kernels that support router advertisements with
route information options. The code fails silently on older unsupported
platforms.

Also factor existing startIPv6() code into a self documenting function
enableInterfaceIpv6PrivacyExtensions()

Bug: 33333670
Test: as follows
    - build sailfish
    - flashed
    - booted
    - runtest frameworks-net passes
    - runtest frameworks-wifi passes

Change-Id: I10ec83b9e04836089477d74417b7222499820066
2017-03-17 09:41:43 +09:00
Erik Kline
b7a55f4a4b Merge "Add blocking and retrying wrappers for INetd uses." am: ba8c613e16 am: 143d0853a2
am: 300c56a977

Change-Id: Ia9d45d8fd636e918c8299b26163de0650f8ddac5
2017-03-16 02:58:10 +00:00
Erik Kline
143d0853a2 Merge "Add blocking and retrying wrappers for INetd uses."
am: ba8c613e16

Change-Id: Iae8ea51852ed6991e3b9ed89297c8a932b9224f3
2017-03-16 02:49:36 +00:00
Treehugger Robot
ba8c613e16 Merge "Add blocking and retrying wrappers for INetd uses." 2017-03-16 02:42:17 +00:00
Erik Kline
af39244a34 Add blocking and retrying wrappers for INetd uses.
Test: as follows
    - built (bullhead)
    - flashed
    - booted
    - runtest frameworks-net passes

Change-Id: I1a8e15149bf9dbedc6a09c0d8ab6abb2ef4f8fee
2017-03-15 16:23:29 +09:00
TreeHugger Robot
1809db5cb1 Merge "IP connectivity metrics: add new APF counters." 2017-03-15 04:24:30 +00:00
Hugo Benichi
22d9b2d430 IP connectivity metrics: add new APF counters.
This patch adds a few missing counters to APF events:
 - an actual lifetime duration to ApfProgramEvent.
 - counters for total number of updates to ApfStatistics.

ApfProgramEvents are now recorded at program removal in order to
populate the actual lifetime of the program. ApfProgramEvents whose
actual lifetime was less than 1 second are filtered out.

Finally, instance fields of ApfProgramEvent and ApfStats classes are
made mutable to allow for simple record-like creation. This was not
possible when these classes were tagged @SystemApi.

Test: - manually verified output of $ dumpsys connmetrics list
      - unit tests updated.
Bug: 34901696

Change-Id: I02694ebb9421ce1c2aa757fa6aa209d19a654dcd
2017-03-15 11:49:48 +09:00
Erik Kline
9f5e699093 Merge "Add comment with packet tracker debugging tip" am: 40aa5ee583 am: 17dd8723b7
am: 663269bae2

Change-Id: Iacf172a6b6e1b62bc84af8b5fcdd1745acfe987f
2017-03-15 02:47:52 +00:00
Erik Kline
17dd8723b7 Merge "Add comment with packet tracker debugging tip"
am: 40aa5ee583

Change-Id: I0f5f139f81af23ddc33e37ddf489a477e37c394f
2017-03-15 02:38:51 +00:00
Erik Kline
c6f796aa91 Add comment with packet tracker debugging tip
Test: as follows
    - built (bullhead)
    - flashed
    - booted
    - "runtest frameworks-net" passes
    - "adb shell dumpsys wifi ipmanager" shows the debugging tip

Change-Id: Ifcccbdd81a0fc8beb7801ec7c3f78e8a941bc72b
2017-03-14 20:03:14 +09:00
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