xdp: tx_loop: allow overriding MACs and IP#7285
Conversation
There was a problem hiding this comment.
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 |
a24f69d to
ef69750
Compare
| }; | ||
|
|
||
| pub fn tx_loop<T: AsRef<[u8]>>( | ||
| #[allow(clippy::too_many_arguments)] |
There was a problem hiding this comment.
I plan to rework this with a builder, but doing that separately or the diff will blow up for no reason
ef69750 to
627c649
Compare
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.
627c649 to
2396c0f
Compare
Codecov Report❌ Patch coverage is 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:
|
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.