Integrate wpa_supplicant "reattach" command
Use wpa_supplicant Reattach call instead of Reassociate in
OnLinkMOnitorFailure to improve the reassociate time.
BUG=chromium:264865
TEST=unit tests, manual (see below)
CQ-DEPEND=CL:189051
Manual testing
--------------
1. Setup a device which has an atheros wifi chip (e.g. peppy, link)
2. connect to "cros airport extreme wpa2", with password "chromeos"
3. set wpa_supplicant debug level to excessive
wpa_debug excessive
4. suspend device (e.g. close lid)
5. wait >5 minutes.
6. resume device (e.g. open lid)
7. verify that Reattach is called after link failure is detected
"OnLinkMonitorFailure(): Call Reattach()" in /var/log/net.log
8. verify that device gets scan result in < 1 second
Event "Received scan results" should occur less than 1 seconds
after "Scan trigger" in /var/log/net.log
Change-Id: I9df6b090e68564f325b93c3cb44ffdc32641515f
Reviewed-on: https://chromium-review.googlesource.com/189489
Tested-by: Peter Qiu <zqiu@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Peter Qiu <zqiu@chromium.org>
diff --git a/dbus_bindings/supplicant-interface.xml b/dbus_bindings/supplicant-interface.xml
index dd6bbaf..6bb5586 100644
--- a/dbus_bindings/supplicant-interface.xml
+++ b/dbus_bindings/supplicant-interface.xml
@@ -19,6 +19,8 @@
</method>
<method name="Reassociate">
</method>
+ <method name="Reattach">
+ </method>
<method name="RemoveNetwork">
<arg name="network" type="o" direction="in"/>
</method>
diff --git a/mock_supplicant_interface_proxy.h b/mock_supplicant_interface_proxy.h
index e689f82..55211ea 100644
--- a/mock_supplicant_interface_proxy.h
+++ b/mock_supplicant_interface_proxy.h
@@ -33,6 +33,7 @@
const std::string &field,
const std::string &value));
MOCK_METHOD0(Reassociate, void());
+ MOCK_METHOD0(Reattach, void());
MOCK_METHOD0(RemoveAllNetworks, void());
MOCK_METHOD1(RemoveNetwork, void(const ::DBus::Path &network));
MOCK_METHOD1(Scan,
diff --git a/supplicant_interface_proxy.cc b/supplicant_interface_proxy.cc
index 6227109..ffd939d 100644
--- a/supplicant_interface_proxy.cc
+++ b/supplicant_interface_proxy.cc
@@ -110,6 +110,16 @@
}
}
+void SupplicantInterfaceProxy::Reattach() {
+ SLOG(DBus, 2) << __func__;
+ try {
+ return proxy_.Reattach();
+ } catch (const DBus::Error &e) {
+ LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what();
+ throw; // Re-throw the exception.
+ }
+}
+
void SupplicantInterfaceProxy::RemoveAllNetworks() {
SLOG(DBus, 2) << __func__;
try {
diff --git a/supplicant_interface_proxy.h b/supplicant_interface_proxy.h
index a3f0cd8..f7da634 100644
--- a/supplicant_interface_proxy.h
+++ b/supplicant_interface_proxy.h
@@ -43,6 +43,7 @@
const std::string &field,
const std::string &value);
virtual void Reassociate();
+ virtual void Reattach();
virtual void RemoveAllNetworks();
virtual void RemoveNetwork(const ::DBus::Path &network);
virtual void Scan(
diff --git a/supplicant_interface_proxy_interface.h b/supplicant_interface_proxy_interface.h
index 7efc7e2..3e660a7 100644
--- a/supplicant_interface_proxy_interface.h
+++ b/supplicant_interface_proxy_interface.h
@@ -29,6 +29,7 @@
const std::string &field,
const std::string &value) = 0;
virtual void Reassociate() = 0;
+ virtual void Reattach() = 0;
virtual void RemoveAllNetworks() = 0;
virtual void RemoveNetwork(const ::DBus::Path &network) = 0;
virtual void Scan(
diff --git a/wifi.cc b/wifi.cc
index 328f8e5..16d7390 100644
--- a/wifi.cc
+++ b/wifi.cc
@@ -1533,13 +1533,13 @@
try {
// This will force a transition out of connected, if we are actually
// connected.
- supplicant_interface_proxy_->Reassociate();
+ supplicant_interface_proxy_->Reattach();
// If we don't eventually get a transition back into a connected state,
// there is something wrong.
StartReconnectTimer();
- LOG(INFO) << "In " << __func__ << "(): Called Reassociate().";
+ LOG(INFO) << "In " << __func__ << "(): Called Reattach().";
} catch (const DBus::Error &e) { // NOLINT
- LOG(ERROR) << "In " << __func__ << "(): failed to call Reassociate().";
+ LOG(ERROR) << "In " << __func__ << "(): failed to call Reattach().";
return;
}
}
diff --git a/wifi_unittest.cc b/wifi_unittest.cc
index 49d80a2..ad86b86 100644
--- a/wifi_unittest.cc
+++ b/wifi_unittest.cc
@@ -2471,15 +2471,15 @@
.WillRepeatedly(Return(true));
EXPECT_CALL(log, Log(logging::LOG_INFO, _,
EndsWith("gateway was never found."))).Times(1);
- EXPECT_CALL(*GetSupplicantInterfaceProxy(), Reassociate()).Times(0);
+ EXPECT_CALL(*GetSupplicantInterfaceProxy(), Reattach()).Times(0);
OnLinkMonitorFailure();
EXPECT_CALL(log, Log(logging::LOG_INFO, _,
- EndsWith("Called Reassociate()."))).Times(1);
- EXPECT_CALL(*GetSupplicantInterfaceProxy(), Reassociate()).Times(1);
+ EndsWith("Called Reattach()."))).Times(1);
+ EXPECT_CALL(*GetSupplicantInterfaceProxy(), Reattach()).Times(1);
OnLinkMonitorFailure();
OnSupplicantVanish();
Mock::VerifyAndClearExpectations(GetSupplicantInterfaceProxy());
- EXPECT_CALL(*GetSupplicantInterfaceProxy(), Reassociate()).Times(0);
+ EXPECT_CALL(*GetSupplicantInterfaceProxy(), Reattach()).Times(0);
EXPECT_CALL(log, Log(logging::LOG_ERROR, _,
EndsWith("Cannot reassociate."))).Times(1);
OnLinkMonitorFailure();