Skip to content

Commit

Permalink
build(s2n-quic-xdp): update toolchain and dependencies (#2147)
Browse files Browse the repository at this point in the history
  • Loading branch information
camshaft authored Mar 6, 2024
1 parent 670b7ad commit 0b2be23
Show file tree
Hide file tree
Showing 38 changed files with 51 additions and 67 deletions.
2 changes: 0 additions & 2 deletions common/s2n-codec/src/encoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ pub use buffer::*;
pub use estimator::*;
pub use value::*;

use core::convert::TryFrom;

pub trait Encoder: Sized {
/// Set to `true` if the particular encoder specializes on the bytes implementation
#[cfg(feature = "bytes")]
Expand Down
2 changes: 1 addition & 1 deletion common/s2n-codec/src/encoder/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
i24, i48, u24, u48, DecoderBuffer, DecoderBufferMut,
};
use byteorder::{ByteOrder, NetworkEndian};
use core::{convert::TryFrom, mem::size_of};
use core::mem::size_of;

pub trait EncoderValue: Sized {
/// Encodes the value into the encoder
Expand Down
5 changes: 1 addition & 4 deletions common/s2n-codec/src/unaligned.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

use core::{
convert::{TryFrom, TryInto},
ops::Deref,
};
use core::ops::Deref;

// Unaligned integer types are integers which Rust does not provide natively.
// This macro attempts to create wrapper types around the rounded up type
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/ack/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
transport::parameters::{AckDelayExponent, MaxAckDelay},
varint::VarInt,
};
use core::{convert::TryInto, time::Duration};
use core::time::Duration;

// After running simulations, this seemed to be a good baseline
// TODO experiment more with this
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/application/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
frame::ConnectionClose,
varint::{VarInt, VarIntError},
};
use core::{convert::TryFrom, fmt, ops};
use core::{fmt, ops};

//= https://www.rfc-editor.org/rfc/rfc9000#section-20.2
//# The management of application error codes is left to application
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/connection/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::{
application, connection, crypto::packet_protection, endpoint, frame::ConnectionClose, transport,
};
use core::{convert::TryInto, fmt, panic, time::Duration};
use core::{fmt, panic, time::Duration};

/// Errors that a connection can encounter.
#[derive(Debug, Copy, Clone)]
Expand Down
5 changes: 1 addition & 4 deletions quic/s2n-quic-core/src/connection/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ use crate::{
event::{api::SocketAddress, IntoEvent},
inet, transport,
};
use core::{
convert::{TryFrom, TryInto},
time::Duration,
};
use core::time::Duration;
use s2n_codec::{decoder_value, Encoder, EncoderValue};

#[cfg(any(test, feature = "generator"))]
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/connection/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
MaxDatagramFrameSize, MaxIdleTimeout, TransportParameters,
},
};
use core::{convert::TryInto, time::Duration};
use core::time::Duration;
use s2n_codec::decoder_invariant;

pub use crate::transport::parameters::ValidationError;
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::number::{
CheckedAddAssign, CheckedMulAssign, CheckedSubAssign, SaturatingAddAssign, SaturatingMulAssign,
SaturatingSubAssign, UpcastFrom,
};
use core::{cmp::Ordering, convert::TryFrom, marker::PhantomData, ops};
use core::{cmp::Ordering, marker::PhantomData, ops};

/// A checked-overflow counter
///
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/crypto/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#[cfg(feature = "alloc")]
pub use bytes::{Bytes, BytesMut};
use core::{convert::TryFrom, fmt::Debug};
use core::fmt::Debug;
use zerocopy::{AsBytes, FromBytes, FromZeroes, Unaligned};

mod error;
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/havoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
stream::StreamType,
varint,
};
use core::{convert::TryInto, ops::Range};
use core::ops::Range;
pub use s2n_codec::{Encoder, EncoderBuffer, EncoderValue};

pub trait Random {
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/packet/decoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{
},
varint::VarInt,
};
use core::{convert::TryInto, mem::size_of};
use core::mem::size_of;
use s2n_codec::{CheckedRange, DecoderBuffer, DecoderBufferMut, DecoderError, DecoderValue};

