Skip to content

Conversation

mvachhar
Copy link
Contributor

@mvachhar mvachhar commented Aug 26, 2025

This PR adds the initial flow table data structure, but not the corresponding pipeline stages.

The appropriate pipeline stages will be added as part of NAT integration and the interface for the flow table updated for anything needed that was not anticipated here.

We also need a way to run the shuttle tests in CI, but that is beyond the scope of this PR.

Fixes #783

@mvachhar mvachhar requested a review from a team as a code owner August 26, 2025 23:06
@mvachhar mvachhar force-pushed the pr/mvachhar/flow-table branch from 977302e to 5e9796b Compare August 26, 2025 23:07
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces the initial flow table data structure for the networking stack, providing a foundation for tracking network flows with timeout capabilities. The implementation uses a combination of DashMap for concurrent hash table operations and thread-local priority queues for managing flow expiration.

  • Adds FlowTable with concurrent insert/lookup/remove operations and automatic timeout handling
  • Implements FlowKey with support for both unidirectional and bidirectional flows
  • Provides thread-local priority queues for efficient timeout management using weak references

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkt-meta/src/lib.rs Adds flow_table module export
pkt-meta/src/flow_table/mod.rs Module structure and public API exports
pkt-meta/src/flow_table/flow_key.rs Flow key data structures with bidirectional/unidirectional support
pkt-meta/src/flow_table/flow_info.rs Flow information storage with atomic expiration times
pkt-meta/src/flow_table/atomic_instant.rs Wrapper for atomic Instant operations
pkt-meta/src/flow_table/thread_local_pq.rs Thread-local priority queue implementation for timeout management
pkt-meta/src/flow_table/table.rs Main FlowTable implementation with concurrent operations
pkt-meta/src/flow_table/README.md Documentation of design decisions and future optimizations
pkt-meta/Cargo.toml Adds required dependencies for flow table functionality
net/src/udp/mod.rs Exports UdpPort type for flow key usage
Cargo.toml Adds workspace dependencies for flow table implementation
Comments suppressed due to low confidence (1)

pkt-meta/src/flow_table/thread_local_pq.rs:1

  • The #[allow(unused_must_use)] attribute is unnecessary here since expires_at() returns Instant which doesn't have #[must_use]. Remove this attribute to clean up the code.
// SPDX-License-Identifier: Apache-2.0

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@mvachhar mvachhar added the ci:+vlab Enable VLAB tests label Aug 26, 2025
@mvachhar mvachhar added this to the GW R1 milestone Aug 26, 2025
@mvachhar mvachhar force-pushed the pr/mvachhar/flow-table branch from 5e9796b to 9bcd4ec Compare August 26, 2025 23:11
@mvachhar mvachhar self-assigned this Aug 26, 2025
@mvachhar mvachhar force-pushed the pr/mvachhar/flow-table branch 5 times, most recently from bd7466e to b900948 Compare August 28, 2025 16:42
@mvachhar mvachhar force-pushed the pr/mvachhar/flow-table branch from b900948 to 03f48ed Compare September 1, 2025 20:54
Copy link
Collaborator

@daniel-noland daniel-noland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks good to me. Minor comments made, but nothing blocking.

I really like the effort which went into testing this code (it isn't easy code to test by any means).

I also appreciate the docs.

I'm slightly concerned about the performance we will get given the number of allocations we can expect, but that requires measurement before we change anything.

qmonnet
qmonnet previously requested changes Sep 2, 2025
Copy link
Member

@qmonnet qmonnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

Looks good overall, I don't see anything obvious that would be “missing”, although it's always hard to tell as long as we haven't integrated yet with e.g. NAT.

I've got some minor nits and comments.

More importantly, I may have spotted a couple bugs in flow_keys.rs, please double-check.

@mvachhar mvachhar force-pushed the pr/mvachhar/flow-table branch 2 times, most recently from 7d63588 to 4cc4008 Compare September 2, 2025 16:57
Signed-off-by: Manish Vachharajani <[email protected]>
Signed-off-by: Manish Vachharajani <[email protected]>
@mvachhar mvachhar force-pushed the pr/mvachhar/flow-table branch 2 times, most recently from 29e73af to 9738e3f Compare September 2, 2025 17:22
This is the first cut for a flow table.
There is more work to be done, but this is a good checkpoint.
Interfaces and organization may change as we start using this
with the stateful NAT code.

Signed-off-by: Manish Vachharajani <[email protected]>
@mvachhar mvachhar force-pushed the pr/mvachhar/flow-table branch from 9738e3f to 09e3f3c Compare September 2, 2025 17:29
@mvachhar mvachhar dismissed qmonnet’s stale review September 2, 2025 20:30

I've addressed all the requested changes but due to timezone, I'm going to dismiss the review so we can merge now.

@mvachhar mvachhar added this pull request to the merge queue Sep 2, 2025
Merged via the queue into main with commit 0bade5a Sep 2, 2025
19 checks passed
@mvachhar mvachhar deleted the pr/mvachhar/flow-table branch September 2, 2025 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:+vlab Enable VLAB tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flow table
3 participants