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

Unified Diff: net/quic/quic_connection.cc

Issue 698703003: Delay a QUIC server's use of the FORWARD_SECURE encrypter until the (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Change_QUIC_Reno_congestion_controller_78728349
Patch Set: set FLAGS_enable_quic_delay_forward_security to true Created 6 years, 1 month 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.h ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_connection.cc
diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc
index 934c801da0ba3d24961a444a7ce1a7a7f7e6eefc..de84000b924434390365bc6ec4ac7b3402f77e32 100644
--- a/net/quic/quic_connection.cc
+++ b/net/quic/quic_connection.cc
@@ -196,6 +196,8 @@ QuicConnection::QuicConnection(QuicConnectionId connection_id,
writer_(writer_factory.Create(this)),
owns_writer_(owns_writer),
encryption_level_(ENCRYPTION_NONE),
+ has_forward_secure_encrypter_(false),
+ first_required_forward_secure_packet_(0),
clock_(helper->GetClock()),
random_generator_(helper->GetRandomGenerator()),
connection_id_(connection_id),
@@ -457,6 +459,14 @@ bool QuicConnection::OnUnauthenticatedHeader(const QuicPacketHeader& header) {
void QuicConnection::OnDecryptedPacket(EncryptionLevel level) {
last_decrypted_packet_level_ = level;
last_packet_decrypted_ = true;
+ // If this packet was foward-secure encrypted and the forward-secure encrypter
+ // is not being used, start using it.
+ if (FLAGS_enable_quic_delay_forward_security &&
+ encryption_level_ != ENCRYPTION_FORWARD_SECURE &&
+ has_forward_secure_encrypter_ &&
+ level == ENCRYPTION_FORWARD_SECURE) {
+ SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
+ }
}
bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) {
@@ -1553,6 +1563,16 @@ void QuicConnection::OnWriteError(int error_code) {
void QuicConnection::OnSerializedPacket(
const SerializedPacket& serialized_packet) {
+ // If a forward-secure encrypter is available but is not being used and this
+ // packet's sequence number is after the first packet which requires
+ // forward security, start using the forward-secure encrypter.
+ if (FLAGS_enable_quic_delay_forward_security &&
+ encryption_level_ != ENCRYPTION_FORWARD_SECURE &&
+ has_forward_secure_encrypter_ &&
+ serialized_packet.sequence_number >=
+ first_required_forward_secure_packet_) {
+ SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
+ }
if (serialized_packet.retransmittable_frames) {
serialized_packet.retransmittable_frames->
set_encryption_level(encryption_level_);
@@ -1653,6 +1673,16 @@ void QuicConnection::OnRetransmissionTimeout() {
void QuicConnection::SetEncrypter(EncryptionLevel level,
QuicEncrypter* encrypter) {
framer_.SetEncrypter(level, encrypter);
+ if (FLAGS_enable_quic_delay_forward_security &&
+ level == ENCRYPTION_FORWARD_SECURE) {
+ has_forward_secure_encrypter_ = true;
+ first_required_forward_secure_packet_ =
+ sequence_number_of_last_sent_packet_ +
+ // 3 times the current congestion window (in slow start) should cover
+ // about two full round trips worth of packets, which should be
+ // sufficient.
+ 3 * sent_packet_manager_.GetCongestionWindow() / max_packet_length();
+ }
}
const QuicEncrypter* QuicConnection::encrypter(EncryptionLevel level) const {
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698