Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1edfe8b
mctp-estack: Remove Stack mtu argument
mkj Jul 28, 2025
4f90003
mctp-estack: Make PortLookup take const references
mkj Jun 11, 2025
ed6a83b
mctp-estack: Temporarily vendor zerocopy_channel
mkj Jul 28, 2025
14b885c
mctp-estack: Add critical-section dev-dependency
mkj Aug 7, 2025
dac69c4
mctp-estack: Separate lifetimes for Router
mkj Jun 6, 2025
66d1d42
mctp-estack: Move packet queue into PortTop
mkj Jun 10, 2025
7fac14a
mctp-estack: Revert send_message() loop change
mkj Jul 28, 2025
22c4ea2
mctp-estack: Better locking between send_message and forward_packets()
mkj Jul 28, 2025
39705ad
mctp-estack: Move MTU handling into PortTop::by_eid()
mkj Jul 28, 2025
f3e3a81
mctp-estack: Construct Stack within Router
mkj Jul 29, 2025
07b86c1
mctp-estack: Don't remove non-expiring flows
mkj Jul 29, 2025
b98f297
mctp-estack: Add recv() timeouts for Listener, Req
mkj Jul 30, 2025
b2cbf79
mctp-estack: impl Debug for Channels, Listener
mkj Jul 30, 2025
4a13f3d
mctp-estack: Stack timeouts expire on >= deadline, not >
mkj Aug 7, 2025
f1ce9d1
mctp-estack: Add cancel_flow_bycookie()
mkj Aug 7, 2025
185038b
mctp-estack: Remove Stack's DEFERRED_TIMEOUT
mkj Aug 7, 2025
40a99db
mctp-estack: cleanup() to remove deferred cookies
mkj Aug 7, 2025
790c03a
Remove needless lifetimes by clippy
mkj Aug 7, 2025
16d6f9d
ci: Don't run clippy for old toolchain
mkj Aug 8, 2025
ca289c3
ci: Move minimum version to Rust 1.85
mkj Aug 7, 2025
b583ad8
mctp-estack: Add StepExecutor for testing
mkj Aug 5, 2025
88c9eba
mctp-estack: Add Router roundtrip tests
mkj Jul 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ jobs:
ci:
strategy:
matrix:
# 1.82 is the earliest version that will build. Notice if it breaks,
# though MSRV may be bumped as needed.
rust_version: [stable, 1.82, nightly]
include:
- rust_version: stable

# 1.85 is the earliest version that will build. Notice if it breaks,
# though MSRV may be bumped as needed.
- rust_version: 1.85
no_clippy: yes

- rust_version: nightly

runs-on: ubuntu-latest

Expand All @@ -41,4 +47,7 @@ jobs:
rustup override set ${{ matrix.rust_version }}

- name: Build and test ${{ matrix.rust_version }}
env:
# Older clippy has some unwanted lints, ignore them.
NO_CLIPPY: ${{ matrix.no_clippy }}
run: ./ci/runtests.sh
26 changes: 26 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion ci/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ cargo fmt -- --check

# Check everything first
cargo check --all-targets --locked
cargo clippy --all-targets
if [ -z "NO_CLIPPY" ]; then
cargo clippy --all-targets
fi

# stable, std
cargo build --release
Expand Down
5 changes: 4 additions & 1 deletion mctp-estack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition.workspace = true
license.workspace = true
repository.workspace = true
categories = ["network-programming", "embedded", "hardware-support", "no-std"]
rust-version = "1.82"
rust-version = "1.85"

[dependencies]
crc = { workspace = true }
Expand All @@ -20,11 +20,14 @@ smbus-pec = { version = "1.0", features = ["lookup-table"] }
uuid = { workspace = true }

[dev-dependencies]
critical-section = { version = "1.2.0", features = ["std"] }
embedded-io-adapters = { workspace = true }
env_logger = { workspace = true }
futures = "0.3"
proptest = { workspace = true }
smol = { workspace = true }


[features]
default = ["log"]
std = ["mctp/std"]
Expand Down
23 changes: 10 additions & 13 deletions mctp-estack/src/fragment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::fmt::{debug, error, info, trace, warn};

use mctp::{Eid, Error, MsgIC, MsgType, Result, Tag};

use crate::{AppCookie, MctpHeader, MAX_MTU};
use crate::{AppCookie, MctpHeader};

/// Fragments a MCTP message.
///
Expand Down Expand Up @@ -44,15 +44,10 @@ impl Fragmenter {
}
debug_assert!(typ.0 & 0x80 == 0, "IC bit's set in typ");
debug_assert!(initial_seq & !mctp::MCTP_SEQ_MASK == 0);
if mtu < MctpHeader::LEN + 1 {
if mtu < mctp::MCTP_MIN_MTU {
debug!("mtu too small");
return Err(Error::BadArgument);
}
if mtu > MAX_MTU {
debug!("mtu too large");
return Err(Error::BadArgument);
}
// TODO other validity checks

let header = MctpHeader {
dest,
Expand Down Expand Up @@ -93,6 +88,8 @@ impl Fragmenter {
///
/// The same input message `payload` should be passed to each `fragment()` call.
/// In `SendOutput::Packet(buf)`, `out` is borrowed as the returned fragment, filled with packet contents.
///
/// `out` must be at least as large as the specified `mtu`.
pub fn fragment<'f>(
&mut self,
payload: &[u8],
Expand All @@ -102,17 +99,16 @@ impl Fragmenter {
return SendOutput::success(self);
}

// first fragment needs type byte
let min = MctpHeader::LEN + self.header.som as usize;

if out.len() < min {
return SendOutput::failure(Error::NoSpace, self);
// Require at least MTU buffer size, to ensure that all non-end
// fragments are the same size per the spec.
if out.len() < self.mtu {
debug!("small out buffer");
return SendOutput::failure(Error::BadArgument, self);
}

// Reserve header space, the remaining buffer keeps being
// updated in `rest`
let max_total = out.len().min(self.mtu);
// let out = &mut out[..max_total];
let (h, mut rest) = out[..max_total].split_at_mut(MctpHeader::LEN);

// Append type byte
Expand All @@ -123,6 +119,7 @@ impl Fragmenter {

if payload.len() < self.payload_used {
// Caller is passing varying payload buffers
debug!("varying payload");
return SendOutput::failure(Error::BadArgument, self);
}

Expand Down
Loading