Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f9bd9b3 authored by Lorenzo Colitti's avatar Lorenzo Colitti Committed by Automerger Merge Worker
Browse files

Merge "Parse IFA_F_* values above 0x80." am: b7dd2935

Change-Id: I4d09aba3c71dff620f0f8873bfc5c413bb7e2919
parents 6cf64c12 b7dd2935
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -180,6 +180,7 @@ bool NetlinkEvent::parseIfAddrMessage(const struct nlmsghdr *nh) {
    struct ifa_cacheinfo *cacheinfo = nullptr;
    char addrstr[INET6_ADDRSTRLEN] = "";
    char ifname[IFNAMSIZ] = "";
    uint32_t flags = 0;

    if (!checkRtNetlinkLength(nh, sizeof(*ifaddr)))
        return false;
@@ -230,6 +231,10 @@ bool NetlinkEvent::parseIfAddrMessage(const struct nlmsghdr *nh) {
                SLOGD("Unknown ifindex %d in %s", ifaddr->ifa_index, msgtype);
            }

            // First 8 bits of flags. In practice will always be overridden by the IFA_FLAGS below,
            // because that always appears after IFA_ADDRESS. But just in case, support both orders.
            flags = (flags & 0xffffff00) | ifaddr->ifa_flags;

        } else if (rta->rta_type == IFA_CACHEINFO) {
            // Address lifetime information.
            if (maybeLogDuplicateAttribute(cacheinfo, "IFA_CACHEINFO", msgtype))
@@ -242,6 +247,10 @@ bool NetlinkEvent::parseIfAddrMessage(const struct nlmsghdr *nh) {
            }

            cacheinfo = (struct ifa_cacheinfo *) RTA_DATA(rta);

        } else if (rta->rta_type == IFA_FLAGS) {
            // In practice IFA_FLAGS is always after IFA_ADDRESS, so this will overwrite the flags.
            flags = *(uint32_t*)RTA_DATA(rta);
        }
    }

@@ -256,7 +265,7 @@ bool NetlinkEvent::parseIfAddrMessage(const struct nlmsghdr *nh) {
    mSubsystem = strdup("net");
    asprintf(&mParams[0], "ADDRESS=%s/%d", addrstr, ifaddr->ifa_prefixlen);
    asprintf(&mParams[1], "INTERFACE=%s", ifname);
    asprintf(&mParams[2], "FLAGS=%u", ifaddr->ifa_flags);
    asprintf(&mParams[2], "FLAGS=%u", flags);
    asprintf(&mParams[3], "SCOPE=%u", ifaddr->ifa_scope);
    asprintf(&mParams[4], "IFINDEX=%u", ifaddr->ifa_index);