Commit Graph

377 Commits

Author SHA1 Message Date
Benedict Wong
51de41dea2 Merge "Return a port from bindToPort() in IpSecService" 2017-10-24 16:31:21 +00:00
Benedict Wong
212777930f Return a port from bindToPort() in IpSecService
When binding to a random port, the port number was not being
returned, so the user is incorrectly receiving a port of zero.
Return the port number that was ultimately bound.

Bug: 67662580
Test: Ran CTS test on aosp_angler-eng
Change-Id: I22f4e5cdc83d43dc453788889990feb34e451bd3
2017-10-18 11:43:43 -07:00
Benedict Wong
edc1d285d7 Add support for AES-GCM-ESP as an IPSec algorithm
Allows native AES-GCM-ESP to be used as an IPSec transport/tunnel mode
algorithm with kernel support

Bug: 63589918
Test: IPsecService tests added, existing ones pass
Change-Id: Ie1a9a902be205f269aa37bf956198f2e5b177c21
2017-10-18 11:22:24 -07:00
Hugo Benichi
fa684574da Merge "Fix ConnectivityServiceTest#testNetworkCallbackMaximum" am: f7929f37b9 am: a5ea707a44
am: 4071792cce

Change-Id: Id5ee94ae9a7e2a92289f2b25b0d5c0f0b5b7381a
2017-10-15 02:53:58 +00:00
Hugo Benichi
602996fe25 Fix ConnectivityServiceTest#testNetworkCallbackMaximum
Although commit 2a84d1cbcf fixed some flakyness issues in
testNetworkCallbackMaximum so that it became stable when ran on its own,
it introduced a new source of random failures because instead of
registering callbacks after callbacks until a limit was reached, commit
2a84d1cbcf changed the test logic to push the assertions right up to
the theoretical limit.

More precisely when registering and unregistering PendingIntents in a
loop, not introducing some delay for checking that previous
PendingIntents have been effectively unregistered can cause the test to
fail. This patch fixes this issue.

Bug: 32561414
Bug: 62918393
Test: runtest frameworks-net
      testNetworkCallbackMaximum now succeeds 100 in a row on sailfish

Change-Id: I086817a738ab99fd53ba76ca8faada6151f46472
2017-10-12 23:15:14 +09:00
Hugo Benichi
cf9ab489de Merge "Import a few android.net unit tests into frameworks-net" am: f851fef87f am: bf80e2f376
am: 3d4d464f0a

Change-Id: Icf9ccd265754f1b85720bb778633dc5ef515646e
2017-10-12 12:34:55 +00:00
Hugo Benichi
470f4382fa Merge "Migrate most of core networking tests to junit4" am: 649a997437 am: 06cfeaf51f
am: c40687f85a

Change-Id: Ic59ca37bbb31ba091c8b6d31170584b946c2527a
2017-10-12 09:43:11 +00:00
Hugo Benichi
87d306b45f Import a few android.net unit tests into frameworks-net
Bug: 62918393
Test: runtest frameworks-net
Change-Id: I3c7c60bcfeffec5c5ec287810312349237a2868a
2017-10-12 15:55:22 +09:00
Hugo Benichi
1c0f4e27bc Migrate most of core networking tests to junit4
This patch is a batch of mechanical changes to test classes to migrate
away from AndroidTestCase and TestCase.

Bug: 62918393
Test: runtest frameworks-net
Change-Id: I74134609e511f22c4d9ecd65780e981f9ba7ae3f
2017-10-12 15:26:09 +09:00
Chalard Jean
0da609859d Merge "Add some useful helpers and constants." am: ed8d236319 am: 316bc4e19c
am: 06d401ae73

Change-Id: Iaf611b8e39080d677c9cfe7edb124c11bbdf8a81
2017-10-06 10:11:04 +00:00
Chalard Jean
8c827b7eb2 Add some useful helpers and constants.
Test: Pulled out of a client app ; the client app is behaving
Test: identically to how it was behaving before. Wrote unit
Test: tests in frameworks-net.

Change-Id: I397137748a95c65cee2e1e1b243a1a260e83a6f7
2017-10-06 13:38:46 +09:00
nharold
869d47e66d Merge changes from topic "ipsec-svc-cleanup" am: 9778c7884f am: 83d7776121
am: 4e793fd0b5

Change-Id: Ib7eae5c9e223493281524e862979e16d25984dde
2017-10-04 20:53:04 +00:00
Nathan Harold
f69cb0a207 Split IpSecServiceTest to add IPv6 Tests
-Split IpSecServiceTest into parameterized
 and single tests.
-Add IPv6 parameters

Bug: 66954381
Test: this
Change-Id: Ib98c112560014f73bccc3d2842c31d297c7a07ef
2017-10-03 19:45:59 -07:00
Nathan Harold
4f4459d8c3 Add equals() for IpSecAlgorithm and IpSecConfig
Add equality testing methods to support tests
for parceling and un-parceling IpSecConfig.

Bug: 38397094
Test: runtest -x IpSecConfigTest.java
Change-Id: I31e318334d39ed6e9daf5ec8f3be7dcec75e12ad
2017-10-03 19:45:58 -07:00
Nathan Harold
bfbda18d48 Input Validation for IpSecService
All of the input to IpSecService over the Binder
interface needs to be validated both for sanity
and for safety.

-Sanity check all the parameters coming from binder.
-Added setters for IpSecConfig to decouple the test
 from the IpSecManager. This was needed because the
 input validation caused the tests to fail due to a
 null parameter that was previously un-tested.
-Added the mode flag to the IpSecConfig bundle this
 oversight was found during testing.
-Expose the getResourceId() methods for testing in
 UdpEncapsulationSocket, SecurityParameterIndex, and
 IpSecTransform classes.
-Remove the unneeded getIpSecConfig() from
 IpSecTransform: unneeded now that we can synthesize
 configs.

Bug: 38397094
Test: runtest frameworks-net
Change-Id: I5241fc7fbfa9816d54219acd8d81a9f7eef10dd4
2017-10-03 19:45:55 -07:00
Hugo Benichi
1cae2642ad Merge "DO NOT MERGE Ignore DUN in describeImmutableDifferences" into oc-mr1-dev
am: b2f4b2e05d

Change-Id: I0236132b8b497af5b1c26aa44e6494fe0510cb6d
2017-10-02 11:10:37 +00:00
Hugo Benichi
b2f4b2e05d Merge "DO NOT MERGE Ignore DUN in describeImmutableDifferences" into oc-mr1-dev 2017-10-02 10:57:01 +00:00
Hugo Benichi
a8565a7716 Merge "ConnectivityServiceTest: fix flaky testNetworkRequestMaximum" am: 1211941aa0 am: ca67954314
am: eced6cd14a

Change-Id: I53d0d6755c8e0be34db66da56efa483006e538ac
2017-10-02 10:51:21 +00:00
Hugo Benichi
2a84d1cbcf ConnectivityServiceTest: fix flaky testNetworkRequestMaximum
Registered requests are not keyed by PendingIntents in
ConnectivityService, which means that unregistering a request with a
PendingIntent causes a linear search in all registered requests.

testNetworkRequestMaximum was registering too many PendingIntents
simultaneously, causing the unregistration loop to have n^2
complexity and to take a long time to take effect.

To make the unregistering loop less likely to trigger a timeout on
waitForIdle, this patch changes the test to not register MAX_REQUEST
number of PendingIntent, but instead mixes a small number of
PendingIntents with NetworkCallbacks to reach MAX_REQUEST number of
simultaneously registered requests.

When unregistering these requests, callbacks are unregistered first.

Bug: 32561414
Test: runtest frameworks-net
Change-Id: I48b882c884abe20b388190b7f28baee293446f37
2017-10-02 17:37:57 +09:00
Hugo Benichi
7f9a223134 DO NOT MERGE Ignore DUN in describeImmutableDifferences
This patch changes describeImmutableDifferences in NetworkCapabilities
to ignore differences in NET_CAPABILITY_DUN, so that updateCapabilities
in ConnectivityService to not report wtf errors when a NetworkAgent
degrades its NetworkCapabilities object by removing NET_CAPABILITY_DUN.

Bug: 65257223
Test: runtest frameworks-net
Change-Id: I115ed1b366da01a3f8c3c6e97e0db8ce995fd377
2017-10-02 15:03:57 +09:00
Hugo Benichi
66749201a1 Merge "Fix NPE in NsdServiceTest" am: c30decbfe8 am: a9177b3748
am: a5d620ae92

Change-Id: Ieb299771438fe55566b76271815e52d02da799c8
2017-09-28 12:35:03 +00:00
Hugo Benichi
c30decbfe8 Merge "Fix NPE in NsdServiceTest" 2017-09-28 12:13:18 +00:00
Hugo Benichi
210ab83b77 Fix NPE in NsdServiceTest
Continuous test dashboards report that quit() can crash sometimes
due to mThread being null.

