diff options
author | Kai Shi <kaishi@google.com> | 2020-02-10 18:49:15 -0800 |
---|---|---|
committer | Kai Shi <kaishi@google.com> | 2020-02-12 14:01:54 -0800 |
commit | 8da501dd29ae22e722de2c372570a08b27e10c98 (patch) | |
tree | 1d04ca41887728a73031bbbd616f9814178a312a /service | |
parent | 145f07c0fe0f60f0d13886a20ce47c8a41081712 (diff) |
Trigger bugreport at high auth failure rate
Trigger bugreport when high auth failure rate (>=80%) happens in an
enterprise network at high RSSI with enough connection attempts (>=5).
This is done in debug build only. The minimum interval between two
captures is 60 mins.
Test: unit test with atest com.android.server.wifi
Test: manual
Bug: 149256555
Change-Id: I57f99a404400d8b4b77f1199646c6917bd090627
Diffstat (limited to 'service')
3 files changed, 50 insertions, 16 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java index ebdfb6864..137d0cfe6 100644 --- a/service/java/com/android/server/wifi/ClientModeImpl.java +++ b/service/java/com/android/server/wifi/ClientModeImpl.java @@ -2797,7 +2797,7 @@ public class ClientModeImpl extends StateMachine { if (level2FailureCode != WifiMetrics.ConnectionEvent.FAILURE_NONE) { - int bssidBlocklistMonitorReason = convertToBssidBlocklistMonitorFailureReason( + int blocklistReason = convertToBssidBlocklistMonitorFailureReason( level2FailureCode, level2FailureReason); String bssid = mLastBssid == null ? mTargetRoamBSSID : mLastBssid; @@ -2806,26 +2806,29 @@ public class ClientModeImpl extends StateMachine { ssid = getTargetSsid(); } - if (level2FailureCode != WifiMetrics.ConnectionEvent.FAILURE_NETWORK_DISCONNECTION) { + if (blocklistReason != -1) { int networkId = (configuration == null) ? WifiConfiguration.INVALID_NETWORK_ID : configuration.networkId; int scanRssi = mWifiConfigManager.findScanRssi(networkId, SCAN_RSSI_VALID_TIME_MS); - mWifiScoreCard.noteConnectionFailure(mWifiInfo, scanRssi, ssid, - bssidBlocklistMonitorReason); - } - if (bssidBlocklistMonitorReason != -1) { - int networkId = (configuration == null) ? WifiConfiguration.INVALID_NETWORK_ID - : configuration.networkId; - ScanDetailCache scanDetailCache = - mWifiConfigManager.getScanDetailCacheForNetwork(networkId); + mWifiScoreCard.noteConnectionFailure(mWifiInfo, scanRssi, ssid, blocklistReason); + boolean isNonWrongPwdAuthFailure = + blocklistReason == BssidBlocklistMonitor.REASON_AUTHENTICATION_FAILURE + || blocklistReason == BssidBlocklistMonitor.REASON_EAP_FAILURE; + boolean isEnterpriseNetwork = configuration != null && configuration.isEnterprise(); + if (isNonWrongPwdAuthFailure && isEnterpriseNetwork + && mWifiScoreCard.detectAbnormalAuthFailure(ssid)) { + String bugTitle = "Wi-Fi BugReport"; + String bugDetail = "Abnormal authentication failure with enterprise network"; + mWifiDiagnostics.takeBugReport(bugTitle, bugDetail); + } + boolean isLowRssi = false; - int rssi = mWifiConfigManager.findScanRssi(networkId, SCAN_RSSI_VALID_TIME_MS); int sufficientRssi = getSufficientRssi(networkId, bssid); - if (rssi != WifiInfo.INVALID_RSSI && sufficientRssi != WifiInfo.INVALID_RSSI) { - isLowRssi = rssi < sufficientRssi; + if (scanRssi != WifiInfo.INVALID_RSSI && sufficientRssi != WifiInfo.INVALID_RSSI) { + isLowRssi = scanRssi < sufficientRssi; } - mBssidBlocklistMonitor.handleBssidConnectionFailure(bssid, ssid, - bssidBlocklistMonitorReason, isLowRssi); + mBssidBlocklistMonitor.handleBssidConnectionFailure(bssid, ssid, blocklistReason, + isLowRssi); } } diff --git a/service/java/com/android/server/wifi/WifiDiagnostics.java b/service/java/com/android/server/wifi/WifiDiagnostics.java index f047f3273..1a8e7feaf 100644 --- a/service/java/com/android/server/wifi/WifiDiagnostics.java +++ b/service/java/com/android/server/wifi/WifiDiagnostics.java @@ -107,6 +107,9 @@ class WifiDiagnostics extends BaseWifiDiagnostics { /** Minimum dump period with same error code */ public static final long MIN_DUMP_TIME_WINDOW_MILLIS = 10 * 60 * 1000; // 10 mins + private long mLastBugReportTime; + static final long MIN_BUG_REPORT_TIME_WINDOW_MILLIS = 60 * 60 * 1000; // 60 mins + @VisibleForTesting public static final String FIRMWARE_DUMP_SECTION_HEADER = "FW Memory dump"; @VisibleForTesting public static final String DRIVER_DUMP_SECTION_HEADER = @@ -288,7 +291,8 @@ class WifiDiagnostics extends BaseWifiDiagnostics { } /** - * Initiates a system-level bugreport, in a non-blocking fashion. + * Initiates a system-level bug report if there is no bug report taken recently. + * This is done in a non-blocking fashion. */ @Override public void takeBugReport(String bugTitle, String bugDetail) { @@ -297,6 +301,12 @@ class WifiDiagnostics extends BaseWifiDiagnostics { R.bool.config_wifi_diagnostics_bugreport_enabled)) { return; } + long currentTime = mClock.getWallClockMillis(); + if ((currentTime - mLastBugReportTime) < MIN_BUG_REPORT_TIME_WINDOW_MILLIS + && mLastBugReportTime > 0) { + return; + } + mLastBugReportTime = currentTime; BugreportManager bugreportManager = mContext.getSystemService(BugreportManager.class); BugreportParams params = new BugreportParams(BugreportParams.BUGREPORT_MODE_WIFI); try { diff --git a/service/java/com/android/server/wifi/WifiScoreCard.java b/service/java/com/android/server/wifi/WifiScoreCard.java index 8553f0023..e01580546 100644 --- a/service/java/com/android/server/wifi/WifiScoreCard.java +++ b/service/java/com/android/server/wifi/WifiScoreCard.java @@ -109,6 +109,10 @@ public class WifiScoreCard { private static final int MIN_NUM_DISCONNECTION = 20; private static final int MIN_NUM_DISCONNECTION_PREV = 40; + // Minimum number of connection attempts to qualify abnormal auth detection + static final int MIN_NUM_CONNECTION_ATTEMPT_ABNORMAL_AUTH_FAILURE = 5; + static final int FAILURE_PERCENT_THRESHOLD_ABNORMAL_AUTH_FAILURE = 80; + static final int INSUFFICIENT_RECENT_STATS = 0; static final int SUFFICIENT_RECENT_STATS_ONLY = 1; static final int SUFFICIENT_RECENT_PREV_STATS = 2; @@ -565,6 +569,23 @@ public class WifiScoreCard { } } + /** + * Detect abnormal authentication failure at high RSSI with enough connection attempts + * and high failure rate + * @return true if abnormal auth failure is detected, false otherwise + */ + public boolean detectAbnormalAuthFailure(String ssid) { + PerNetwork perNetwork = lookupNetwork(ssid); + NetworkConnectionStats recentStats = perNetwork.getRecentStats(); + logd("detectAbnormalAuthFailure: " + recentStats.toString()); + int numAuthFailure = recentStats.getCount(CNT_AUTHENTICATION_FAILURE); + int numAttempt = recentStats.getCount(CNT_CONNECTION_ATTEMPT); + boolean hasEnoughAttempt = numAttempt >= MIN_NUM_CONNECTION_ATTEMPT_ABNORMAL_AUTH_FAILURE; + boolean isAuthFailureRateHigh = (numAuthFailure * 100) + >= (numAttempt * FAILURE_PERCENT_THRESHOLD_ABNORMAL_AUTH_FAILURE); + return hasEnoughAttempt && isAuthFailureRateHigh; + } + final class PerBssid extends MemoryStoreAccessBase { public int id; public final String ssid; |