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

Commit 17bb79ae authored by Mike Yu's avatar Mike Yu
Browse files

Remove markToFwmarkString()

Log the value of network mark as hexadecimal number rather than print
each bit/variable one by one. No functionality change.

Bug: 151895202
Test: enabled the resolver debugging and checked the logs
Change-Id: I448c6487e5787c6dd0466ac76c80900ccd3b7249
parent cb902c94
Loading
Loading
Loading
Loading
+8 −16
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@
#include "DnsTlsSessionCache.h"
#include "IDnsTlsSocketObserver.h"

#include <Fwmark.h>
#include <android-base/logging.h>
#include <android-base/stringprintf.h>
#include <netdutils/SocketOption.h>
@@ -72,13 +71,6 @@ int waitForWriting(int fd, int timeoutMs = -1) {
    return TEMP_FAILURE_RETRY(poll(&fds, 1, timeoutMs));
}

std::string markToFwmarkString(unsigned mMark) {
    Fwmark mark;
    mark.intValue = mMark;
    return android::base::StringPrintf("%d, %d, %d, %d, %d", mark.netId, mark.explicitlySelected,
                                       mark.protectedFromVpn, mark.permission, mark.uidBillingDone);
}

}  // namespace

Status DnsTlsSocket::tcpConnect() {
@@ -245,9 +237,9 @@ bssl::UniquePtr<SSL> DnsTlsSocket::sslConnect(int fd) {
    }

    for (;;) {
        LOG(DEBUG) << " Calling SSL_connect with " << markToFwmarkString(mMark);
        LOG(DEBUG) << " Calling SSL_connect with mark 0x" << std::hex << mMark;
        int ret = SSL_connect(ssl.get());
        LOG(DEBUG) << " SSL_connect returned " << ret << " with " << markToFwmarkString(mMark);
        LOG(DEBUG) << " SSL_connect returned " << ret << " with mark 0x" << std::hex << mMark;
        if (ret == 1) break;  // SSL handshake complete;

        const int ssl_err = SSL_get_error(ssl.get(), ret);
@@ -257,8 +249,8 @@ bssl::UniquePtr<SSL> DnsTlsSocket::sslConnect(int fd) {
                // the TCP connection handshake, the device is waiting for the SSL handshake reply
                // from the server.
                if (int err = waitForReading(fd, mServer.connectTimeout.count()); err <= 0) {
                    PLOG(WARNING) << "SSL_connect read error " << err << ", "
                                  << markToFwmarkString(mMark);
                    PLOG(WARNING) << "SSL_connect read error " << err << ", mark 0x" << std::hex
                                  << mMark;
                    return nullptr;
                }
                break;
@@ -266,14 +258,14 @@ bssl::UniquePtr<SSL> DnsTlsSocket::sslConnect(int fd) {
                // If no application data is sent during the TCP connection handshake, the
                // device is waiting for the connection established to perform SSL handshake.
                if (int err = waitForWriting(fd, mServer.connectTimeout.count()); err <= 0) {
                    PLOG(WARNING) << "SSL_connect write error " << err << ", "
                                  << markToFwmarkString(mMark);
                    PLOG(WARNING) << "SSL_connect write error " << err << ", mark 0x" << std::hex
                                  << mMark;
                    return nullptr;
                }
                break;
            default:
                PLOG(WARNING) << "SSL_connect ssl error =" << ssl_err << ", "
                              << markToFwmarkString(mMark);
                PLOG(WARNING) << "SSL_connect ssl error =" << ssl_err << ", mark 0x" << std::hex
                              << mMark;
                return nullptr;
        }
    }