Upgrade quiche to 0.17.1
This change is made by the following steps:
$ rm patches/Initial-stateless-reset-detection.patch patches/Android.bp.patch
$ ../../../../tools/external_updater/updater.sh update rust/crates/quiche
$ (add a new Android.bp.patch in patches/)
$ cargo2android.py --config cargo2android.json
$ rm -rf cargo.out target.tmp/
Bug: 277315978
Ignore-AOSP-First: Can't merge the quiche-0.17.1 upgrade in AOSP first
because the code change in external/rust/crates/quiche doesn't
automerge into udc-mainline-prod (the code change in
packages/modules/DnsResolver does). Will cherry-pick the change to
AOSP after this change mergers into master.
Test: cd external/rust/crates/quiche && atest
Test: cd packages/modules/DnsResolver && atest
Change-Id: I87acbb95e943eb41e89c56acf470cf6de6254dbe
(cherry picked from commit 794f6f0480f0e5b71486e48c776bfb9b8bc77998)
diff --git a/src/frame.rs b/src/frame.rs
index f568b29..2addb8d 100644
--- a/src/frame.rs
+++ b/src/frame.rs
@@ -47,14 +47,14 @@
pub const MAX_STREAM_OVERHEAD: usize = 12;
pub const MAX_STREAM_SIZE: u64 = 1 << 62;
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq, Eq)]
pub struct EcnCounts {
ect0_count: u64,
ect1_count: u64,
ecn_ce_count: u64,
}
-#[derive(Clone, PartialEq)]
+#[derive(Clone, PartialEq, Eq)]
pub enum Frame {
Padding {
len: usize,
@@ -185,8 +185,6 @@
) -> Result<Frame> {
let frame_type = b.get_varint()?;
- // println!("GOT FRAME {:x}", frame_type);
-
let frame = match frame_type {
0x00 => {
let mut len = 1;
@@ -428,7 +426,7 @@
},
Frame::Crypto { data } => {
- encode_crypto_header(data.off() as u64, data.len() as u64, b)?;
+ encode_crypto_header(data.off(), data.len() as u64, b)?;
b.put_bytes(data)?;
},
@@ -445,7 +443,7 @@
Frame::Stream { stream_id, data } => {
encode_stream_header(
*stream_id,
- data.off() as u64,
+ data.off(),
data.len() as u64,
data.fin(),
b,
@@ -641,7 +639,7 @@
Frame::Crypto { data } => {
1 + // frame type
- octets::varint_len(data.off() as u64) + // offset
+ octets::varint_len(data.off()) + // offset
2 + // length, always encode as 2-byte varint
data.len() // data
},
@@ -662,7 +660,7 @@
Frame::Stream { stream_id, data } => {
1 + // frame type
octets::varint_len(*stream_id) + // stream_id
- octets::varint_len(data.off() as u64) + // offset
+ octets::varint_len(data.off()) + // offset
2 + // length, always encode as 2-byte varint
data.len() // data
},
@@ -800,6 +798,16 @@
)
}
+ pub fn probing(&self) -> bool {
+ matches!(
+ self,
+ Frame::Padding { .. } |
+ Frame::NewConnectionId { .. } |
+ Frame::PathChallenge { .. } |
+ Frame::PathResponse { .. }
+ )
+ }
+
#[cfg(feature = "qlog")]
pub fn to_qlog(&self) -> QuicFrame {
match self {
@@ -866,18 +874,21 @@
Frame::NewToken { token } => QuicFrame::NewToken {
token: qlog::Token {
// TODO: pick the token type some how
- ty: Some(qlog::TokenType::StatelessReset),
- length: None,
- data: qlog::HexSlice::maybe_string(Some(token)),
+ ty: Some(qlog::TokenType::Retry),
+ raw: Some(qlog::events::RawInfo {
+ data: qlog::HexSlice::maybe_string(Some(token)),
+ length: Some(token.len() as u64),
+ payload_length: None,
+ }),
details: None,
},
},
Frame::Stream { stream_id, data } => QuicFrame::Stream {
stream_id: *stream_id,
- offset: data.off() as u64,
+ offset: data.off(),
length: data.len() as u64,
- fin: data.fin().then(|| true),
+ fin: data.fin().then_some(true),
raw: None,
},
@@ -940,12 +951,9 @@
retire_prior_to: *retire_prior_to as u32,
connection_id_length: Some(conn_id.len() as u8),
connection_id: format!("{}", qlog::HexSlice::new(conn_id)),
- stateless_reset_token: Some(qlog::Token {
- ty: Some(qlog::TokenType::StatelessReset),
- length: None,
- data: qlog::HexSlice::maybe_string(Some(reset_token)),
- details: None,
- }),
+ stateless_reset_token: qlog::HexSlice::maybe_string(Some(
+ reset_token,
+ )),
},
Frame::RetireConnectionId { seq_num } =>
@@ -963,8 +971,8 @@
} => QuicFrame::ConnectionClose {
error_space: Some(ErrorSpace::TransportError),
error_code: Some(*error_code),
- raw_error_code: None, // raw error is no different for us
- reason: Some(String::from_utf8(reason.clone()).unwrap()),
+ error_code_value: None, // raw error is no different for us
+ reason: Some(String::from_utf8_lossy(reason).into_owned()),
trigger_frame_type: None, // don't know trigger type
},
@@ -972,8 +980,8 @@
QuicFrame::ConnectionClose {
error_space: Some(ErrorSpace::ApplicationError),
error_code: Some(*error_code),
- raw_error_code: None, // raw error is no different for us
- reason: Some(String::from_utf8(reason.clone()).unwrap()),
+ error_code_value: None, // raw error is no different for us
+ reason: Some(String::from_utf8_lossy(reason).into_owned()),
trigger_frame_type: None, // don't know trigger type
},
@@ -996,7 +1004,7 @@
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Frame::Padding { len } => {
- write!(f, "PADDING len={}", len)?;
+ write!(f, "PADDING len={len}")?;
},
Frame::Ping => {
@@ -1010,8 +1018,7 @@
} => {
write!(
f,
- "ACK delay={} blocks={:?} ecn_counts={:?}",
- ack_delay, ranges, ecn_counts
+ "ACK delay={ack_delay} blocks={ranges:?} ecn_counts={ecn_counts:?}"
)?;
},
@@ -1022,8 +1029,7 @@
} => {
write!(
f,
- "RESET_STREAM stream={} err={:x} size={}",
- stream_id, error_code, final_size
+ "RESET_STREAM stream={stream_id} err={error_code:x} size={final_size}"
)?;
},
@@ -1031,11 +1037,7 @@
stream_id,
error_code,
} => {
- write!(
- f,
- "STOP_SENDING stream={} err={:x}",
- stream_id, error_code
- )?;
+ write!(f, "STOP_SENDING stream={stream_id} err={error_code:x}")?;
},
Frame::Crypto { data } => {
@@ -1043,7 +1045,7 @@
},
Frame::CryptoHeader { offset, length } => {
- write!(f, "CRYPTO off={} len={}", offset, length)?;
+ write!(f, "CRYPTO off={offset} len={length}")?;
},
Frame::NewToken { .. } => {
@@ -1069,61 +1071,67 @@
} => {
write!(
f,
- "STREAM id={} off={} len={} fin={}",
- stream_id, offset, length, fin
+ "STREAM id={stream_id} off={offset} len={length} fin={fin}"
)?;
},
Frame::MaxData { max } => {
- write!(f, "MAX_DATA max={}", max)?;
+ write!(f, "MAX_DATA max={max}")?;
},
Frame::MaxStreamData { stream_id, max } => {
- write!(f, "MAX_STREAM_DATA stream={} max={}", stream_id, max)?;
+ write!(f, "MAX_STREAM_DATA stream={stream_id} max={max}")?;
},
Frame::MaxStreamsBidi { max } => {
- write!(f, "MAX_STREAMS type=bidi max={}", max)?;
+ write!(f, "MAX_STREAMS type=bidi max={max}")?;
},
Frame::MaxStreamsUni { max } => {
- write!(f, "MAX_STREAMS type=uni max={}", max)?;
+ write!(f, "MAX_STREAMS type=uni max={max}")?;
},
Frame::DataBlocked { limit } => {
- write!(f, "DATA_BLOCKED limit={}", limit)?;
+ write!(f, "DATA_BLOCKED limit={limit}")?;
},
Frame::StreamDataBlocked { stream_id, limit } => {
write!(
f,
- "STREAM_DATA_BLOCKED stream={} limit={}",
- stream_id, limit
+ "STREAM_DATA_BLOCKED stream={stream_id} limit={limit}"
)?;
},
Frame::StreamsBlockedBidi { limit } => {
- write!(f, "STREAMS_BLOCKED type=bidi limit={}", limit)?;
+ write!(f, "STREAMS_BLOCKED type=bidi limit={limit}")?;
},
Frame::StreamsBlockedUni { limit } => {
- write!(f, "STREAMS_BLOCKED type=uni limit={}", limit)?;
+ write!(f, "STREAMS_BLOCKED type=uni limit={limit}")?;
},
- Frame::NewConnectionId { .. } => {
- write!(f, "NEW_CONNECTION_ID (TODO)")?;
+ Frame::NewConnectionId {
+ seq_num,
+ retire_prior_to,
+ conn_id,
+ reset_token,
+ } => {
+ write!(
+ f,
+ "NEW_CONNECTION_ID seq_num={seq_num} retire_prior_to={retire_prior_to} conn_id={conn_id:02x?} reset_token={reset_token:02x?}",
+ )?;
},
- Frame::RetireConnectionId { .. } => {
- write!(f, "RETIRE_CONNECTION_ID (TODO)")?;
+ Frame::RetireConnectionId { seq_num } => {
+ write!(f, "RETIRE_CONNECTION_ID seq_num={seq_num}")?;
},
Frame::PathChallenge { data } => {
- write!(f, "PATH_CHALLENGE data={:02x?}", data)?;
+ write!(f, "PATH_CHALLENGE data={data:02x?}")?;
},
Frame::PathResponse { data } => {
- write!(f, "PATH_RESPONSE data={:02x?}", data)?;
+ write!(f, "PATH_RESPONSE data={data:02x?}")?;
},
Frame::ConnectionClose {
@@ -1133,16 +1141,14 @@
} => {
write!(
f,
- "CONNECTION_CLOSE err={:x} frame={:x} reason={:x?}",
- error_code, frame_type, reason
+ "CONNECTION_CLOSE err={error_code:x} frame={frame_type:x} reason={reason:x?}"
)?;
},
Frame::ApplicationClose { error_code, reason } => {
write!(
f,
- "APPLICATION_CLOSE err={:x} reason={:x?}",
- error_code, reason
+ "APPLICATION_CLOSE err={error_code:x} reason={reason:x?}"
)?;
},
@@ -1155,7 +1161,7 @@
},
Frame::DatagramHeader { length } => {
- write!(f, "DATAGRAM len={}", length)?;
+ write!(f, "DATAGRAM len={length}")?;
},
}
@@ -1360,7 +1366,7 @@
};
assert_eq!(wire_len, 1);
- assert_eq!(&d[..wire_len], [0x01 as u8]);
+ assert_eq!(&d[..wire_len], [0x01_u8]);
let mut b = octets::Octets::with_slice(&d);
assert_eq!(Frame::from_bytes(&mut b, packet::Type::Short), Ok(frame));