Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Unified Diff: net/quic/quic_connection_logger.cc

Issue 159143007: Log QUIC public reset client address mismatch to a histogram. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Address review comments Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_connection_logger.h ('k') | net/quic/quic_crypto_client_stream_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_connection_logger.cc
===================================================================
--- net/quic/quic_connection_logger.cc (revision 250874)
+++ net/quic/quic_connection_logger.cc (working copy)
@@ -12,7 +12,10 @@
#include "base/values.h"
#include "net/base/net_log.h"
#include "net/quic/crypto/crypto_handshake_message.h"
+#include "net/quic/crypto/crypto_protocol.h"
+#include "net/quic/quic_socket_address_coder.h"
+using base::StringPiece;
using std::string;
namespace net {
@@ -195,6 +198,65 @@
num_consecutive_missing_packets);
}
+void UpdatePublicResetAddressMismatchHistogram(
+ const IPEndPoint& server_hello_address,
+ const IPEndPoint& public_reset_address) {
+ enum {
+ // The addresses don't match.
+ kAddressMismatch_base = 0,
+ kAddressMismatch_v4_v4 = 0,
+ kAddressMismatch_v6_v6 = 1,
+ kAddressMismatch_v4_v6 = 2,
+ kAddressMismatch_v6_v4 = 3,
+
+ // The addresses match, but the ports don't match.
+ kPortMismatch_base = 4,
+ kPortMismatch_v4_v4 = 4,
+ kPortMismatch_v6_v6 = 5,
+
+ kAddressAndPortMatch_base = 6,
+ kAddressAndPortMatch_v4_v4 = 6,
+ kAddressAndPortMatch_v6_v6 = 7,
+
+ kBoundaryValue,
+ };
+
+ // We are seemingly talking to an older server that does not support the
+ // feature, so we can't report the results in the histogram.
+ if (server_hello_address.address().empty() ||
+ public_reset_address.address().empty()) {
+ return;
+ }
+
+ int sample;
+ if (server_hello_address.address() != public_reset_address.address()) {
+ sample = kAddressMismatch_base;
+ } else if (server_hello_address.port() != public_reset_address.port()) {
+ sample = kPortMismatch_base;
+ } else {
+ sample = kAddressAndPortMatch_base;
+ }
+
+ // Add an offset to |sample|:
+ // v4_v4: add 0
+ // v6_v6: add 1
+ // v4_v6: add 2
+ // v6_v4: add 3
+ bool first_ipv4 =
+ (server_hello_address.address().size() == kIPv4AddressSize);
+ bool second_ipv4 =
+ (public_reset_address.address().size() == kIPv4AddressSize);
+ if (first_ipv4 != second_ipv4) {
+ CHECK_EQ(sample, kAddressMismatch_base);
+ sample += 2;
+ }
+ if (!first_ipv4) {
+ sample += 1;
+ }
+ UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.PublicResetAddressMismatch",
+ sample, kBoundaryValue);
+}
+
} // namespace
QuicConnectionLogger::QuicConnectionLogger(const BoundNetLog& net_log)
@@ -393,6 +455,8 @@
void QuicConnectionLogger::OnPublicResetPacket(
const QuicPublicResetPacket& packet) {
net_log_.AddEvent(NetLog::TYPE_QUIC_SESSION_PUBLIC_RESET_PACKET_RECEIVED);
+ UpdatePublicResetAddressMismatchHistogram(client_address_,
+ packet.client_address);
}
void QuicConnectionLogger::OnVersionNegotiationPacket(
@@ -415,6 +479,15 @@
net_log_.AddEvent(
NetLog::TYPE_QUIC_SESSION_CRYPTO_HANDSHAKE_MESSAGE_RECEIVED,
base::Bind(&NetLogQuicCryptoHandshakeMessageCallback, &message));
+
+ if (message.tag() == kSHLO) {
+ StringPiece address;
+ QuicSocketAddressCoder decoder;
+ if (message.GetStringPiece(kCADR, &address) &&
+ decoder.Decode(address.data(), address.size())) {
+ client_address_ = IPEndPoint(decoder.ip(), decoder.port());
+ }
+ }
}
void QuicConnectionLogger::OnCryptoHandshakeMessageSent(
« no previous file with comments | « net/quic/quic_connection_logger.h ('k') | net/quic/quic_crypto_client_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698