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

Commit beb34a67 authored by Mike Yu's avatar Mike Yu Committed by Automerger Merge Worker
Browse files

Add more error log in resolv_stats_set_addrs am: 354cb873

parents 1201e963 354cb873
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -131,12 +131,7 @@ int PrivateDnsConfiguration::setDot(int32_t netId, uint32_t mark,
        }
    }

    if (int n = resolv_stats_set_addrs(netId, PROTO_DOT, servers, kDotPort); n != 0) {
        LOG(WARNING) << "Failed to set DoT stats";
        return n;
    }

    return 0;
    return resolv_stats_set_addrs(netId, PROTO_DOT, servers, kDotPort);
}

void PrivateDnsConfiguration::clearDot(int32_t netId) {
+7 −23
Original line number Diff line number Diff line
@@ -70,9 +70,6 @@ using aidl::android::net::ResolverOptionsParcel;
using android::net::DnsQueryEvent;
using android::net::DnsStats;
using android::net::Experiments;
using android::net::PROTO_DOH;
using android::net::PROTO_DOT;
using android::net::PROTO_MDNS;
using android::net::PROTO_TCP;
using android::net::PROTO_UDP;
using android::net::Protocol;
@@ -1938,29 +1935,16 @@ int resolv_cache_get_expiration(unsigned netid, span<const uint8_t> query, time_
    return 0;
}

static const char* protocol_to_str(const Protocol proto) {
    switch (proto) {
        case PROTO_UDP:
            return "UDP";
        case PROTO_TCP:
            return "TCP";
        case PROTO_DOT:
            return "DOT";
        case PROTO_DOH:
            return "DOH";
        case PROTO_MDNS:
            return "MDNS";
        default:
            return "UNKNOWN";
    }
}

int resolv_stats_set_addrs(unsigned netid, Protocol proto, const std::vector<std::string>& addrs,
                           int port) {
    std::lock_guard guard(cache_mutex);
    const auto info = find_netconfig_locked(netid);

    if (info == nullptr) return -ENONET;
    if (info == nullptr) {
        LOG(WARNING) << __func__ << ": Network " << netid << " not found for "
                     << Protocol_Name(proto);
        return -ENONET;
    }

    std::vector<IPSockAddr> sockAddrs;
    sockAddrs.reserve(addrs.size());
@@ -1969,8 +1953,8 @@ int resolv_stats_set_addrs(unsigned netid, Protocol proto, const std::vector<std
    }

    if (!info->dnsStats.setAddrs(sockAddrs, proto)) {
        LOG(WARNING) << __func__ << ": netid = " << netid << ", failed to set "
                     << protocol_to_str(proto) << " stats";
        LOG(WARNING) << __func__ << ": Failed to set " << Protocol_Name(proto) << " on network "
                     << netid;
        return -EINVAL;
    }