Repository navigation
Conversation
The unicast locators in SPDP/SEDP announcements listed every local IPv4 address, including interfaces that cannot pass traffic (an idle docker0 bridge, an unplugged NIC, Jetson's l4tbr0), in random order because netdev collects interfaces through a HashMap. Fast DDS uses only the first 4 unicast locators by default. On a host with more addresses, whether the reachable address made it into the first 4 was decided by chance at every process start, so discovery with Fast DDS peers worked or failed seemingly at random. - Sort the enumerated interfaces by index and address. - Do not announce addresses of non-running (IFF_RUNNING unset) interfaces. Loopback is always kept for same-host peers, and an explicit only_networks selection is honored as before. Co-authored-by: Copilot <[email protected]>
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.
Problem
The unicast locators in SPDP/SEDP announcements list every local IPv4 address, including those of interfaces that cannot pass traffic. Examples are an idle
docker0bridge or an unplugged NIC.They are also listed in random order.
netdev::get_interfaces()collects interfaces through aHashMap, so the order differs between processes, and even between the metatraffic and user-traffic lists of a single participant.Fast DDS uses only the first 4 unicast locators by default (
max_unicast_locators). On a host with more addresses, whether the reachable address made it into the first 4 was decided by chance at every process start.One RustDDS process was discovered by the
ros2CLI (Fast DDS) and another was not. A restart could flip which one.Change
(index, address), so the announced order is deterministic. Loopback and primary NICs normally come first.IFF_RUNNINGunset). Loopback is always kept for same-host peers. An explicitonly_networksselection is honored as before, even for a non-running interface.The change is limited to
src/network/util.rsand adds a unit test.Limitation
Interfaces are still read once, at participant creation. An interface that comes up later is not announced until restart. This was already true for interfaces that get their address after startup.
Testing
cargo test --lib network::utilandcargo clippy --all-targets -- -D warningspass.docker0andbr-*bridges, the announced locators are127.0.0.1, followed by the two running NICs in the same order on every call. The bridges are no longer included.