Skip to content

Commit a67d4da

Browse files
committed
h3: remove duplicated stream type validation
The `Stream::set_frame_type()` already checks whether a frame is allowed on a specific type of stream, so we don't have to check it again while processing the frame.
1 parent a9db5d2 commit a67d4da

2 files changed

Lines changed: 6 additions & 70 deletions

File tree

‎quiche/src/h3/mod.rs‎

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2877,16 +2877,6 @@ impl Connection {
28772877
},
28782878

28792879
frame::Frame::Headers { header_block } => {
2880-
if Some(stream_id) == self.peer_control_stream_id {
2881-
conn.close(
2882-
true,
2883-
Error::FrameUnexpected.to_wire(),
2884-
b"HEADERS received on control stream",
2885-
)?;
2886-
2887-
return Err(Error::FrameUnexpected);
2888-
}
2889-
28902880
// Servers reject too many HEADERS frames.
28912881
if let Some(s) = self.streams.get_mut(&stream_id) {
28922882
if self.is_server && s.headers_received_count() == 2 {
@@ -2961,30 +2951,10 @@ impl Connection {
29612951
},
29622952

29632953
frame::Frame::Data { .. } => {
2964-
if Some(stream_id) == self.peer_control_stream_id {
2965-
conn.close(
2966-
true,
2967-
Error::FrameUnexpected.to_wire(),
2968-
b"DATA received on control stream",
2969-
)?;
2970-
2971-
return Err(Error::FrameUnexpected);
2972-
}
2973-
29742954
// Do nothing. The Data event is returned separately.
29752955
},
29762956

29772957
frame::Frame::GoAway { id } => {
2978-
if Some(stream_id) != self.peer_control_stream_id {
2979-
conn.close(
2980-
true,
2981-
Error::FrameUnexpected.to_wire(),
2982-
b"GOAWAY received on non-control stream",
2983-
)?;
2984-
2985-
return Err(Error::FrameUnexpected);
2986-
}
2987-
29882958
if !self.is_server && id % 4 != 0 {
29892959
conn.close(
29902960
true,
@@ -3013,16 +2983,6 @@ impl Connection {
30132983
},
30142984

30152985
frame::Frame::MaxPushId { push_id } => {
3016-
if Some(stream_id) != self.peer_control_stream_id {
3017-
conn.close(
3018-
true,
3019-
Error::FrameUnexpected.to_wire(),
3020-
b"MAX_PUSH_ID received on non-control stream",
3021-
)?;
3022-
3023-
return Err(Error::FrameUnexpected);
3024-
}
3025-
30262986
if !self.is_server {
30272987
conn.close(
30282988
true,
@@ -3071,16 +3031,6 @@ impl Connection {
30713031
},
30723032

30733033
frame::Frame::CancelPush { .. } => {
3074-
if Some(stream_id) != self.peer_control_stream_id {
3075-
conn.close(
3076-
true,
3077-
Error::FrameUnexpected.to_wire(),
3078-
b"CANCEL_PUSH received on non-control stream",
3079-
)?;
3080-
3081-
return Err(Error::FrameUnexpected);
3082-
}
3083-
30843034
// TODO: implement CANCEL_PUSH frame
30853035
},
30863036

@@ -3098,16 +3048,6 @@ impl Connection {
30983048
return Err(Error::FrameUnexpected);
30993049
}
31003050

3101-
if Some(stream_id) != self.peer_control_stream_id {
3102-
conn.close(
3103-
true,
3104-
Error::FrameUnexpected.to_wire(),
3105-
b"PRIORITY_UPDATE received on non-control stream",
3106-
)?;
3107-
3108-
return Err(Error::FrameUnexpected);
3109-
}
3110-
31113051
if prioritized_element_id % 4 != 0 {
31123052
conn.close(
31133053
true,
@@ -3170,16 +3110,6 @@ impl Connection {
31703110
return Err(Error::FrameUnexpected);
31713111
}
31723112

3173-
if Some(stream_id) != self.peer_control_stream_id {
3174-
conn.close(
3175-
true,
3176-
Error::FrameUnexpected.to_wire(),
3177-
b"PRIORITY_UPDATE received on non-control stream",
3178-
)?;
3179-
3180-
return Err(Error::FrameUnexpected);
3181-
}
3182-
31833113
if prioritized_element_id % 3 != 0 {
31843114
conn.close(
31853115
true,

‎quiche/src/h3/stream.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,12 @@ impl Stream {
349349
(frame::MAX_PUSH_FRAME_TYPE_ID, _) =>
350350
return Err(Error::FrameUnexpected),
351351

352+
(frame::PRIORITY_UPDATE_FRAME_REQUEST_TYPE_ID, _) =>
353+
return Err(Error::FrameUnexpected),
354+
355+
(frame::PRIORITY_UPDATE_FRAME_PUSH_TYPE_ID, _) =>
356+
return Err(Error::FrameUnexpected),
357+
352358
// All other frames can be ignored regardless of stream
353359
// state.
354360
_ => (),

0 commit comments

Comments
 (0)