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

Unified Diff: net/quic/quic_session_test.cc

Issue 448973002: Close a QUIC connection if there are too many unfinished streams being (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Remove_unused_version_argument_72559549
Patch Set: Created 6 years, 4 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_session.cc ('k') | net/quic/quic_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_session_test.cc
diff --git a/net/quic/quic_session_test.cc b/net/quic/quic_session_test.cc
index a81d1f5bb116025fe696c70a76a56141f4f41a04..b604a7ffee1f19c3b0793913313cbc4f6d123974 100644
--- a/net/quic/quic_session_test.cc
+++ b/net/quic/quic_session_test.cc
@@ -11,6 +11,7 @@
#include "base/containers/hash_tables.h"
#include "net/quic/crypto/crypto_protocol.h"
#include "net/quic/quic_crypto_stream.h"
+#include "net/quic/quic_flags.h"
#include "net/quic/quic_protocol.h"
#include "net/quic/quic_utils.h"
#include "net/quic/reliable_quic_stream.h"
@@ -903,6 +904,35 @@ TEST_P(QuicSessionTest, VersionNegotiationDisablesFlowControl) {
EXPECT_FALSE(stream->flow_controller()->IsEnabled());
}
+TEST_P(QuicSessionTest, TooManyUnfinishedStreamsCauseConnectionClose) {
+ if (version() < QUIC_VERSION_18) {
+ return;
+ }
+ // If a buggy/malicious peer creates too many streams that are not ended with
+ // a FIN or RST then we send a connection close.
+ ValueRestore<bool> old_flag(&FLAGS_close_quic_connection_unfinished_streams,
+ true);
+
+ EXPECT_CALL(*connection_,
+ SendConnectionClose(QUIC_TOO_MANY_UNFINISHED_STREAMS)).Times(1);
+
+ const int kMaxStreams = 5;
+ QuicSessionPeer::SetMaxOpenStreams(&session_, kMaxStreams);
+
+ // Create kMaxStreams + 1 data streams, and close them all without receiving a
+ // FIN or a RST from the client.
+ const int kFirstStreamId = kClientDataStreamId1;
+ const int kFinalStreamId = kClientDataStreamId1 + 2 * kMaxStreams + 1;
+ for (int i = kFirstStreamId; i < kFinalStreamId; i += 2) {
+ QuicStreamFrame data1(i, false, 0, MakeIOVector("HT"));
+ vector<QuicStreamFrame> frames;
+ frames.push_back(data1);
+ session_.OnStreamFrames(frames);
+ EXPECT_EQ(1u, session_.GetNumOpenStreams());
+ session_.CloseStream(i);
+ }
+}
+
} // namespace
} // namespace test
} // namespace net
« no previous file with comments | « net/quic/quic_session.cc ('k') | net/quic/quic_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698