From 2390fb24dfd82139ebca3daf06095082ea5a757f Mon Sep 17 00:00:00 2001 From: Patrick Rohr Date: Mon, 16 Jan 2023 06:35:36 -0800 Subject: [PATCH] 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 --- .../server/ethernet/EthernetNetworkFactory.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java index 51683deb05..60485f19c8 100644 --- a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java +++ b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java @@ -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(); }