Skip to content

xdp: tx_loop: allow overriding MACs and IP#7285

Merged
alessandrod merged 2 commits intoanza-xyz:masterfrom
alessandrod:xdp-overrides
Aug 5, 2025
Merged

xdp: tx_loop: allow overriding MACs and IP#7285
alessandrod merged 2 commits intoanza-xyz:masterfrom
alessandrod:xdp-overrides

Conversation

@alessandrod
Copy link
Copy Markdown

This is useful for sending via bonded NICs, skipping the bond device and targeting the slaved NICs directly so they can be used in zero copy mode.

Slaved NICs don't have an IP assigned to them, so the source IP can't be discovered but must be passed explicitly (eg the bond IP).

Overriding MACs can be useful while testing to ensure frames don't leave the switch/metro.

@alessandrod alessandrod requested a review from Copilot August 3, 2025 12:20
Copy link
Copy Markdown

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 extends the XDP tx_loop function to allow overriding source/destination MAC addresses and source IP addresses. This enables sending packets via bonded NICs by targeting slave NICs directly for zero-copy mode support, while manually specifying network parameters that would normally be auto-discovered from the device.

Key changes:

  • Adds optional parameters for overriding source MAC, source IP, and destination MAC addresses
  • Modifies the function signature to accept generic address collections
  • Updates MAC address handling throughout the device and networking code

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
xdp/src/tx_loop.rs Extends tx_loop function signature with optional MAC/IP overrides and implements fallback logic
xdp/src/device.rs Changes mac_addr() return type from raw bytes to MacAddress wrapper type
turbine/src/xdp.rs Updates tx_loop call site to pass None values for new optional parameters

Comment thread xdp/src/tx_loop.rs
Comment thread xdp/src/tx_loop.rs
Comment thread xdp/src/tx_loop.rs
};

pub fn tx_loop<T: AsRef<[u8]>>(
#[allow(clippy::too_many_arguments)]
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I plan to rework this with a builder, but doing that separately or the diff will blow up for no reason

@alessandrod alessandrod requested a review from bw-solana August 3, 2025 12:57
Copy link
Copy Markdown

@bw-solana bw-solana left a comment

Choose a reason for hiding this comment

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

1 question and 1 nit, but LGTM

Comment thread xdp/src/tx_loop.rs
Comment thread xdp/src/tx_loop.rs
bw-solana
bw-solana previously approved these changes Aug 4, 2025
Comment thread xdp/src/tx_loop.rs
This allows passing Arc<Vec<_>> when sending to a static list of peers.
This is useful for sending via bonded NICs, skipping the bond device and
targeting the slaved NICs directly so they can be used in zero copy
mode.

Slaved NICs don't have an IP assigned to them, so the source IP can't be
discovered but must be passed explicitly (eg the bond IP).

Overriding MACs can be useful while testing to ensure frames don't leave
the switch/metro.
@alessandrod alessandrod added the automerge automerge Merge this Pull Request automatically once CI passes label Aug 4, 2025
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 59 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.8%. Comparing base (3297ff4) to head (2396c0f).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##           master    #7285     +/-   ##
=========================================
- Coverage    82.8%    82.8%   -0.1%     
=========================================
  Files         801      801             
  Lines      363392   363418     +26     
=========================================
- Hits       301027   300947     -80     
- Misses      62365    62471    +106     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alessandrod alessandrod merged commit d3038f3 into anza-xyz:master Aug 5, 2025
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge automerge Merge this Pull Request automatically once CI passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants