feat(enhancement): resolve the problem of udp asymmetric routing#2570
Open
Micbetter wants to merge 1 commit into
Open
feat(enhancement): resolve the problem of udp asymmetric routing#2570Micbetter wants to merge 1 commit into
Micbetter wants to merge 1 commit into
Conversation
Author
|
Hi @oteffahi, Adding tests to reproduce this bug is not easily in a standard CI environment, because we require a multi-IP host. Do you have any suggestions on how to approach the reproduction test for this? |
Contributor
Correct me if I'm wrong, I believe the requirements are the same as for binding tests, which use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds the sender-side support for
IP_PKTINFO(andIPV6_PKTINFO) in thezenoh-link-udpmodule on Unix platforms.What does this PR do?
send_with_src_innertopktinfo_unix.rs, utilizinglibc::sendmsgto injectIP_PKTINFO(orIPV6_PKTINFO) into the ancillary data (cmsg) of outgoing UDP packets.cmsgbuffer is efficiently stack-allocated using a compile-time computedCMSG_BUF_SIZEto avoid heap allocations in the hot path.send_to(buffer, dst_addr, src_addr)API inPktInfoUdpSocketand gracefully falls back to the standardsend_toon non-Unix platforms.LinkUnicastUdpUnconnectedinunicast.rsto leverage this new API, ensuring that unconnected UDP sockets (e.g., those listening on0.0.0.0or[::]) reply using the exact local IP address on which the incoming packet was received.Why is this change needed?
Prior to this PR, Zenoh's UDP link successfully utilized
IP_PKTINFOviarecvmsgto determine the specific local IP address a packet arrived on. However, when replying, Zenoh fell back to the standardUdpSocket::send_to(), ignoring the captured local IP.This created a severe issue known as udp asymmetric routing in multi-homed environments (e.g., a node with both
eth0andwlan0listening on0.0.0.0).When a client connected to the server's
wlan0IP, the server would often reply viaeth0due to OS routing table defaults, causing the reply packet to bear theeth0source IP. Because the client's socket wasconnect()ed to thewlan0IP, the client's OS kernel would strictly drop the mismatching reply packet.🏷️ Label-Based Checklist
Based on the labels applied to this PR, please complete these additional requirements:
Labels:
bug🐛 Bug Fix Requirements
Since this PR is labeled as a bug fix, please ensure:
Why this matters: Bugs without tests often reoccur.
Instructions:
- [ ]to- [x])This checklist updates automatically when labels change, but preserves your checked boxes.