pub struct HeaderDecoder<'a> {
Expand Down
1 change: 0 additions & 1 deletion quic/s2n-quic-core/src/packet/long.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::{
packet::{encoding::PacketPayloadLenCursor, number::TruncatedPacketNumber},
varint::VarInt,
};
use core::convert::TryFrom;
use s2n_codec::{
decoder_invariant, CheckedRange, DecoderError, Encoder, EncoderBuffer, EncoderValue,
};
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/packet/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
},
random, token,
};
use core::{convert::TryInto, mem::size_of, ops::Range};
use core::{mem::size_of, ops::Range};
use retry::INTEGRITY_TAG_LEN;
use s2n_codec::{
decoder_invariant, DecoderBufferMut, DecoderBufferMutResult, Encoder, EncoderBuffer,
Expand Down
1 change: 0 additions & 1 deletion quic/s2n-quic-core/src/path/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::{
inet::{IpV4Address, IpV6Address, SocketAddress, SocketAddressV4, SocketAddressV6},
};
use core::{
convert::{TryFrom, TryInto},
fmt,
fmt::{Display, Formatter},
num::NonZeroU16,
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/path/mtu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use crate::{
counter::{Counter, Saturating},
ensure, event,
event,
event::{builder::MtuUpdatedCause, IntoEvent},
frame,
inet::SocketAddress,
Expand Down
1 change: 0 additions & 1 deletion quic/s2n-quic-core/src/recovery/bbr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use crate::{
};
use core::{
cmp::{max, min},
convert::TryInto,
time::Duration,
};
use num_rational::Ratio;
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/recovery/bbr/probe_bw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
},
time::Timestamp,
};
use core::{convert::TryInto, time::Duration};
use core::time::Duration;
use num_rational::Ratio;
use num_traits::One;

Expand Down
4 changes: 1 addition & 3 deletions quic/s2n-quic-core/src/recovery/persistent_congestion.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

use crate::{
ensure, packet::number::PacketNumber, path, recovery::SentPacketInfo, time::Timestamp,
};
use crate::{packet::number::PacketNumber, path, recovery::SentPacketInfo, time::Timestamp};
use core::time::Duration;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/recovery/pto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{
ensure, frame,
frame,
time::{timer, Timer, Timestamp},
transmission::{self, interest::Provider as _},
};
Expand Down
1 change: 0 additions & 1 deletion quic/s2n-quic-core/src/recovery/sent_packets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::{
frame::ack_elicitation::AckElicitation, inet::ExplicitCongestionNotification, path,
time::Timestamp, transmission,
};
use core::convert::TryInto;

//= https://www.rfc-editor.org/rfc/rfc9002#appendix-A.1

Expand Down
1 change: 0 additions & 1 deletion quic/s2n-quic-core/src/stateless_reset/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

//! Defines the Stateless Reset token
use core::convert::{TryFrom, TryInto};
use s2n_codec::{decoder_value, Encoder, EncoderValue};
use subtle::ConstantTimeEq;

Expand Down
6 changes: 1 addition & 5 deletions quic/s2n-quic-core/src/transport/parameters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ use crate::{
stream::{StreamId, StreamType},
varint::VarInt,
};
use core::{
convert::{TryFrom, TryInto},
mem::size_of,
time::Duration,
};
use core::{mem::size_of, time::Duration};
use s2n_codec::{
decoder_invariant, decoder_value, DecoderBuffer, DecoderBufferMut, DecoderBufferMutResult,
DecoderBufferResult, DecoderError, DecoderValue, DecoderValueMut, Encoder, EncoderValue,
Expand Down
6 changes: 1 addition & 5 deletions quic/s2n-quic-core/src/varint/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

use core::{
convert::{TryFrom, TryInto},
fmt,
ops::Deref,
};
use core::{fmt, ops::Deref};
use s2n_codec::{decoder_value, Encoder, EncoderValue};

#[cfg(any(test, feature = "generator"))]
Expand Down
5 changes: 2 additions & 3 deletions quic/s2n-quic-qns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ trace = ["s2n-quic-core/branch-tracing", "s2n-quic-core/probe-tracing", "s2n-qui
xdp = ["s2n-quic/unstable-provider-io-xdp", "aya", "aya-log"]

[dependencies]
# TODO use the crates.io version once https://github.com/aya-rs/aya/pull/527 is merged
aya = { git = "https://github.com/camshaft/aya", branch = "xdpmaps", optional = true }
aya-log = { git = "https://github.com/camshaft/aya", branch = "xdpmaps", optional = true }
aya = { version = "0.12", optional = true }
aya-log = { version = "0.2", optional = true }
bytes = { version = "1", default-features = false }
cfg-if = "1"
futures = "0.3"
Expand Down
5 changes: 2 additions & 3 deletions tools/xdp/ebpf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ edition = "2021"

[dependencies]
# These crates are not published so use a git dependency for now. See https://github.com/aya-rs/aya/issues/464
# TODO switch to the main repo once the xdpmaps are available - https://github.com/aya-rs/aya/pull/527
aya-bpf = { git = "https://github.com/camshaft/aya", branch = "xdpmaps" }
aya-log-ebpf = { git = "https://github.com/camshaft/aya", branch = "xdpmaps" }
aya-bpf = { git = "https://github.com/aya-rs/aya", tag = "aya-v0.12.0" }
aya-log-ebpf = { git = "https://github.com/aya-rs/aya", tag = "aya-v0.12.0" }
s2n-quic-core = { path = "../../../quic/s2n-quic-core", default-features = false }

[features]
Expand Down
2 changes: 1 addition & 1 deletion tools/xdp/ebpf/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[toolchain]
# pin the version to prevent random breakage
channel = "nightly-2023-06-21"
channel = "nightly-2024-03-05"
# The source code of rustc, provided by the rust-src component, is needed for
# building eBPF programs.
components = [ "rustc", "cargo", "rust-src" ]
8 changes: 5 additions & 3 deletions tools/xdp/ebpf/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ static SOCKETS: XskMap = XskMap::with_max_entries(1024, 0);
#[map(name = "S2N_QUIC_XDP_PORTS")]
static PORTS: HashMap<u16, u8> = HashMap::with_max_entries(1024, 0);

#[xdp(name = "s2n_quic_xdp")]
#[xdp]
#[allow(clippy::let_and_return)]
pub fn s2n_quic_xdp(ctx: XdpContext) -> u32 {
let action = handle_packet(&ctx);

Expand Down Expand Up @@ -60,8 +61,9 @@ fn handle_packet(ctx: &XdpContext) -> u32 {

// if the packet is valid forward it on to the associated AF_XDP socket
let queue_id = unsafe { (*ctx.ctx).rx_queue_index };
let not_found_action = xdp_action::XDP_PASS as _;
SOCKETS.redirect(queue_id, not_found_action)
SOCKETS
.redirect(queue_id, 0)
.unwrap_or(xdp_action::XDP_PASS)
}
Ok(None) => xdp_action::XDP_PASS,
Err(_) => xdp_action::XDP_ABORTED,
Expand Down
2 changes: 1 addition & 1 deletion tools/xdp/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.71.1"
channel = "1.74.1"
components = [ "rustc", "clippy", "rustfmt" ]
2 changes: 1 addition & 1 deletion tools/xdp/s2n-quic-xdp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exclude = ["corpus.tar.gz"]
default = ["tokio"]

[dependencies]
aya = { version = "0.11", default-features = false }
aya = { version = "0.12", default-features = false }
bitflags = "2"
errno = "0.3"
libc = "0.2"
Expand Down
4 changes: 2 additions & 2 deletions tools/xdp/s2n-quic-xdp/src/bpf/s2n-quic-xdp-bpfeb-trace.ebpf
Git LFS file not shown
4 changes: 2 additions & 2 deletions tools/xdp/s2n-quic-xdp/src/bpf/s2n-quic-xdp-bpfeb.ebpf
Git LFS file not shown
4 changes: 2 additions & 2 deletions tools/xdp/s2n-quic-xdp/src/bpf/s2n-quic-xdp-bpfel-trace.ebpf
Git LFS file not shown
4 changes: 2 additions & 2 deletions tools/xdp/s2n-quic-xdp/src/bpf/s2n-quic-xdp-bpfel.ebpf
Git LFS file not shown
4 changes: 2 additions & 2 deletions tools/xdp/s2n-quic-xdp/src/io/rx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ impl<D: Driver> Driver for WithCooldown<D> {
}

match self.cooldown.on_pending_task(cx) {
cooldown::Outcome::Loop => return Some(0),
cooldown::Outcome::Sleep => return self.driver.poll(rx, fill, cx),
cooldown::Outcome::Loop => Some(0),
cooldown::Outcome::Sleep => self.driver.poll(rx, fill, cx),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tools/xdp/s2n-quic-xdp/src/io/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl<D: Driver> tx::Tx for Tx<D> {

// use the first channel that had entries, otherwise return the length, which will indicate
// the queue has no free items
let channel_index = first_channel_with_entries.unwrap_or_else(|| channels.len());
let channel_index = first_channel_with_entries.unwrap_or(channels.len());

let mut queue = Queue {
channels,
Expand Down
7 changes: 7 additions & 0 deletions tools/xdp/s2n-quic-xdp/src/umem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,14 @@ impl Umem {
/// Specifies an indexable value, which relies on the caller to guarantee borrowing rules are not
/// violated.
pub trait UnsafeIndex<T> {
/// # Safety
///
/// Callers need to guarantee the reference is not already exclusively borrowed
unsafe fn index(&self, idx: T) -> &[u8];

/// # Safety
///
/// Callers need to guarantee the reference is not already exclusively borrowed
#[allow(clippy::mut_from_ref)] // interior mutability safety is enforced by the caller
unsafe fn index_mut(&self, idx: T) -> &mut [u8];
}
Expand Down
6 changes: 3 additions & 3 deletions tools/xdp/tester/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ edition = "2021"
publish = false

[dependencies]
aya = { version = ">=0.11", features = ["async_tokio"] }
aya-log = "0.1"
aya = { version = "0.12", features = ["async_tokio"] }
aya-log = "0.2"
clap = { version = "4.1", features = ["derive"] }
anyhow = "1.0.68"
env_logger = "0.10"
env_logger = "0.11"
log = "0.4"
s2n-quic-xdp = { path = "../s2n-quic-xdp" }
tokio = { version = "1.24", features = ["macros", "rt", "rt-multi-thread", "net", "signal"] }

0 comments on commit 0b2be23

Please sign in to comment.