-
Notifications
You must be signed in to change notification settings - Fork 8
feat(routing): avoid extra copy of data #1060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
6f23778 to
7a9b408
Compare
|
@copilot: Review the last commit for this Pull Request, the first three have already been merged via another PR. |
There was a problem hiding this 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 pull request focuses on performance optimization by eliminating unnecessary data copies in the routing module, along with significant code quality improvements through enabling stricter Clippy lints and refactoring.
Key changes:
- Introduced
BytesMutbuffer reuse in the router IO loop to avoid copying received data from CPI/CLI sockets - Reorganized module structure by making internal modules
pub(crate)while maintaining public API through re-exports inlib.rs - Enabled
#![deny(clippy::all, clippy::pedantic)]and fixed hundreds of lint warnings including method reference optimizations, unused code removal, and code simplifications
Reviewed changes
Copilot reviewed 58 out of 59 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| routing/src/router/rio.rs | Core performance optimization using BytesMut for zero-copy data handling; module reorganization; test naming fixes needed |
| routing/src/router/cpi.rs | Changed process_rx_data to process_cpi_data accepting &mut Bytes instead of &[u8] to avoid copy |
| routing/src/router/mod.rs | Removed unused metrics_addr parameter; refactored router initialization; removed unused getter methods |
| routing/src/lib.rs | Made internal modules private (pub(crate)); comprehensive re-export list maintains public API |
| routing/src/interfaces/interface.rs | Renamed enum variants: VRF → Vrf, BD → BridgeDomain for better naming conventions |
| routing/src/fib/fibobjects.rs | Used clone_from() optimization for better performance when cloning into existing values |
| routing/src/frr/frrmi.rs | Improved error handling with matches! macro; better Option handling patterns |
| routing/src/cli/display.rs | Refactored string formatting to use write! macro instead of concatenation |
| routing/src/config/* | Consistent use of clone() over to_owned() for clarity; improved Option handling |
| routing/Cargo.toml | Removed unused mac_address dependency |
| dataplane/src/main.rs | Removed metrics_addr parameter from router initialization |
| mgmt/src/processor/*.rs | Updated imports to use re-exported types from routing crate |
Comments suppressed due to low confidence (3)
routing/src/router/rio.rs:478
confidence: 9
tags: [logic]
The same typo "test-routter" appears here as well. Should be "test-router".
**routing/src/router/rio.rs:379**
* ```yaml
confidence: 8
tags: [logic]
There's an inconsistency in buffer handling between CPI and CLI sockets. For CPI (line 357), the code uses buf.split_to(len).freeze() which consumes part of the buffer, but for CLI (line 379), it uses &buf[0..len] which just borrows a slice.
After the CPI socket processes data with split_to(), the buffer may be in a partially consumed state. If the while loop continues and hits the CLI case, the buf.resize(2048, 0) call on line 377 may not properly reset the buffer state.
Consider one of these approaches:
- Use
buf.clear(); buf.resize(2048, 0);before each resize to ensure consistent state - Reset the buffer explicitly after CPI processing
- Use separate buffers for CPI and CLI if they have different requirements
The current implementation may work but is fragile and could lead to subtle bugs.
routing/src/router/rio.rs:454
confidence: 9
tags: [logic]
The typo "test-routter" (with double 't') appears in test code. This should be corrected to "test-router" for consistency with standard spelling.
</details>
| if Some(ip) != vtep.get_ip() { | ||
| vtep.set_ip(ip); | ||
| info!("Updated VTEP ip address set to {ip}"); | ||
| info!("Updated VTEP ip address to {ip}"); |
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] ```yaml
confidence: 8
tags: [logic]
The comment says "Updated VTEP ip address to" but the previous line was "Updated VTEP ip address set to". While this is an improvement, consider making it more consistent with the MAC address update below (line 22) which says "Updated VTEP mac address set to". For consistency, this could be either:
- "Updated VTEP ip address to {ip}" (current change)
- "VTEP ip address set to {ip}" (matches MAC line pattern)
The current change is acceptable but consider consistency across all VTEP update messages.
```suggestion
info!("Updated VTEP ip address set to {ip}");
qmonnet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last commit looks good to me, thanks!
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
7a9b408 to
f5a3f0d
Compare
On top of #1059