InterfaceController::setBaseReachableTimeMs()
Add an InterfaceController::setBaseReachableTimeMs() method to set
the ARP/ND default reachable time, as configured in:
/proc/sys/net/ipv4/{interface}/base_reachable_time_ms
/proc/sys/net/ipv6/{interface}/base_reachable_time_ms
Bug: 18581716
Change-Id: Idc652e81396d81efe0f08bb1d6dc38bc8e554a56
diff --git a/server/InterfaceController.cpp b/server/InterfaceController.cpp
index 373bfd0..640bf8c 100644
--- a/server/InterfaceController.cpp
+++ b/server/InterfaceController.cpp
@@ -34,6 +34,10 @@
const char ipv6_proc_path[] = "/proc/sys/net/ipv6/conf";
+const char ipv4_neigh_conf_dir[] = "/proc/sys/net/ipv4/neigh";
+
+const char ipv6_neigh_conf_dir[] = "/proc/sys/net/ipv6/neigh";
+
const char sys_net_path[] = "/sys/class/net";
const char wl_util_path[] = "/system/xbin/wlutil";
@@ -86,6 +90,9 @@
// Enable optimistic DAD for IPv6 addresses on all interfaces.
setIPv6OptimisticMode("1");
+
+ // Reduce the ARP/ND base reachable time from the default (30sec) to 15sec.
+ setBaseReachableTimeMs(15 * 1000);
}
InterfaceController::~InterfaceController() {
@@ -160,6 +167,12 @@
return writeValueToPath(sys_net_path, interface, "mtu", mtu);
}
+void InterfaceController::setBaseReachableTimeMs(unsigned int millis) {
+ std::string value(StringPrintf("%u", millis));
+ setOnAllInterfaces(ipv4_neigh_conf_dir, "base_reachable_time_ms", value.c_str());
+ setOnAllInterfaces(ipv6_neigh_conf_dir, "base_reachable_time_ms", value.c_str());
+}
+
void InterfaceController::setIPv6OptimisticMode(const char *value) {
setOnAllInterfaces(ipv6_proc_path, "optimistic_dad", value);
setOnAllInterfaces(ipv6_proc_path, "use_optimistic", value);