Unbreak interface add/delete notifications.
The change to enable address tracking via netlink incorrectly
changed the subsystem of rtnetlink events from "net" to
"interface". This broke interface add/delete notifications,
which come from the kernel with subsystem "net".
Switch back to "net" and deal with address tracking via new
action codes instead of a new subsystem.
Bug: 10433320
Change-Id: I59a50e9c7cb49f46e680c7d84ac8e196a861ca4b
diff --git a/NetlinkHandler.cpp b/NetlinkHandler.cpp
index 753b92b..5d8a8b5 100644
--- a/NetlinkHandler.cpp
+++ b/NetlinkHandler.cpp
@@ -52,7 +52,7 @@
return;
}
- if (!strcmp(subsys, "interface")) {
+ if (!strcmp(subsys, "net")) {
int action = evt->getAction();
const char *iface = evt->findParam("INTERFACE");
@@ -67,16 +67,14 @@
notifyInterfaceLinkChanged(iface, true);
} else if (action == evt->NlActionLinkDown) {
notifyInterfaceLinkChanged(iface, false);
- }
-
- } else if (!strcmp(subsys, "address")) {
- const char *address = evt->findParam("ADDRESS");
- const char *iface = evt->findParam("IFACE");
- const char *flags = evt->findParam("FLAGS");
- const char *scope = evt->findParam("SCOPE");
-
- if (iface && flags && scope) {
- notifyAddressChanged(evt->getAction(), address, iface, flags, scope);
+ } else if (action == evt->NlActionAddressUpdated ||
+ action == evt->NlActionAddressRemoved) {
+ const char *address = evt->findParam("ADDRESS");
+ const char *flags = evt->findParam("FLAGS");
+ const char *scope = evt->findParam("SCOPE");
+ if (iface && flags && scope) {
+ notifyAddressChanged(action, address, iface, flags, scope);
+ }
}
} else if (!strcmp(subsys, "qlog")) {
@@ -161,8 +159,8 @@
const char *scope) {
char msg[255];
snprintf(msg, sizeof(msg), "Address %s %s %s %s %s",
- (action == NetlinkEvent::NlActionAdd) ? "updated" : "removed",
- addr, iface, flags, scope);
+ (action == NetlinkEvent::NlActionAddressUpdated) ?
+ "updated" : "removed", addr, iface, flags, scope);
mNm->getBroadcaster()->sendBroadcast(ResponseCode::InterfaceAddressChange,
msg, false);