You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "moonchen (via GitHub)" <gi...@apache.org> on 2026/06/16 14:36:34 UTC

[PR] net: count application bytes in read_bytes for TLS [trafficserver]

moonchen opened a new pull request, #13282:
URL: https://github.com/apache/trafficserver/pull/13282

   On TLS connections, net.read_bytes was only counting some bytes for the handshake, and none of the incoming ciphertext.  This is neither intuitive nor consistent with net.write_bytes.
   
   The fix for now is to make it symmetric with net.write_bytes.  Count the plaintext bytes for TLS.  This means not counting the handshake bytes.
   
   For a long term fix, I plan to add more comprehensive metrics for TLS.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] net: count application bytes in read_bytes for TLS [trafficserver]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #13282:
URL: https://github.com/apache/trafficserver/pull/13282#discussion_r3421659028


##########
doc/admin-guide/monitoring/statistics/core/network-io.en.rst:
##########
@@ -79,10 +79,18 @@ Network I/O
    :type: counter
    :units: bytes
 
+   Application-layer bytes read from client and origin connections.  For TLS
+   connections this is the decrypted payload, symmetric with ``write_bytes``; it
+   does not include TLS handshake or record-layer framing.

Review Comment:
   This PR changes the meaning of `proxy.process.net.read_bytes_count` as well (it’s now incremented alongside decrypted `read_bytes`, not raw socket reads). The docs updated here only describe `read_bytes`/`write_bytes`; please also update the documentation entry for `read_bytes_count` (if present in this document set) to match the new TLS semantics.



##########
src/iocore/net/SSLNetVConnection.cc:
##########
@@ -287,6 +287,9 @@ SSLNetVConnection::_ssl_read_from_net(int64_t &ret)
     Dbg(dbg_ctl_ssl, "bytes_read=%" PRId64, bytes_read);
 
     s->vio.ndone += bytes_read;
+    // Decrypted application bytes, to match write_bytes (also plaintext for TLS).
+    Metrics::Counter::increment(net_rsb.read_bytes, bytes_read);
+    Metrics::Counter::increment(net_rsb.read_bytes_count);

Review Comment:
   Consider explicitly guarding (or asserting) that `bytes_read > 0` before incrementing counters. If `bytes_read` can ever be `0` (clean shutdown) or negative (error paths) in this block due to future refactors, this would either skew `read_bytes_count` or potentially underflow/record an unintended value depending on `increment`'s parameter type.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] net: count application bytes in read_bytes for TLS [trafficserver]

Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen commented on PR #13282:
URL: https://github.com/apache/trafficserver/pull/13282#issuecomment-4805258820

   Cherry-picked to 10.2.x


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] net: count application bytes in read_bytes for TLS [trafficserver]

Posted by "moonchen (via GitHub)" <gi...@apache.org>.
moonchen merged PR #13282:
URL: https://github.com/apache/trafficserver/pull/13282


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] net: count application bytes in read_bytes for TLS [trafficserver]

Posted by "moonchen (via GitHub)" <gi...@apache.org>.
moonchen commented on PR #13282:
URL: https://github.com/apache/trafficserver/pull/13282#issuecomment-4720153934

   [approve ci Clang-Analyzer]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] net: count application bytes in read_bytes for TLS [trafficserver]

Posted by "moonchen (via GitHub)" <gi...@apache.org>.
moonchen commented on code in PR #13282:
URL: https://github.com/apache/trafficserver/pull/13282#discussion_r3422049835


##########
src/iocore/net/SSLNetVConnection.cc:
##########
@@ -287,6 +287,9 @@ SSLNetVConnection::_ssl_read_from_net(int64_t &ret)
     Dbg(dbg_ctl_ssl, "bytes_read=%" PRId64, bytes_read);
 
     s->vio.ndone += bytes_read;
+    // Decrypted application bytes, to match write_bytes (also plaintext for TLS).
+    Metrics::Counter::increment(net_rsb.read_bytes, bytes_read);
+    Metrics::Counter::increment(net_rsb.read_bytes_count);

Review Comment:
   This is inside an if (bytes_read > 0)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] net: count application bytes in read_bytes for TLS [trafficserver]

Posted by "moonchen (via GitHub)" <gi...@apache.org>.
moonchen commented on code in PR #13282:
URL: https://github.com/apache/trafficserver/pull/13282#discussion_r3422051356


##########
doc/admin-guide/monitoring/statistics/core/network-io.en.rst:
##########
@@ -79,10 +79,18 @@ Network I/O
    :type: counter
    :units: bytes
 
+   Application-layer bytes read from client and origin connections.  For TLS
+   connections this is the decrypted payload, symmetric with ``write_bytes``; it
+   does not include TLS handshake or record-layer framing.

Review Comment:
   Added doc for read_bytes_count



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org