summaryrefslogtreecommitdiff
path: root/src/android/net/ip/IpReachabilityMonitor.java
diff options
context:
space:
mode:
authorRemi NGUYEN VAN <reminv@google.com>2020-04-28 07:03:50 +0000
committerLorenzo Colitti <lorenzo@google.com>2020-05-01 06:57:49 +0000
commita51a28854f1e325fd0b9c187ab42ab05c4b4d060 (patch)
treec4ace7e3a2f54a5d43cc1cf960201b1285256880 /src/android/net/ip/IpReachabilityMonitor.java
parentb91dc8229ccbb444a0ee77939485556e64873890 (diff)
Fix potential exceptions in FdEventReader users
In particular, - Fix a possible NPE In IpNeighborMonitor, if a NUD_FAILED is received for some neighbor before all other neighbors have received RTM_NEWNEIGH. - Add try / catch in IpNeighborMonitor, DhcpPacketListener, ConnectivityPacketTracker in case some unexpected exception is thrown while processing packets. - Add Log.wtf logging in FdEventsReader in case any such exception is missed. Bug: 152842850 Test: atest NetworkStackTests Original-Change: https://android-review.googlesource.com/1274609 Merged-In: Ia03fec358e98b3f218220e70fc3265e14ca15f78 Change-Id: Ia03fec358e98b3f218220e70fc3265e14ca15f78
Diffstat (limited to 'src/android/net/ip/IpReachabilityMonitor.java')
-rw-r--r--src/android/net/ip/IpReachabilityMonitor.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/android/net/ip/IpReachabilityMonitor.java b/src/android/net/ip/IpReachabilityMonitor.java
index db928d6..2a0ca5d 100644
--- a/src/android/net/ip/IpReachabilityMonitor.java
+++ b/src/android/net/ip/IpReachabilityMonitor.java
@@ -341,7 +341,14 @@ public class IpReachabilityMonitor {
// TODO: Consider using NeighborEvent#isValid() here; it's more
// strict but may interact badly if other entries are somehow in
// NUD_INCOMPLETE (say, during network attach).
- if (entry.getValue().nudState != StructNdMsg.NUD_FAILED) continue;
+ final NeighborEvent val = entry.getValue();
+
+ // Find all the neighbors that have gone into FAILED state.
+ // Ignore entries for which we have never received an event. If there are neighbors
+ // that never respond to ARP/ND, the kernel will send several FAILED event, then
+ // an INCOMPLETE event, and then more FAILED events. The INCOMPLETE event will
+ // populate the map and the subsequent FAILED event will be processed.
+ if (val == null || val.nudState != StructNdMsg.NUD_FAILED) continue;
ip = entry.getKey();
for (RouteInfo route : mLinkProperties.getRoutes()) {
@@ -378,10 +385,12 @@ public class IpReachabilityMonitor {
Log.d(TAG, "neighbour IPv4(v6): " + entry.getKey() + " neighbour state: "
+ StructNdMsg.stringForNudState(entry.getValue().nudState));
}
- if (entry.getValue().nudState != StructNdMsg.NUD_REACHABLE) return;
+ final NeighborEvent val = entry.getValue();
+ // If an entry is null, consider that probing for that neighbour has completed.
+ if (val == null || val.nudState != StructNdMsg.NUD_REACHABLE) return;
}
- // All neighbours in the watchlist are in REACHABLE state and connection is stable,
+ // Probing for all neighbours in the watchlist is complete and the connection is stable,
// restore NUD probe parameters to steadystate value. In the case where neighbours
// are responsive, this code will run before the wakelock expires.
setNeighbourParametersForSteadyState();