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

Commit cb902c94 authored by Mike Yu's avatar Mike Yu
Browse files

Don't use Fwmark to rename threads

Use the least 16 significant bits, which are supposed to represent
netId, of the network mark for resolver threads name. This is in
preparation for dropping Fwmark used in DnsResolver.

No naming rule change.

Bug: 151895202
Test: adb shell ps -AT $(adb shell pidof netd)
Change-Id: Ie1724dc5775cdeff6ee00a51b5f74e8f8a32d5d3
parent eb85d8b0
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -37,11 +37,13 @@

namespace android {

using android::base::StringPrintf;
using android::net::NetworkDnsEventReported;
using netdutils::DumpWriter;
using netdutils::IPAddress;
using netdutils::IPPrefix;
using netdutils::ScopedAddrinfo;
using netdutils::setThreadName;

namespace net {

@@ -64,7 +66,7 @@ void Dns64Configuration::startPrefixDiscovery(unsigned netId) {

    // Note that capturing |cfg| in this lambda creates a copy.
    std::thread discovery_thread([this, cfg, netId] {
        netdutils::setThreadName(android::base::StringPrintf("Nat64Pfx_%u", netId).c_str());
        setThreadName(StringPrintf("Nat64Pfx_%u", netId).c_str());

        // Make a mutable copy rather than mark the whole lambda mutable.
        // No particular reason.
+3 −3
Original line number Diff line number Diff line
@@ -49,9 +49,11 @@

namespace android {

using base::StringPrintf;
using netdutils::enableSockopt;
using netdutils::enableTcpKeepAlives;
using netdutils::isOk;
using netdutils::setThreadName;
using netdutils::Slice;
using netdutils::Status;

@@ -321,9 +323,7 @@ void DnsTlsSocket::loop() {
    std::deque<std::vector<uint8_t>> q;
    const int timeout_msecs = DnsTlsSocket::kIdleTimeout.count() * 1000;

    Fwmark mark;
    mark.intValue = mMark;
    netdutils::setThreadName(android::base::StringPrintf("TlsListen_%u", mark.netId).c_str());
    setThreadName(StringPrintf("TlsListen_%u", mMark & 0xffff).c_str());
    while (true) {
        // poll() ignores negative fds
        struct pollfd fds[2] = { { .fd = -1 }, { .fd = -1 } };
+4 −4
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@

#include "DnsTlsTransport.h"

#include <Fwmark.h>
#include <android-base/logging.h>
#include <android-base/stringprintf.h>
#include <arpa/inet.h>
@@ -28,6 +27,9 @@
#include "DnsTlsSocketFactory.h"
#include "IDnsTlsSocketFactory.h"

using android::base::StringPrintf;
using android::netdutils::setThreadName;

namespace android {
namespace net {

@@ -112,9 +114,7 @@ void DnsTlsTransport::onClosed() {

void DnsTlsTransport::doReconnect() {
    std::lock_guard guard(mLock);
    Fwmark mark;
    mark.intValue = mMark;
    netdutils::setThreadName(android::base::StringPrintf("TlsReconn_%u", mark.netId).c_str());
    setThreadName(StringPrintf("TlsReconn_%u", mMark & 0xffff).c_str());
    if (mClosing) {
        return;
    }
+3 −1
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@
#include "resolv_cache.h"
#include "util.h"

using android::base::StringPrintf;
using android::netdutils::setThreadName;
using std::chrono::milliseconds;

namespace android {
@@ -180,7 +182,7 @@ void PrivateDnsConfiguration::validatePrivateDnsProvider(const DnsTlsServer& ser

    // Note that capturing |server| and |netId| in this lambda create copies.
    std::thread validate_thread([this, server, netId, mark] {
        netdutils::setThreadName(android::base::StringPrintf("TlsVerify_%u", netId).c_str());
        setThreadName(StringPrintf("TlsVerify_%u", netId).c_str());

        // cat /proc/sys/net/ipv4/tcp_syn_retries yields "6".
        //