ethernet: prevent provisioning failure loop

Adds check to restart() to prevent an endless provisioning failure loop
that could occur when link disappears while an interface is
provisioning (triggering a subsequent provisioning failure, restart,
and so on).

Test: atest EthernetManagerTest
Bug: 265255745
Change-Id: I83decad4eae5bb1070204997bb0acd35ba4cc9f4
This commit is contained in:
Patrick Rohr 2023-01-16 06:35:36 -08:00
commit 2390fb24df

View file

@ -657,7 +657,17 @@ public class EthernetNetworkFactory {
}
void restart() {
if (DBG) Log.d(TAG, "reconnecting Ethernet");
if (DBG) Log.d(TAG, "restart IpClient");
if (mIpClient == null) {
// If restart() is called from a provisioning failure, it is
// possible that link disappeared in the meantime. In that
// case, stop() has already been called and IpClient should not
// get restarted to prevent a provisioning failure loop.
Log.i(TAG, String.format("restart() was called on stopped interface %s", name));
return;
}
stop();
start();
}