Skip to content

Conversation

@Fredi-raspall
Copy link
Contributor

No description provided.

@Fredi-raspall Fredi-raspall force-pushed the pr/fredi/pkt-io branch 3 times, most recently from 3ea6b45 to 5ccaffc Compare October 20, 2025 18:23
@Fredi-raspall Fredi-raspall marked this pull request as ready for review October 21, 2025 16:11
@Fredi-raspall Fredi-raspall requested a review from a team as a code owner October 21, 2025 16:11
@qmonnet qmonnet requested a review from Copilot October 21, 2025 16:14
Copy link
Contributor

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 a new pkt-io crate that provides packet injection and punting capabilities for the gateway pipeline. The main purpose is to enable bidirectional packet flow control: injecting packets into the pipeline from external threads and extracting packets from the pipeline for local consumption.

Key changes:

  • New PktIo network function stage with configurable injection and punt queues
  • Added LOCAL metadata flag to mark packets for local consumption
  • New InternalDrop done reason for resource-constrained scenarios
  • Integration of pkt-io stage into the main dataplane packet processor pipeline

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkt-io/Cargo.toml Defines the new pkt-io crate with dependencies on crossbeam, net, pipeline, and tracectl
pkt-io/src/lib.rs Library entry point exposing the PktIo network function
pkt-io/src/nf.rs Implements PktIo with dual-queue architecture for packet injection and punting
pkt-io/src/tests.rs Comprehensive test suite covering injection, punting, and multi-pipeline scenarios
net/src/packet/meta.rs Adds LOCAL flag and InternalDrop reason to packet metadata
net/src/packet/display.rs Refactors metadata display to show all flags including new LOCAL flag
dataplane/Cargo.toml Adds pkt-io dependency to dataplane crate
dataplane/src/packet_processor/mod.rs Integrates PktIo stage into main packet processing pipeline
dataplane/src/packet_processor/ipforward.rs Updates local packet handling to use Unhandled instead of removed Local reason
Cargo.toml Adds pkt-io workspace member and crossbeam dependency

Comment on lines +73 to +81
// criteria may work. QUESTION: do we need/want this to be configurable?, or should this
// stage remain simple and the preceding stages keep the knowledge of what needs to be
// punted and set the local flag?
Copy link
Member

Choose a reason for hiding this comment

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

What would it require to make it configurable, passing a closure to filter packets to pull? Would that be easy to do at a later time, if necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, something like that. I think it would. We do a similar thing already for the dumper function, where we pass a filter to know what packets to dump. That being said, I believe that the best would be to have a fixed criteria based on some packet annotation set by preceding NFs.

.add_stage(flow_lookup_nf)
.add_stage(stateless_nat)
.add_stage(iprouter2)
.add_stage(pktio1)
Copy link
Member

Choose a reason for hiding this comment

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

Is my understanding correct that this new stage has no effect until we set the queues calling set_injectq() and set_puntq()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can have the behavior that you mention if we create the pkt-io without buffers.
In this commit, I added 10K buffer queue for injection and 100 pkts for punting.
Since some packets may be marked as local, they will be punted. But since no one checks the punt queue, they will be cached there forever. So this PR is not to be merged (I set 100 pkts so that we'd not cache megabytes) as is. The expectation was to add more commits from @daniel-noland to do the actual consumption of those packets).
If we'd want to merge this PR, we'd just need to set zero buffering to the pkt-io, in which case it would be transparent.

Replace DoneReason::Local by a local flag in the metadata flags.
The reason is that Local is not a terminating condition but a hint
of how to further process a packet.

Signed-off-by: Fredi Raspall <[email protected]>
This reason may be set to packets that can't be handled due to
lack of resources.

Signed-off-by: Fredi Raspall <[email protected]>
Pkt-io implements a network function capable of injecting packets
into a pipeline or pulling off packets from it. Pulling packets off
the pipeline may be used to locally process them (e.g. by punting
them to the kernel). The injection capability may be used to
transmit locally-generated packets (e.g. control-plane, ICMP, ARP,
etc.)

Signed-off-by: Fredi Raspall <[email protected]>
Signed-off-by: Fredi Raspall <[email protected]>
This is just a toy proof of concept.

Signed-off-by: Fredi Raspall <[email protected]>
Add a pkt-io instance to pipeline before egress stage. The injection
buffer is 10K packets. The punting buffer is only 100 packets large.
This is temporary: we currently mark some packets as local,
but do not handle them yet. Therefore, the first 100 of local
packets will be cached (forever) and the rest removed.

Signed-off-by: Fredi Raspall <[email protected]>
Alternatively, we may:
  - define a struct
  - and/or define a trait Queue to abstract the implementation.

Signed-off-by: Fredi Raspall <[email protected]>
This is not a full abstraction, but may suffice for an easy
switch of the inner queue type.

Signed-off-by: Fredi Raspall <[email protected]>
@Fredi-raspall Fredi-raspall force-pushed the pr/fredi/pkt-io branch 2 times, most recently from fa3be59 to 6aae11b Compare October 22, 2025 14:04
We need to abstract the creation of buffers. Add trait Allocate
to PacketBufferMut.

Signed-off-by: Fredi Raspall <[email protected]>
@qmonnet qmonnet added the dont-merge Do not merge this Pull Request label Oct 23, 2025
@Frostman Frostman removed the ci:+vlab label Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dont-merge Do not merge this Pull Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants