Skip to content

Commit

Permalink
feat(bin): use quinn-udp crates.io release instead of git ref (#1899)
Browse files Browse the repository at this point in the history
* feat(bin): use quinn-udp crates.io release instead of git ref

`neqo-bin` has been importing `quinn-udp` as a git reference, in order to
include quinn-rs/quinn#1765. The quinn project has since
released `quinn-udp` `v0.5.0`.

This commit upgrades `neqo-bin` to use `quinn-udp` `v0.5.0`.

`quinn-udp` now takes a data reference (`&[u8]`) instead of owned
data (`bytes::Bytes`) on its send path, thus no longer requiring `neqo-bin` to
convert, but simply pass a reference. See
quinn-rs/quinn#1729 (comment) for details.

`quinn-udp` has dropped `sendmmsg` support in the `v0.5.0`
release (quinn-rs/quinn@ee08826).
`neqo-bin` does not (yet) use `sendmmsg`. This might change in the
future (#1693).

* remove impl From<Datagram> for Vec<u8>
  • Loading branch information
mxinden authored May 13, 2024
1 parent d7f33e2 commit e44c472
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 23 deletions.
2 changes: 1 addition & 1 deletion neqo-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ neqo-http3 = { path = "./../neqo-http3" }
neqo-qpack = { path = "./../neqo-qpack" }
neqo-transport = { path = "./../neqo-transport" }
qlog = { workspace = true }
quinn-udp = { git = "https://github.com/quinn-rs/quinn/", rev = "a947962131aba8a6521253d03cc948b20098a2d6" }
quinn-udp = { version = "0.5.0", default-features = false }
regex = { version = "1.9", default-features = false, features = ["unicode-perl"] }
tokio = { version = "1", default-features = false, features = ["net", "time", "macros", "rt", "rt-multi-thread"] }
url = { version = "2.5", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion neqo-bin/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ impl<'a, H: Handler> Runner<'a, H> {
match self.client.process_output(Instant::now()) {
Output::Datagram(dgram) => {
self.socket.writable().await?;
self.socket.send(dgram)?;
self.socket.send(&dgram)?;
}
Output::Callback(new_timeout) => {
qdebug!("Setting timeout of {:?}", new_timeout);
Expand Down
2 changes: 1 addition & 1 deletion neqo-bin/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl ServerRunner {
Output::Datagram(dgram) => {
let socket = self.find_socket(dgram.source());
socket.writable().await?;
socket.send(dgram)?;
socket.send(&dgram)?;
}
Output::Callback(new_timeout) => {
qdebug!("Setting timeout of {:?}", new_timeout);
Expand Down
22 changes: 8 additions & 14 deletions neqo-bin/src/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,19 @@ impl Socket {
}

/// Send the UDP datagram on the specified socket.
pub fn send(&self, d: Datagram) -> io::Result<()> {
pub fn send(&self, d: &Datagram) -> io::Result<()> {
let transmit = Transmit {
destination: d.destination(),
ecn: EcnCodepoint::from_bits(Into::<u8>::into(d.tos())),
contents: Vec::from(d).into(),
contents: d,
segment_size: None,
src_ip: None,
};

let n = self.socket.try_io(Interest::WRITABLE, || {
self.state
.send((&self.socket).into(), slice::from_ref(&transmit))
self.socket.try_io(Interest::WRITABLE, || {
self.state.send((&self.socket).into(), &transmit)
})?;

assert_eq!(n, 1, "only passed one slice");

Ok(())
}

Expand Down Expand Up @@ -149,7 +146,7 @@ mod tests {
);

sender.writable().await?;
sender.send(datagram.clone())?;
sender.send(&datagram)?;

receiver.readable().await?;
let received_datagram = receiver
Expand Down Expand Up @@ -189,17 +186,14 @@ mod tests {
IpTosDscp::Le,
IpTosEcn::Ect1,
)))),
contents: msg.clone().into(),
contents: &msg,
segment_size: Some(SEGMENT_SIZE),
src_ip: None,
};
sender.writable().await?;
let n = sender.socket.try_io(Interest::WRITABLE, || {
sender
.state
.send((&sender.socket).into(), slice::from_ref(&transmit))
sender.socket.try_io(Interest::WRITABLE, || {
sender.state.send((&sender.socket).into(), &transmit)
})?;
assert_eq!(n, 1, "only passed one slice");

// Allow for one GSO sendmmsg to result in multiple GRO recvmmsg.
let mut num_received = 0;
Expand Down
6 changes: 0 additions & 6 deletions neqo-common/src/datagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ impl std::fmt::Debug for Datagram {
}
}

impl From<Datagram> for Vec<u8> {
fn from(datagram: Datagram) -> Self {
datagram.d
}
}

#[cfg(test)]
use test_fixture::datagram;

Expand Down

0 comments on commit e44c472

Please sign in to comment.