This patch adds a null guard in tearDown().

Bug: 32561414
Test: runtest frameworks-net
Change-Id: If66fb47e31e77d25b4741a786f12eb78f0b9102e
2017-09-28 15:22:13 +09:00
Lorenzo Colitti
f384a58f79 Merge "Delete the legacy framework code for manipulating ND offload." am: 3c0bf71eee am: fc56002707
am: bb21618a86

Change-Id: I07d9753e214af311d3dcab6f8016442f60388700
2017-09-27 11:05:29 +00:00
Lorenzo Colitti
3c0bf71eee Merge "Delete the legacy framework code for manipulating ND offload." 2017-09-27 10:46:36 +00:00
Lorenzo Colitti
d6cc68dab4 Merge "Declare support for Ethernet if the service is running." am: 21fcca6818 am: 5b906e1d11
am: a6648cc90b

Change-Id: Iafd9807ab76ce4e4ab1fd506d7b0e2b2b7017751
2017-09-27 08:51:51 +00:00
Lorenzo Colitti
2c9dd64d94 Declare support for Ethernet if the service is running.
On some devices, support for TYPE_ETHERNET is not specified in
the networkAttributes config resource, even though the device is
capable of supporting Ethernet (e.g., via USB host adapters).
This leads to Ethernet working but various connectivity APIs
behaving as if it was not - for example, no CONNECTIVITY_ACTION
broadcasts will be issues when it connects or disconnects.

Ensure that ConnectivityService always treats Ethernet as
available if the service is running. Currently the service is
started if the device supports FEATURE_ETHERNET or
FEATURE_USB_HOST.

(cherry picked from commit 7bbe3eee52c08ee92a81b7bed395ca5499554cc4)

Bug: 37359230
Test: bullhead builds, boots
Test: ConnectivityServiceTest passes
Test: Ethernet is available even if removed from networkAttributes resource
Test: ConnectivityManagerTest CTS test passes
Change-Id: I9b6db4edeaf966ee6715011dd92770b9d25dd938
Merged-In: I9b6db4edeaf966ee6715011dd92770b9d25dd938
2017-09-27 17:35:06 +09:00
Treehugger Robot
21fcca6818 Merge "Declare support for Ethernet if the service is running." 2017-09-27 08:23:34 +00:00
Lorenzo Colitti
19d4cd99f5 Delete the legacy framework code for manipulating ND offload.
This only worked on broadcom devices, and was superseded in
M by a wifi HAL call made by IpManager.

Test: bullhead builds, boots
Change-Id: I711cae7dafe171c2c8b4e84a229adbcad27f3d14
2017-09-27 16:47:36 +09:00
Lorenzo Colitti
23e9afc702 Declare support for Ethernet if the service is running.
On some devices, support for TYPE_ETHERNET is not specified in
the networkAttributes config resource, even though the device is
capable of supporting Ethernet (e.g., via USB host adapters).
This leads to Ethernet working but various connectivity APIs
behaving as if it was not - for example, no CONNECTIVITY_ACTION
broadcasts will be issues when it connects or disconnects.

Ensure that ConnectivityService always treats Ethernet as
available if the service is running. Currently the service is
started if the device supports FEATURE_ETHERNET or
FEATURE_USB_HOST.

Bug: 37359230
Test: bullhead builds, boots
Test: ConnectivityServiceTest passes
Test: Ethernet is available even if removed from networkAttributes resource
Test: ConnectivityManagerTest CTS test passes
Change-Id: I58801bf4f0bbdc3ff6345ec6bfdc911ce045c8ab
2017-09-27 13:03:10 +09:00
Hugo Benichi
883604a9fd Merge changes Ia47e566b,Ib94d79a9 am: d8eae0de70 am: 53eee16439
am: b91bd88c5e

Change-Id: Ied2b31c9d1219b8aebf5fec085ab598b77bede6e
2017-09-26 13:05:41 +00:00
Hugo Benichi
bf737c0a6b Extract RingBuffer class from NetdEventListenerService
This patch takes out the ring buffer array added for NFLOG wakeup packet
events logging and extract it into its own class for reuse. This new
RingBuffer class has the two minimal useful functions append() and
toArray().

Bug: 65164242
Bug: 65700460
Test: runtest frameworks-net, with new unit test
Change-Id: Ib94d79a93f4e99661b7d0fac67117b91d57af980
2017-09-26 14:14:16 +09:00
Erik Kline
0bbe489393 Merge "Also support 464xlat on SUSPENDED networks" am: 995a28d334 am: 698b2ee406
am: 1347ac8109

Change-Id: I83ae39a2e36bc036dce419c80dd476d2358b4537
2017-09-21 12:06:05 +00:00
Erik Kline
0b01b0f191 Also support 464xlat on SUSPENDED networks
Test: as follows
    - built
    - flashed
    - booted
    - runtest frameworks-net passes
Bug: 65684232

Change-Id: I1b10aab01554b1f926ec7157dba78645fdaff90f
2017-09-21 18:06:29 +09:00
Hugo Benichi
49289269b1 Merge changes Ied9d0cec,I3087f446,Ibe706872 into oc-mr1-dev
* changes:
  Wakeup packet events: addressing a few comments
  Connectivity metrics: add WakeupStats events
  Connectivity metrics: collect NFLOG wakeup events
2017-09-20 00:58:35 +00:00
Charles He
e25293089d Merge changes from topic "vpn-dialog" am: 85afa50569 am: b692194f38
am: a9f6384b6a

Change-Id: I853f48a75865008ac8b976eec1af56fb1870a1b3
2017-09-19 08:25:16 +00:00
Charles He
85afa50569 Merge changes from topic "vpn-dialog"
* changes:
  Unbreak VPN unit tests.
  Add alert dialog when always-on VPN disconnects.
2017-09-19 07:56:44 +00:00
Charles He
ca55d7bda7 Unbreak VPN unit tests.
VpnTest was broken earlier due to a change to always-on VPN
notifications. This CL adds the corresponding mocks to the unit test to
fix it.

Bug: 36650087
Bug: 65439160
Test: runtest frameworks-net
Change-Id: Icff57c7e927c135d75a7d70ff347a579c5d45134
Merged-In: Icff57c7e927c135d75a7d70ff347a579c5d45134
(cherry picked from commit 5da89994b9)
2017-09-19 07:56:36 +00:00
Charles He
65e8bd2e04 Merge changes from topic "always-on-vpn"
* changes:
  Opt-out for always-on VPN: rename API.
  Opt-out for always-on VPN
2017-09-19 07:50:13 +00:00
Hugo Benichi
17d5101e99 Merge "Wakeup packet events: addressing a few comments" am: efd7e6d7a9 am: ca88876b58
am: 19625788a1

Change-Id: I8ca2a01a95acaaca2599563efd6a21e4372d1f95
2017-09-19 07:36:12 +00:00
Hugo Benichi
6c35b8082c Wakeup packet events: addressing a few comments
This patch addresses a few post-submit comment for
commits f562ac34a51dc and 60c9f63b66921.

Bug: 34901696
Bug: 62179647
Test: runtest frameworks-net
Merged-In: I4abec57e0c6bc869dc57b5eb54582dd977b64c30

(cherry picked from commit 175b574e27daa0d8832b8cc9615a15fce998309a)

Change-Id: Ied9d0cec98685e5a91ed2ca2c81ad88d7ae8d751
2017-09-19 16:14:19 +09:00
Hugo Benichi
d4a29081c1 Wakeup packet events: addressing a few comments
This patch addresses a few post-submit comment for
commits f562ac34a51dc and 60c9f63b66921.

Bug: 34901696
Bug: 62179647
Test: runtest frameworks-net
Change-Id: I4abec57e0c6bc869dc57b5eb54582dd977b64c30
2017-09-19 14:07:47 +09:00
Hugo Benichi
611f62c6b9 Connectivity metrics: add WakeupStats events
This patch defines a new WakeupStats event in ipconnectivity.proto and
populates these events from the NFLOG wakeup events stored in
NetdEventListenerService.

There is one WakeupStats object per known interface on which ingress
packets arrive and may wake the system up.

Example from $ adb shell dumpsys connmetrics list:

...
WakeupStats(wlan0, total: 58, root: 0, system: 3, apps: 38, non-apps: 0, unrouted: 17, 6111s)
WakeupEvent(13:36:31.686, iface wlan0, uid -1)
WakeupEvent(13:38:50.846, iface wlan0, uid -1)
WakeupEvent(13:39:16.676, iface wlan0, uid 10065)
WakeupEvent(13:40:32.144, iface wlan0, uid 1000)
WakeupEvent(13:40:35.827, iface wlan0, uid 1000)
WakeupEvent(13:40:47.913, iface wlan0, uid 10004)
WakeupEvent(13:40:52.622, iface wlan0, uid 10014)
WakeupEvent(13:41:06.036, iface wlan0, uid 10004)
...

