Skip to content

feat: implement Port and Mempool initialization with comprehensive tests - #2

Merged
gspivey merged 1 commit into
mainfrom
claude/tokio-dpdk-sample-app-wc3Om
Feb 4, 2026
Merged

gspivey merged 1 commit into
mainfrom
claude/tokio-dpdk-sample-app-wc3Om

Conversation

@gspivey

@gspivey gspivey commented Feb 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Port management (dpdk/src/port.rs): Full implementation of DPDK port initialization, configuration, and packet I/O operations including PortConfig, MacAddress, LinkStatus, PortStats, and burst-based RX/TX
  • Mempool management (dpdk/src/mbuf.rs): Complete mempool creation with MempoolConfig builder pattern, bulk allocation, and pool status queries
  • Enhanced stubs (dpdk-sys/src/stubs.rs): Working stub implementations that return valid pointers for testing

Test plan

  • All 48 unit tests in dpdk crate pass (17 for Port, 28 for Mempool, 3 existing)
  • All 3 unit tests in dpdk-sys crate pass
  • All 8 unit tests in dpdk-tokio crate pass
  • cargo build succeeds
  • cargo test passes (59 total tests)

Add real implementations for DPDK port and mempool management:

Port (dpdk/src/port.rs):

  • PortConfig with queue count, descriptor counts, promiscuous mode, MTU
  • MacAddress with utility methods (is_broadcast, is_multicast, is_zero)
  • LinkStatus and PortStats types
  • Port::init() with device info validation and queue setup
  • Port::start/stop with promiscuous mode support
  • rx_burst/tx_burst for packet I/O
  • 17 unit tests

Mempool (dpdk/src/mbuf.rs):

  • MempoolConfig builder pattern
  • Mempool::create() calling rte_pktmbuf_pool_create
  • Mempool::create_with_config() and create_default() helpers
  • alloc_bulk() for batch allocation
  • available_count(), in_use_count(), is_full(), is_empty()
  • 28 unit tests

Error types (dpdk/src/error.rs):

  • MempoolCreateFailed, QueueSetupFailed, InvalidName variants

Stubs (dpdk-sys/src/stubs.rs):

  • SOCKET_ID_ANY constant
  • rte_mempool struct with size/populated_size fields
  • rte_pktmbuf_pool_create returns valid mempool
  • rte_pktmbuf_alloc/alloc_bulk return valid mbufs with buffers
  • rte_mempool_avail_count, in_use_count, full, empty functions

https://claude.ai/code/session_01UiHnsVmMyk1CJgck3cCYZQ

Add real implementations for DPDK port and mempool management:

Port (dpdk/src/port.rs):
- PortConfig with queue count, descriptor counts, promiscuous mode, MTU
- MacAddress with utility methods (is_broadcast, is_multicast, is_zero)
- LinkStatus and PortStats types
- Port::init() with device info validation and queue setup
- Port::start/stop with promiscuous mode support
- rx_burst/tx_burst for packet I/O
- 17 unit tests

Mempool (dpdk/src/mbuf.rs):
- MempoolConfig builder pattern
- Mempool::create() calling rte_pktmbuf_pool_create
- Mempool::create_with_config() and create_default() helpers
- alloc_bulk() for batch allocation
- available_count(), in_use_count(), is_full(), is_empty()
- 28 unit tests

Error types (dpdk/src/error.rs):
- MempoolCreateFailed, QueueSetupFailed, InvalidName variants

Stubs (dpdk-sys/src/stubs.rs):
- SOCKET_ID_ANY constant
- rte_mempool struct with size/populated_size fields
- rte_pktmbuf_pool_create returns valid mempool
- rte_pktmbuf_alloc/alloc_bulk return valid mbufs with buffers
- rte_mempool_avail_count, in_use_count, full, empty functions

https://claude.ai/code/session_01UiHnsVmMyk1CJgck3cCYZQ
@gspivey
gspivey merged commit fc71f9a into main Feb 4, 2026
1 check passed
gspivey pushed a commit that referenced this pull request May 21, 2026
Append performance test results from GH Actions run 26227356354
(Graviton, TRex). No regressions detected — IPv6 fallback path adds
zero overhead to IPv4 traffic.

Mark IPv6 sub-task #2 (UDP over IPv6 checksum) as complete in the
README roadmap.
gspivey added a commit that referenced this pull request May 21, 2026
## Roadmap item

IPv6 sub-task #2: **UDP over IPv6 checksum** — mandatory IPv6
pseudo-header checksum validation (RFC 8200 §8.1).

## Changes

- Integrated `verify_udp6_checksum` into the RX path
(`process_frame_zerocopy`)
- IPv6 UDP packets are now parsed and checksum-validated before delivery
to the application
- Zero checksums are rejected (mandatory for IPv6, unlike IPv4 where 0
means disabled)
- Valid IPv6 UDP packets are delivered with `SocketAddrV6` source
addresses

## Tests added (21 new tests)

**Checksum verification (ipv6.rs):**
- VLAN-tagged IPv6 frame checksum verification
- Extension header (Hop-by-Hop) checksum verification
- Various payload sizes: empty, 1-byte, odd-length, max (1452B)
- Corruption detection: src/dst IP, src/dst port, payload
- Edge cases: truncated frames, non-IPv6 frames, too-short frames
- Pseudo-header checksum properties (different lengths, addresses, large
lengths)
- Zero-becomes-0xFFFF contract verification (RFC 8200 §8.1)

**RX path integration (lib.rs):**
- `process_frame_zerocopy_accepts_valid_ipv6_udp`
- `process_frame_zerocopy_rejects_corrupted_ipv6_checksum`
- `process_frame_zerocopy_rejects_zero_ipv6_checksum`

## Tradeoffs

- The RX path tries IPv4 parsing first, then falls back to IPv6. This
adds one failed parse attempt for IPv6-only traffic. The cost is
negligible (a few comparisons) and avoids changing the hot path for
existing IPv4 workloads.
- No topology worker integration yet — that will come with sub-task #3
(SocketAddrV6 through UdpSocket) which adds full dual-stack socket
support.

## All 607 tests pass, no regressions.

---------

Co-authored-by: Agent Router <agent@agent-router.dev>
gspivey pushed a commit that referenced this pull request Jun 5, 2026
- Append Run #29 to docs/perf-test-log.md with GitHub Actions perf
  test results (no regression from dpdk-stdlib-quic crate skeleton)
- Update ROADMAP.md: mark item #2 as complete with PR #66
gspivey added a commit that referenced this pull request Jun 5, 2026
## Roadmap Item

Implements roadmap item #2: **dpdk-stdlib-quic: Crate skeleton and
walking-skeleton CI**

Spec: `.kiro/specs/s2n-quic-provider/` · tasks 1.1, 1.2, 1.3, 1.4, 1.5

## Changes

- Created `dpdk-stdlib-quic/` workspace crate with `Cargo.toml` pinning
`s2n-quic = "=1.81.0"` and `s2n-quic-core = "=0.81.0"`
- Added crate to workspace `members` in root `Cargo.toml`
- Created `src/lib.rs` with module declarations and public re-exports
for all provider components:
  - `clock` — `StdClock` wrapping `std::time::Instant`
  - `ecn` — ECN extraction/TOS helpers (direct cast via `#[repr(u8)]`)
- `error` — `DpdkQuicError` enum (`thiserror`, `'static + Send + Sync`)
  - `event_loop` — placeholder for the core poll loop
  - `frame` — placeholder for frame building re-exports
- `loopback` — `LoopbackBackend` implementing all 9 `PacketBackend`
methods
- `path_handle` — `DpdkPathHandle` implementing
`s2n_quic_core::path::Handle`
  - `provider` — `DpdkProvider` + `ProviderBuilder` with builder pattern
  - `rx` — `DpdkRxQueue` stub with correct `datagram::Header` types
- `stats` — `ProviderStats` (atomic counters) + `ProviderHandle`
(shutdown + stats)
  - `tx` — `DpdkTxQueue` stub
- Created `quic-smoke` binary (builds provider in stub mode, prints
`QUIC_SMOKE_OK`, exits 0)
- Created `quic-integration-tests.yml` workflow (not pushed due to PAT
lacking `workflow` scope — file is tracked locally and noted for manual
addition)

## Tests Added

- 8 loopback backend tests (send/recv roundtrip, empty recv, MAC, name,
promiscuous, allmulticast, multiple frames, rx_readiness)
- 3 provider init tests (builds without panic, shutdown on non-started,
builder defaults)

## Verified

- All 715+ workspace tests pass (`cargo test` from workspace root)
- `quic-smoke` binary prints `QUIC_SMOKE_OK` and exits 0
- No existing crate APIs modified

## Note

The `quic-integration-tests.yml` workflow file could not be pushed
because the configured PAT lacks `workflow` scope. The file exists
locally and should be pushed by a user/token with appropriate
permissions.

---------

Co-authored-by: Agent Router <agent@agent-router.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants