gfe-relnote: Combine quic_no_stream_data_after_reset and quic_no_decrease_in_final_offset into a single flag gfe2_reloadable_flag_quic_close_connection_and_discard_data_on_wrong_offset to impose flag dependency.
PiperOrigin-RevId: 280710051
Change-Id: I2ab0c396d4cb44c144204908f15952b61fbc9761
diff --git a/quic/core/quic_stream_sequencer.cc b/quic/core/quic_stream_sequencer.cc
index 57651ef..d797668 100644
--- a/quic/core/quic_stream_sequencer.cc
+++ b/quic/core/quic_stream_sequencer.cc
@@ -35,7 +35,9 @@
ignore_read_data_(false),
level_triggered_(false),
stop_reading_when_level_triggered_(
- GetQuicReloadableFlag(quic_stop_reading_when_level_triggered)) {
+ GetQuicReloadableFlag(quic_stop_reading_when_level_triggered)),
+ close_connection_and_discard_data_on_wrong_offset_(GetQuicReloadableFlag(
+ quic_close_connection_and_discard_data_on_wrong_offset)) {
if (stop_reading_when_level_triggered_) {
QUIC_RELOADABLE_FLAG_COUNT(quic_stop_reading_when_level_triggered);
}
@@ -54,8 +56,9 @@
if (data_len == 0) {
return;
}
- if (GetQuicReloadableFlag(quic_no_stream_data_after_reset)) {
- QUIC_RELOADABLE_FLAG_COUNT(quic_no_stream_data_after_reset);
+ if (close_connection_and_discard_data_on_wrong_offset_) {
+ QUIC_RELOADABLE_FLAG_COUNT_N(
+ quic_close_connection_and_discard_data_on_wrong_offset, 1, 3);
if (!should_process_data) {
return;
}
@@ -130,11 +133,12 @@
// If there is a scheduled close, the new offset should match it.
if (close_offset_ != kMaxOffset && offset != close_offset_) {
- if (!GetQuicReloadableFlag(quic_no_decrease_in_final_offset)) {
+ if (!close_connection_and_discard_data_on_wrong_offset_) {
stream_->Reset(QUIC_MULTIPLE_TERMINATION_OFFSETS);
return false;
}
- QUIC_RELOADABLE_FLAG_COUNT_N(quic_no_decrease_in_final_offset, 1, 2);
+ QUIC_RELOADABLE_FLAG_COUNT_N(
+ quic_close_connection_and_discard_data_on_wrong_offset, 2, 3);
stream_->CloseConnectionWithDetails(
QUIC_STREAM_SEQUENCER_INVALID_STATE,
QuicStrCat("Stream ", stream_->id(),
@@ -145,16 +149,16 @@
// The final offset should be no less than the highest offset that is
// received.
- if (GetQuicReloadableFlag(quic_no_decrease_in_final_offset)) {
- QUIC_RELOADABLE_FLAG_COUNT_N(quic_no_decrease_in_final_offset, 2, 2);
- if (offset < highest_offset_) {
- stream_->CloseConnectionWithDetails(
- QUIC_STREAM_SEQUENCER_INVALID_STATE,
- QuicStrCat(
- "Stream ", stream_->id(), " received fin with offset: ", offset,
- ", which reduces current highest offset: ", highest_offset_));
- return false;
- }
+ if (close_connection_and_discard_data_on_wrong_offset_ &&
+ offset < highest_offset_) {
+ QUIC_RELOADABLE_FLAG_COUNT_N(
+ quic_close_connection_and_discard_data_on_wrong_offset, 3, 3);
+ stream_->CloseConnectionWithDetails(
+ QUIC_STREAM_SEQUENCER_INVALID_STATE,
+ QuicStrCat(
+ "Stream ", stream_->id(), " received fin with offset: ", offset,
+ ", which reduces current highest offset: ", highest_offset_));
+ return false;
}
close_offset_ = offset;
diff --git a/quic/core/quic_stream_sequencer.h b/quic/core/quic_stream_sequencer.h
index 54e0e28..878acb0 100644
--- a/quic/core/quic_stream_sequencer.h
+++ b/quic/core/quic_stream_sequencer.h
@@ -211,6 +211,11 @@
// the sequencer will discard incoming data (but not FIN bits) after
// StopReading is called, even in level_triggered_ mode.
const bool stop_reading_when_level_triggered_;
+
+ // Latched value of quic_close_connection_and_discard_data_on_wrong_offset.
+ // When true, the sequencer will inform the stream to close connection when
+ // wrong offset is received. And the stream frame's data will be discarded.
+ const bool close_connection_and_discard_data_on_wrong_offset_;
};
} // namespace quic
diff --git a/quic/core/quic_stream_sequencer_test.cc b/quic/core/quic_stream_sequencer_test.cc
index 15484d8..cb6fb93 100644
--- a/quic/core/quic_stream_sequencer_test.cc
+++ b/quic/core/quic_stream_sequencer_test.cc
@@ -375,7 +375,8 @@
OnFinFrame(3, "");
EXPECT_EQ(3u, QuicStreamSequencerPeer::GetCloseOffset(sequencer_.get()));
- if (!GetQuicReloadableFlag(quic_no_decrease_in_final_offset)) {
+ if (!GetQuicReloadableFlag(
+ quic_close_connection_and_discard_data_on_wrong_offset)) {
EXPECT_CALL(stream_, Reset(QUIC_MULTIPLE_TERMINATION_OFFSETS));
} else {
EXPECT_CALL(stream_, CloseConnectionWithDetails(
@@ -760,15 +761,14 @@
// Regression test for https://crbug.com/992486.
TEST_F(QuicStreamSequencerTest, CorruptFinFrames) {
- SetQuicReloadableFlag(quic_no_stream_data_after_reset, true);
- if (!GetQuicReloadableFlag(quic_no_decrease_in_final_offset)) {
- EXPECT_CALL(stream_, Reset(QUIC_MULTIPLE_TERMINATION_OFFSETS));
- } else {
- EXPECT_CALL(stream_, CloseConnectionWithDetails(
- QUIC_STREAM_SEQUENCER_INVALID_STATE,
- "Stream 1 received new final offset: 1, which is "
- "different from close offset: 2"));
+ if (!GetQuicReloadableFlag(
+ quic_close_connection_and_discard_data_on_wrong_offset)) {
+ return;
}
+ EXPECT_CALL(stream_, CloseConnectionWithDetails(
+ QUIC_STREAM_SEQUENCER_INVALID_STATE,
+ "Stream 1 received new final offset: 1, which is "
+ "different from close offset: 2"));
OnFinFrame(2u, "");
OnFinFrame(0u, "a");
@@ -777,7 +777,10 @@
// Regression test for crbug.com/1015693
TEST_F(QuicStreamSequencerTest, ReceiveFinLessThanHighestOffset) {
- SetQuicReloadableFlag(quic_no_decrease_in_final_offset, true);
+ if (!GetQuicReloadableFlag(
+ quic_close_connection_and_discard_data_on_wrong_offset)) {
+ return;
+ }
EXPECT_CALL(stream_, OnDataAvailable()).Times(1);
EXPECT_CALL(stream_, CloseConnectionWithDetails(
QUIC_STREAM_SEQUENCER_INVALID_STATE,