Fix IP address cleanup on network disconnect
We used to bring down the interface on network disconnect
which would in turn clean up all the IP addresses.
The interface bringup/shutdown is now handled by wpa_supplicant.
Add netd interface for clearing all IP addresses
Bug: 4676254
Change-Id: I7e24c0ab2e4a412b8d61e9c33ce028966913aaf6
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index 2190b30..bb0c671 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -311,6 +311,18 @@
}
}
+ /* TODO: This is right now a IPv4 only function. Works for wifi which loses its
+ IPv6 addresses on interface down, but we need to do full clean up here */
+ public void clearInterfaceAddresses(String iface) throws IllegalStateException {
+ String cmd = String.format("interface clearaddrs %s", iface);
+ try {
+ mConnector.doCommand(cmd);
+ } catch (NativeDaemonConnectorException e) {
+ throw new IllegalStateException(
+ "Unable to communicate with native daemon to interface clearallips - " + e);
+ }
+ }
+
public void addRoute(String interfaceName, RouteInfo route) {
modifyRoute(interfaceName, ADD, route);
}