Commit e07effe6 authored by JP Abgrall's avatar JP Abgrall
Browse files

netd: Netlink: Use KOBJECT_UEVENT instead of IDLETIMER

The initial idletimer support required using NETLINK_IDLETIMER
netlink socket type.
Instead we now just re-use the existing KOBJECT_UEVENT socket.

Change-Id: I951f2f29182c7cf7f29a054a0eabc88dc25f6d1f
parent ad729ac1
......@@ -52,6 +52,8 @@ void NetlinkHandler::onEvent(NetlinkEvent *evt) {
return;
}
ALOGV("subsystem %s", subsys);
if (!strcmp(subsys, "net")) {
int action = evt->getAction();
const char *iface = evt->findParam("INTERFACE");
......@@ -68,19 +70,19 @@ void NetlinkHandler::onEvent(NetlinkEvent *evt) {
} else if (action == evt->NlActionLinkDown) {
notifyInterfaceLinkChanged(iface, false);
}
} else if (!strcmp(subsys, "qlog")) {
const char *alertName = evt->findParam("ALERT_NAME");
const char *iface = evt->findParam("INTERFACE");
notifyQuotaLimitReached(alertName, iface);
} else if (!strcmp(subsys, "idletimer")) {
} else if (!strcmp(subsys, "xt_idletimer")) {
int action = evt->getAction();
const char *iface = evt->findParam("INTERFACE");
const char *state = evt->findParam("STATE");
if (state)
notifyInterfaceActivity(iface, !strcmp("active", state));
if (action == evt->NlActionIfaceActive) {
notifyInterfaceActivity(iface, true);
} else if (action == evt->NlActionIfaceIdle) {
notifyInterfaceActivity(iface, false);
}
}
}
......@@ -129,8 +131,8 @@ void NetlinkHandler::notifyQuotaLimitReached(const char *name, const char *iface
void NetlinkHandler::notifyInterfaceActivity(const char *name, bool isActive) {
char msg[255];
snprintf(msg, sizeof(msg), "Iface %s %s", isActive ? "active" : "idle", name);
snprintf(msg, sizeof(msg), "Iface %s %s", name, isActive ? "active" : "idle");
ALOGV("Broadcasting interface activity msg: %s", msg);
mNm->getBroadcaster()->sendBroadcast(isActive ? ResponseCode::InterfaceActive
: ResponseCode::InterfaceIdle,
msg, false);
......
......@@ -34,7 +34,6 @@
#include "NetlinkHandler.h"
const int NetlinkManager::NFLOG_QUOTA_GROUP = 1;
const int NetlinkManager::IDLETIMER_GROUP = 1;
NetlinkManager *NetlinkManager::sInstance = NULL;
......@@ -113,11 +112,6 @@ int NetlinkManager::start() {
// TODO: return -1 once the emulator gets a new kernel.
}
if ((mIfaceIdleTimerHandler = setupSocket(&mIfaceIdleTimerSock, NETLINK_IDLETIMER,
IDLETIMER_GROUP, NetlinkListener::NETLINK_FORMAT_BINARY)) == NULL) {
// TODO: switch back to using NETLINK_NFLOG with a custom type.
ALOGE("Unable to open iface idletimer socket");
}
return 0;
}
......@@ -159,18 +153,5 @@ int NetlinkManager::stop() {
mQuotaSock = -1;
}
if (mIfaceIdleTimerHandler) {
if (mIfaceIdleTimerHandler->stop()) {
ALOGE("Unable to stop iface IDLETIMER NetlinkHandler: %s", strerror(errno));
status = -1;
}
delete mIfaceIdleTimerHandler;
mIfaceIdleTimerHandler = NULL;
close(mIfaceIdleTimerSock);
mIfaceIdleTimerSock = -1;
}
return status;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment