shill: Disconnect a service on DHCP lease failure
Fix a bug where failing to acquire a DHCP lease would result in
permanent device offline state. This happens because marking a service
as disconnected doesn't work through any of the logic to trigger an
actual disconnect from the actually fully associated service. For
instance, in WiFi's case, this leaves the service associated in the
eye's of wifi.cc, but in some state outside of the typical state machine
for connecting services. Thus shill does nothing, leaving users to
wonder.
device.cc should ask the service to disconnect itself rather than
changing its state unbeknownst to the service. However, there does not
seem to be a path to disconnect a service without marking the disconnect
as user initiated. Create such a path. I've gone over the callsites
and looked for places where they might assume that the service won't be
autoconnected again, and not found problems on inspection. At worst,
we'll just be auto connecting some services we didn't used to. In some
places, like cellular, it seems like we Disconnect when we find we are
roaming, which doesn't seem like a permanent/non autoconnectable
offense.
TEST=Unit tests
BUG=chromium-os:32279
Change-Id: I34b60f3c009c276efac5d7e51495dc5681bf4b5f
Reviewed-on: https://gerrit.chromium.org/gerrit/34195
Commit-Ready: Christopher Wiley <wiley@chromium.org>
Reviewed-by: Christopher Wiley <wiley@chromium.org>
Tested-by: Christopher Wiley <wiley@chromium.org>
diff --git a/device_unittest.cc b/device_unittest.cc
index 4dea30f..8686f20 100644
--- a/device_unittest.cc
+++ b/device_unittest.cc
@@ -315,7 +315,7 @@
metrics(),
manager()));
SelectService(service);
- EXPECT_CALL(*service.get(), SetState(Service::kStateDisconnected));
+ EXPECT_CALL(*service.get(), DisconnectWithFailure(Service::kFailureDHCP, _));
EXPECT_CALL(*service.get(), SetConnection(IsNullRefPtr()));
OnIPConfigUpdated(NULL, false);
}