am a0b3fef0: Merge "Get rid of an infinite loop in NetlinkEvent.cpp."
* commit 'a0b3fef0b78e8c6ef38eac6bcd6da7db6a841522': Get rid of an infinite loop in NetlinkEvent.cpp.
This commit is contained in:
commit
ee676317b0
1 changed files with 7 additions and 8 deletions
|
|
@ -78,7 +78,7 @@ void NetlinkEvent::dump() {
|
||||||
*/
|
*/
|
||||||
bool NetlinkEvent::parseIfAddrMessage(int type, struct ifaddrmsg *ifaddr,
|
bool NetlinkEvent::parseIfAddrMessage(int type, struct ifaddrmsg *ifaddr,
|
||||||
int rtasize) {
|
int rtasize) {
|
||||||
struct rtattr *rta = IFA_RTA(ifaddr);
|
struct rtattr *rta;
|
||||||
struct ifa_cacheinfo *cacheinfo = NULL;
|
struct ifa_cacheinfo *cacheinfo = NULL;
|
||||||
char addrstr[INET6_ADDRSTRLEN] = "";
|
char addrstr[INET6_ADDRSTRLEN] = "";
|
||||||
|
|
||||||
|
|
@ -91,7 +91,8 @@ bool NetlinkEvent::parseIfAddrMessage(int type, struct ifaddrmsg *ifaddr,
|
||||||
// For log messages.
|
// For log messages.
|
||||||
const char *msgtype = (type == RTM_NEWADDR) ? "RTM_NEWADDR" : "RTM_DELADDR";
|
const char *msgtype = (type == RTM_NEWADDR) ? "RTM_NEWADDR" : "RTM_DELADDR";
|
||||||
|
|
||||||
while(RTA_OK(rta, rtasize)) {
|
for (rta = IFA_RTA(ifaddr); RTA_OK(rta, rtasize);
|
||||||
|
rta = RTA_NEXT(rta, rtasize)) {
|
||||||
if (rta->rta_type == IFA_ADDRESS) {
|
if (rta->rta_type == IFA_ADDRESS) {
|
||||||
// Only look at the first address, because we only support notifying
|
// Only look at the first address, because we only support notifying
|
||||||
// one change at a time.
|
// one change at a time.
|
||||||
|
|
@ -157,8 +158,6 @@ bool NetlinkEvent::parseIfAddrMessage(int type, struct ifaddrmsg *ifaddr,
|
||||||
asprintf(&mParams[6], "CSTAMP=%u", cacheinfo->cstamp);
|
asprintf(&mParams[6], "CSTAMP=%u", cacheinfo->cstamp);
|
||||||
asprintf(&mParams[7], "TSTAMP=%u", cacheinfo->tstamp);
|
asprintf(&mParams[7], "TSTAMP=%u", cacheinfo->tstamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
rta = RTA_NEXT(rta, rtasize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addrstr[0] == '\0') {
|
if (addrstr[0] == '\0') {
|
||||||
|
|
@ -173,10 +172,11 @@ bool NetlinkEvent::parseIfAddrMessage(int type, struct ifaddrmsg *ifaddr,
|
||||||
* Parse an binary message from a NETLINK_ROUTE netlink socket.
|
* Parse an binary message from a NETLINK_ROUTE netlink socket.
|
||||||
*/
|
*/
|
||||||
bool NetlinkEvent::parseBinaryNetlinkMessage(char *buffer, int size) {
|
bool NetlinkEvent::parseBinaryNetlinkMessage(char *buffer, int size) {
|
||||||
size_t sz = size;
|
const struct nlmsghdr *nh;
|
||||||
const struct nlmsghdr *nh = (struct nlmsghdr *) buffer;
|
|
||||||
|
|
||||||
while (NLMSG_OK(nh, sz) && (nh->nlmsg_type != NLMSG_DONE)) {
|
for (nh = (struct nlmsghdr *) buffer;
|
||||||
|
NLMSG_OK(nh, size) && (nh->nlmsg_type != NLMSG_DONE);
|
||||||
|
nh = NLMSG_NEXT(nh, size)) {
|
||||||
|
|
||||||
if (nh->nlmsg_type == RTM_NEWLINK) {
|
if (nh->nlmsg_type == RTM_NEWLINK) {
|
||||||
int len = nh->nlmsg_len - sizeof(*nh);
|
int len = nh->nlmsg_len - sizeof(*nh);
|
||||||
|
|
@ -245,7 +245,6 @@ bool NetlinkEvent::parseBinaryNetlinkMessage(char *buffer, int size) {
|
||||||
} else {
|
} else {
|
||||||
SLOGD("Unexpected netlink message. type=0x%x\n", nh->nlmsg_type);
|
SLOGD("Unexpected netlink message. type=0x%x\n", nh->nlmsg_type);
|
||||||
}
|
}
|
||||||
nh = NLMSG_NEXT(nh, size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue