Commit Graph

23 Commits

Author SHA1 Message Date
Lorenzo Colitti
9effed6f9e Make Ethernet more robust.
1. Remove the IP provisioning thread and just attempt
   provisioning indefinitely whenever we have an interface.
2. Make all methods run on the passed-in handler thread. This
   makes it easier to verify correctness by code inspection.
3. Remove the code that changes the factory score depending on
   whether we're tracking an interface and have link. This is
   unnecessary complexity, as there is no penalty to accepting a
   request even if we don't have an interface.
4. Remove code duplication and only have one codepath for
   stopping layer 3.

Tested the following are tested with this CL:
- Booting with an interface connected.
- Disconnecting/reconnecting the Ethernet cable repeatedly,
  particularly at inconvenient times (e.g., during provisioning).
- Similarly, disconnecting/reconnecting USB Ethernet interfaces.
- Falling back to another Ethernet interface if the currently
  tracked Ethernet interface is unplugged.
- Disconnecting and restarting provisioning when provisioning is
  lost (e.g., if the default route is deleted).
- Crashing the system server causes Ethernet to reconnect on
  restart.
- The above while running watch -n 0.1 adb shell dumpsys ethernet

Bug: 62308954
Test: tested on marlin with USB ethernet adapters, as described
Change-Id: Iad12a52a903bfaccf7e245dfe499652c752c31e9
2017-06-09 14:01:29 +09:00
Lorenzo Colitti
0587321554 Disable the IpManager timeout on Ethernet.
This fixes a longstanding bug where after a DHCP timeout, we
would never restart the DHCP client and get an IP address until
the link bounced.

Also, two minor improvements:

1. Dump IpManager info when dump() is called.
2. When onLinkPropertiesChange is called, also update
   mLinkProperties. We were already sending the updated
   LinkProperties to the NetworkAgent, so this is really only
   useful for dump(), but it's just one line and safe because
   onLinkPropertiesChange already grabs the lock.

Bug: 17733693
Change-Id: I42c3319cb4bc151c547ed721baf5e83f97e23862
2016-04-29 19:57:43 +09:00
Erik Kline
5774ef5328 Use more IpManager features
- WaitForProvisioningCallback
    - setHttpProxy
    - setTcpBufferSizes

Bug: 26991160
Change-Id: I5e02039a35006f0466fb40c43805f0443cd758c2
2016-02-22 17:41:12 +09:00
Erik Kline
1cb0138ad3 Use IpManager on Ethernet
Bug: 17733693
Bug: 26991160
Change-Id: Idaee8c64bf452e58b93031d8d7ad666edb0c82ae
2016-02-17 22:19:22 +09:00
Lorenzo Colitti
189063ffb0 Stop requiring CHANGE_NETWORK_STATE to change Ethernet config.
Requiring CHANGE_NETWORK_STATE is pointless, since immediately
after doing that we require CONNECTIVITY_INTERNAL, which is
a system-only permission.

Bug: 23597341
Change-Id: If4c8ecbb319e547c2c81d2dcc3c7bbb63e0bc2af
2015-10-15 16:59:07 +09:00
Lorenzo Colitti
baabe41348 Don't crash on startup if we can't fetch the interface list.
The intent of the code was to catch exceptions, but it wasn't
actually doing that because when a netd command fails we get an
IllegalStateException, not a RemoteException.

Bug: 23581852
Change-Id: I66c7c33bdc7b0d0de4fa5cd92dff054797cf860f
2015-09-08 16:21:52 +09:00
Billy Lau
824a0a5050 Bug: 21588539 Move CHANGE_NETWORK_STATE to be in SYSTEM_SETTINGS
Replaced the method where we used to enforce static permission
CHANGE_NETWORK_STATE to method calls that also check for WRITE_SETTINGS.
This is due to the merging of CHANGE_NETWORK_STATE permission with
WRITE_SETTINGS in M.

Change-Id: I104ac41733663b4f6b5cd30e7314574ec4acdc07
2015-08-07 19:00:49 +01:00
Lorenzo Colitti
9830ae6d92 Stop DHCP if it times out.
This was not necessary in L, but it is necessary after
https://partner-android-review.googlesource.com/#/c/205415/ .

Bug: 22936203
Change-Id: I24a96c33e5bb375f36217a1c2cec2076eb5ac8b4
2015-08-04 14:54:10 +09:00
Pierre Couillaud
b1d214c5a5 am 566e12ad: eth: make sure dhcp is stopped before bringing up interface.
* commit '566e12ad11445a4b90d615fd823b53a2c1eba9be':
  eth: make sure dhcp is stopped before bringing up interface.
2015-02-16 07:58:48 +00:00
Pierre Couillaud
566e12ad11 eth: make sure dhcp is stopped before bringing up interface.
Signed-off-by: Pierre Couillaud <pierre@broadcom.com>
Signed-off-by: Blair Prescott <blairp@broadcom.com>
2015-02-11 11:31:22 -08:00
Jaewan Kim
f4740f2d37 Add an API to check availability of Ethernet interface.
Bug: 18045481
Change-Id: I3fb517c3e7fa807e2937fda92026301e312be986
2014-11-19 11:13:41 +09:00
Lorenzo Colitti
272be52cb7 Clear all Ethernet state when our interface goes away.
Previously we did not stop DHCP or try to force a disconnect.
This made it impossible to reconnect by unplugging and
replugging an USB Ethernet adapter.

Bug: 17736828
Change-Id: Idd8576a96b063b5ca726ee9149800bdcb0f62bd1
2014-10-01 13:52:40 +09:00
Robert Greenwalt
cf0f619a50 Don't accept score below 0.
Network Factories are allowed to go below, but networks need to be
constrained.  Allowing the network to go below 0 meant that -1 could
sometimes leak through and foul the logic.

bug:17361330
Change-Id: Ife34ca0f9c233dd3c3df80f6fea580af43afcdeb
2014-09-10 10:06:32 -07:00
Robert Greenwalt
eee07beb92 Use config resource for tcp buffer size
bug:16549611
Change-Id: I48426f6b746e4bd9729bdd529d81b163ff5112a9
2014-08-21 16:28:18 -07:00
Lorenzo Colitti
1affc58cb6 Actually provide useful output in Ethernet service dump.
Bug: 17133859
Change-Id: Ic8424004e48712e4dd906d5bb6a48ce7d38ff9d8
2014-08-19 20:03:35 -07:00
Lorenzo Colitti
c0cfe2ee04 Stop using LinkProperties for static configuration.
Also make static IP configuration more robust (e.g., tear down
our NetworkAgent when we switch between static and DHCP).

Bug: 16114392
Bug: 16893413
Change-Id: Ib33f35c004e30b6067bb20235ffa43c247d174df
2014-08-19 11:57:35 -07:00
Robert Greenwalt
84502f5300 Add tcp buffer size data for ethernet
bug: 16549611
Change-Id: I61d29bb88b9e58c50e03c39570f3ebb7712e4f37
2014-08-15 15:10:05 -07:00
Robert Greenwalt
62e8e4d3d5 DO NOT MERGE Don't tear down based on NetworkFactory input.
NetworkFactory only indicates if we're interested in new connections.  It
shouldn't be used to tear down existing connections (they have unwanted callbacks
for that).

Supports linger properly as well as dealing with tie scores.

bug:15612739
Change-Id: Ib3dfe673d3645b9dc4756c176958409a64ec32e4
(cherry picked from commit 8b07ee36a2)
2014-07-22 17:38:42 +00:00
Robert Greenwalt
694a835e89 Make NetworkCapabilities publicly immutable.
Applying API council comments.

bug: 15142362
Change-Id: Ie0bde68b72656a676d90c0343b9756fe9268d8d6
2014-06-11 18:36:52 +00:00
Robert Greenwalt
521b2bd483 Fix ethernet.
It was attempting to update the NetworkAgent before the NetworkAgent
was created, causing NullPointerExceptions.

bug:15407938
Change-Id: Ie36b906df4b12f095a16d1b30c847a55b074d60c
2014-06-04 11:52:08 -07:00
Robert Greenwalt
301c18a01d Apply refactored NetworkFactory.
Make NetworkFactory a concrete class and divide responsibilites between it and NetworkAgent.
Factory will track requests and by default give a single connect/disconnect api for ease
of use.  Then NetworkAgent is created and destroyed as needed with very simple logic.

Change-Id: I401c14a6e5466f2fc63b04219b97ff85bb9af291
(cherry picked from commit 8af038d056)
2014-06-03 01:22:54 +00:00
Lorenzo Colitti
0ffeaf5c76 DO NOT MERGE - Make Ethernet more reliable.
1. If DHCP fails, set the score to 0. Coupled with changes in
   NetworkAgent, that will cause us to retry DHCP the next time
   the link is plugged in.
2. Send LinkProperties before sending NetworkInfo, because of
   a race in NetworkAgent.
3. Make Ethernet work properly after a runtime restart.
4. Improve locking.
5. Clarify how things work in comments.

Bug: 15295359
Change-Id: I06cd683a1633838bca1ec177e61f1829889d3934
(cherry picked from commit 21be8b6dc7)
2014-05-28 09:29:21 +00:00
Lorenzo Colitti
eb730a7ffc Initial EthernetService implementation.
Bug: 14981801
Bug: 14993642
Change-Id: If392ef7063e096854ef830f4fe3b038439a1d307
2014-05-21 19:53:04 -07:00