OSDN Git Service

Reset connections whenever an address goes away.
authorSreeram Ramachandran <sreeram@google.com>
Mon, 8 Sep 2014 23:03:18 +0000 (16:03 -0700)
committerSreeram Ramachandran <sreeram@google.com>
Tue, 9 Sep 2014 06:36:42 +0000 (23:36 -0700)
Bug: 15414453
Change-Id: Ibf1f052e12b88838a328148e25817a96f10d50f5

server/NetlinkHandler.cpp

index d1dbf7d..6c81c18 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <cutils/log.h>
 
+#include <netutils/ifc.h>
 #include <sysutils/NetlinkEvent.h>
 #include "NetlinkHandler.h"
 #include "NetlinkManager.h"
@@ -76,6 +77,14 @@ void NetlinkHandler::onEvent(NetlinkEvent *evt) {
             const char *address = evt->findParam("ADDRESS");
             const char *flags = evt->findParam("FLAGS");
             const char *scope = evt->findParam("SCOPE");
+            if (action == evt->NlActionAddressRemoved && iface && address) {
+                int resetMask = strchr(address, ':') ? RESET_IPV6_ADDRESSES : RESET_IPV4_ADDRESSES;
+                resetMask |= RESET_IGNORE_INTERFACE_ADDRESS;
+                if (int ret = ifc_reset_connections(iface, resetMask)) {
+                    ALOGE("ifc_reset_connections failed on iface %s for address %s (%s)", iface,
+                          address, strerror(ret));
+                }
+            }
             if (iface && flags && scope) {
                 notifyAddressChanged(action, address, iface, flags, scope);
             }