Skip to content

Conversation

@Fredi-raspall
Copy link
Contributor

On top of #1059

@Fredi-raspall Fredi-raspall requested a review from a team as a code owner November 20, 2025 14:23
@Fredi-raspall Fredi-raspall requested review from sergeymatov and removed request for a team November 20, 2025 14:23
Base automatically changed from pr/fredi/R2_routing_cleanup to main November 20, 2025 19:18
@qmonnet
Copy link
Member

qmonnet commented Nov 21, 2025

@copilot: Review the last commit for this Pull Request, the first three have already been merged via another PR.

Copy link

Copilot AI commented Nov 21, 2025

@qmonnet I've opened a new pull request, #1065, to work on those changes. Once the pull request is ready, I'll request review from you.

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 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 BytesMut buffer 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 in lib.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: VRFVrf, BDBridgeDomain 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:

  1. Use buf.clear(); buf.resize(2048, 0); before each resize to ensure consistent state
  2. Reset the buffer explicitly after CPI processing
  3. 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}");
Copy link

Copilot AI Nov 21, 2025

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}");

Copilot uses AI. Check for mistakes.
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.

Last commit looks good to me, thanks!

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
@Fredi-raspall Fredi-raspall added this pull request to the merge queue Nov 21, 2025
Merged via the queue into main with commit 7a1ca81 Nov 21, 2025
19 checks passed
@Fredi-raspall Fredi-raspall deleted the pr/fredi/zero-copy-cpi branch November 21, 2025 18:27
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.

3 participants