diff options
author | Mike Yu <yumike@google.com> | 2022-09-20 08:25:01 +0000 |
---|---|---|
committer | Mike Yu <yumike@google.com> | 2022-12-07 07:02:59 +0000 |
commit | 1166d0ad103e76f6e782a0caf626644a6069fb3b (patch) | |
tree | 642e29c019e4ff68f44a5deb7029428cfcdeacf9 /doh | |
parent | 3265440f590e31954126dcf70406ce89fe8cedae (diff) | |
download | DnsResolver-1166d0ad103e76f6e782a0caf626644a6069fb3b.tar.gz |
Use quiche 0.14.0
bug: 233719694
Test: cd external/rust/crates/quiche && atest
Test: cd packages/modules/DnsResolver && atest
Change-Id: If48774f7591e076c0ab102984c7f247edf0f7717
Merged-In: If48774f7591e076c0ab102984c7f247edf0f7717
(cherry picked from commit 4ef6a9c2dd290c82ede8fbcb1a0a68d5ddcfe6c8)
Diffstat (limited to 'doh')
-rw-r--r-- | doh/connection/driver.rs | 42 | ||||
-rw-r--r-- | doh/tests/doh_frontend/src/client.rs | 5 |
2 files changed, 29 insertions, 18 deletions
diff --git a/doh/connection/driver.rs b/doh/connection/driver.rs index f452d0a0..315fc130 100644 --- a/doh/connection/driver.rs +++ b/doh/connection/driver.rs @@ -23,7 +23,6 @@ use std::collections::HashMap; use std::default::Default; use std::future; use std::io; -use std::pin::Pin; use thiserror::Error; use tokio::net::UdpSocket; use tokio::select; @@ -80,7 +79,7 @@ const MAX_UDP_PACKET_SIZE: usize = 65536; struct Driver { request_rx: mpsc::Receiver<Request>, status_tx: watch::Sender<Status>, - quiche_conn: Pin<Box<quiche::Connection>>, + quiche_conn: quiche::Connection, socket: UdpSocket, // This buffer is large, boxing it will keep it // off the stack and prevent it being copied during @@ -119,7 +118,7 @@ async fn optional_timeout(timeout: Option<boot_time::Duration>, net_id: u32) { pub async fn drive( request_rx: mpsc::Receiver<Request>, status_tx: watch::Sender<Status>, - quiche_conn: Pin<Box<quiche::Connection>>, + quiche_conn: quiche::Connection, socket: UdpSocket, net_id: u32, ) -> Result<()> { @@ -130,7 +129,7 @@ impl Driver { fn new( request_rx: mpsc::Receiver<Request>, status_tx: watch::Sender<Status>, - quiche_conn: Pin<Box<quiche::Connection>>, + quiche_conn: quiche::Connection, socket: UdpSocket, net_id: u32, ) -> Self { @@ -163,7 +162,8 @@ impl Driver { self.quiche_conn.peer_error() ); // We don't care if the receiver has hung up - let _ = self.status_tx.send(Status::Dead { session: self.quiche_conn.session() }); + let session = self.quiche_conn.session().map(<[_]>::to_vec); + let _ = self.status_tx.send(Status::Dead { session }); Err(Error::Closed) } else { Ok(()) @@ -180,7 +180,8 @@ impl Driver { self.quiche_conn.peer_error() ); // We don't care if the receiver has hung up - let _ = self.status_tx.send(Status::Dead { session: self.quiche_conn.session() }); + let session = self.quiche_conn.session().map(<[_]>::to_vec); + let _ = self.status_tx.send(Status::Dead { session }); self.request_rx.close(); // Drain the pending DNS requests from the queue to make their corresponding future @@ -265,10 +266,8 @@ impl H3Driver { let _ = self.driver.status_tx.send(Status::H3); loop { if let Err(e) = self.drive_once().await { - let _ = self - .driver - .status_tx - .send(Status::Dead { session: self.driver.quiche_conn.session() }); + let session = self.driver.quiche_conn.session().map(<[_]>::to_vec); + let _ = self.driver.status_tx.send(Status::Dead { session }); return Err(e); } } @@ -445,17 +444,30 @@ impl H3Driver { ); self.respond(stream_id) } - // This clause is for quiche 0.10.x, we're still on 0.9.x - //h3::Event::Reset(e) => { - // self.streams.get_mut(&stream_id).map(|stream| stream.error = Some(e)); - // self.respond(stream_id); - //} + h3::Event::Reset(e) => { + debug!( + "process_h3_event: h3::Event::Reset with error code {} on stream ID {}, network {}", + e, stream_id, self.driver.net_id + ); + if let Some(stream) = self.streams.get_mut(&stream_id) { + stream.error = Some(e) + } + self.respond(stream_id); + } h3::Event::Datagram => { warn!("Unexpected Datagram received"); // We don't care if something went wrong with the datagram, we didn't // want it anyways. let _ = self.discard_datagram(stream_id); } + h3::Event::PriorityUpdate => { + debug!( + "process_h3_event: h3::Event::PriorityUpdate on stream ID {}, network {}", + stream_id, self.driver.net_id + ); + // It tells us that PRIORITY_UPDATE frame is received, but we are not + // using it in our code currently. No-op should be fine. + } h3::Event::GoAway => self.shutdown(false, b"SERVER GOAWAY").await?, } Ok(()) diff --git a/doh/tests/doh_frontend/src/client.rs b/doh/tests/doh_frontend/src/client.rs index 8e3d2965..0a33ef45 100644 --- a/doh/tests/doh_frontend/src/client.rs +++ b/doh/tests/doh_frontend/src/client.rs @@ -21,7 +21,6 @@ use log::{debug, error, info, warn}; use quiche::h3::NameValue; use std::collections::{hash_map, HashMap}; use std::net::SocketAddr; -use std::pin::Pin; use std::time::Duration; pub const DNS_HEADER_SIZE: usize = 12; @@ -35,7 +34,7 @@ const URL_PATH_PREFIX: &str = "/dns-query?dns="; /// Manages a QUIC and HTTP/3 connection. No socket I/O operations. pub struct Client { /// QUIC connection. - conn: Pin<Box<quiche::Connection>>, + conn: quiche::Connection, /// HTTP/3 connection. h3_conn: Option<quiche::h3::Connection>, @@ -59,7 +58,7 @@ pub struct Client { } impl Client { - fn new(conn: Pin<Box<quiche::Connection>>, addr: &SocketAddr, id: ConnectionID) -> Client { + fn new(conn: quiche::Connection, addr: &SocketAddr, id: ConnectionID) -> Client { Client { conn, h3_conn: None, |