summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2018-09-06 08:42:05 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-09-06 08:42:05 +0000
commit08d7a208e8c8b6e23d7949d5ce9bc06cb5bea538 (patch)
treea98c7cef8aea365230ca7ac8b6b3f54c17bc7288
parent460a52947192febdf99f37cb761710a46c63fd46 (diff)
parent5b43cea3c8185425fa43cb817ab26fecfd13708c (diff)
Merge "Tighten up neighbor timers if IpReachabilityMonitor is in use"
-rw-r--r--services/net/java/android/net/ip/IpClient.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/services/net/java/android/net/ip/IpClient.java b/services/net/java/android/net/ip/IpClient.java
index 3cdef1e73ae4..ccc092d3b0e7 100644
--- a/services/net/java/android/net/ip/IpClient.java
+++ b/services/net/java/android/net/ip/IpClient.java
@@ -1385,6 +1385,20 @@ public class IpClient extends StateMachine {
private boolean startIpReachabilityMonitor() {
try {
+ // TODO: Fetch these parameters from settings, and install a
+ // settings observer to watch for update and re-program these
+ // parameters (Q: is this level of dynamic updatability really
+ // necessary or does reading from settings at startup suffice?).
+ final int NUM_SOLICITS = 5;
+ final int INTER_SOLICIT_INTERVAL_MS = 750;
+ setNeighborParameters(mDependencies.getNetd(), mInterfaceName,
+ NUM_SOLICITS, INTER_SOLICIT_INTERVAL_MS);
+ } catch (Exception e) {
+ mLog.e("Failed to adjust neighbor parameters", e);
+ // Carry on using the system defaults (currently: 3, 1000);
+ }
+
+ try {
mIpReachabilityMonitor = new IpReachabilityMonitor(
mContext,
mInterfaceParams,
@@ -1863,6 +1877,20 @@ public class IpClient extends StateMachine {
}
}
+ private static void setNeighborParameters(
+ INetd netd, String ifName, int num_solicits, int inter_solicit_interval_ms)
+ throws RemoteException, IllegalArgumentException {
+ Preconditions.checkNotNull(netd);
+ Preconditions.checkArgument(!TextUtils.isEmpty(ifName));
+ Preconditions.checkArgument(num_solicits > 0);
+ Preconditions.checkArgument(inter_solicit_interval_ms > 0);
+
+ for (int family : new Integer[]{INetd.IPV4, INetd.IPV6}) {
+ netd.setProcSysNet(family, INetd.NEIGH, ifName, "retrans_time_ms", Integer.toString(inter_solicit_interval_ms));
+ netd.setProcSysNet(family, INetd.NEIGH, ifName, "ucast_solicit", Integer.toString(num_solicits));
+ }
+ }
+
// TODO: extract out into CollectionUtils.
static <T> boolean any(Iterable<T> coll, Predicate<T> fn) {
for (T t : coll) {