Bug: 34901696
Bug: 62179647
Test: runtest frameworks-net
Merged-In: Ie2676b20bfb411a1902f4942643df0c20e268d99

(cherry pick from commit 60c9f63b66926745603978e1bd6372b3a44561d1)

Change-Id: I3087f446fc998fc1ca895d975b80c4a1dd029bf3
2017-09-15 10:36:24 +09:00
Hugo Benichi
8b3f87160b Connectivity metrics: collect NFLOG wakeup events
This patch stores NFLOG packet wakeup events sent by Netd to the system
server into a ring buffer inside NetdEventListenerService. The content
of this buffer is accessible by $ dumpsys connmetrics or $ dumpsys
connmetrics list, and is added to bug reports.

The wakeup event buffer stores currently uid and timestamps.

Bug: 34901696
Bug: 62179647
Test: runtest frameworks-net, new unit tests

Merged-In: Ie8db6f8572b1a929a20398d8dc03e189bc488382

(cherry picked from commit f562ac34a51da55e4d15e34f0cd1cb597e7d926c)

Change-Id: Ibe706872a80dfd06abd9779a2116ca7e4bc0fb77
2017-09-15 10:35:17 +09:00
Hugo Benichi
46510068bc Merge changes I4719b4dc,I0308cdf4,I38db1bb7 am: e5090f2547 am: 1cbdfb6460
am: b025492a6b

Change-Id: I5385a3747e039a42e86034f7632edd0f855b2eb1
2017-09-14 18:11:06 +00:00
Hugo Benichi
b5141eb1d4 Merge changes Ie2676b20,Ie8db6f85 am: f33207512a am: 3b0c20458d
am: 7d16886c7e

Change-Id: Ifd0ace409909d258db3738e58126bbf1c48af5dc
2017-09-14 18:02:14 +00:00
Hugo Benichi
e5090f2547 Merge changes I4719b4dc,I0308cdf4,I38db1bb7
* changes:
  IpManagerTest: fix flaky test
  Fix flaky NsdManagerTest
  Boostrap test for NetworkMonitor
2017-09-14 11:59:58 +00:00
Hugo Benichi
3c15d11b94 Connectivity metrics: add WakeupStats events
This patch defines a new WakeupStats event in ipconnectivity.proto and
populates these events from the NFLOG wakeup events stored in
NetdEventListenerService.

There is one WakeupStats object per known interface on which ingress
packets arrive and may wake the system up.

Example from $ adb shell dumpsys connmetrics list:

UPDATEME
...
WakeupStats(wlan0, total: 58, root: 0, system: 3, apps: 38, non-apps: 0, unrouted: 17, 6111s)
WakeupEvent(13:36:31.686, iface wlan0, uid -1)
WakeupEvent(13:38:50.846, iface wlan0, uid -1)
WakeupEvent(13:39:16.676, iface wlan0, uid 10065)
WakeupEvent(13:40:32.144, iface wlan0, uid 1000)
WakeupEvent(13:40:35.827, iface wlan0, uid 1000)
WakeupEvent(13:40:47.913, iface wlan0, uid 10004)
WakeupEvent(13:40:52.622, iface wlan0, uid 10014)
WakeupEvent(13:41:06.036, iface wlan0, uid 10004)
...

Bug: 34901696
Bug: 62179647
Test: runtest frameworks-net
Change-Id: Ie2676b20bfb411a1902f4942643df0c20e268d99
2017-09-14 13:29:56 +09:00
Hugo Benichi
ce2d1859b2 Fix flaky NsdManagerTest
Bad synchronization between the mock handler and the test assertions
were causing testDiscoverService() to sometime fails (1/50 ~ 1/100 repro
rate).

Bug: 32561414
Bug: 62918393
Test: runtest frameworks-net, NsdManager#testDiscoverService now passes
      1000 times without errors.
Change-Id: I0308cdf48fc6bdc2fc9b4e8f7d5241a1cf2ea443
2017-09-13 18:38:53 +09:00
Hugo Benichi
454d55d822 Boostrap test for NetworkMonitor
This will finally allow to write captive portal detection unit tests.

Bug: 32561414
Bug: 62918393
Test: runtest frameworks-net
Change-Id: I38db1bb79ae80a82b4199dc9cb1b56257e0cf222
2017-09-13 16:21:50 +09:00