Skip to content

[23248] Fix DS initialization on "any" if no interfaces are available (backport #5850) #5877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 2.14.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/cpp/rtps/participant/RTPSParticipantImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2888,6 +2888,13 @@ bool RTPSParticipantImpl::did_mutation_took_place_on_meta(
if (locals.empty())
{
IPFinder::getIP4Address(&locals);
// If no local interfaces found, use localhost
if (locals.empty())
{
Locator_t loc_lo;
IPLocator::setIPv4(loc_lo, "127.0.0.1");
locals.push_back(loc_lo);
}
}

// add a locator for each local
Expand Down
1 change: 1 addition & 0 deletions test/dds/communication/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ list(APPEND TEST_DEFINITIONS


list(APPEND XML_CONFIGURATION_FILES
ds_client.xml
simple_reliable_profile.xml
simple_besteffort_profile.xml
simple_reliable_zerocopy_profile.xml
Expand Down
75 changes: 75 additions & 0 deletions test/dds/communication/ds_client.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8" ?>
<dds xmlns="http://www.eprosima.com">
<profiles>
<transport_descriptors>
<transport_descriptor>
<transport_id>udp_transport</transport_id>
<type>UDPv4</type>
</transport_descriptor>
</transport_descriptors>

<participant profile_name="Client" is_default_profile="true">
<rtps>
<useBuiltinTransports>false</useBuiltinTransports>
<userTransports>
<transport_id>udp_transport</transport_id>
</userTransports>
<builtin>
<discovery_config>
<discoveryProtocol>CLIENT</discoveryProtocol>
<discoveryServersList>
<RemoteServer prefix="44.53.00.5f.45.50.52.4f.53.49.4d.41">
<metatrafficUnicastLocatorList>
<locator>
<udpv4>
<address>${SERVER_IP}</address>
<port>11811</port>
</udpv4>
</locator>
</metatrafficUnicastLocatorList>
</RemoteServer>
</discoveryServersList>
</discovery_config>

<metatrafficUnicastLocatorList>
<locator>
<udpv4>
<port>17401</port>
</udpv4>
</locator>
</metatrafficUnicastLocatorList>
</builtin>

<defaultUnicastLocatorList>
<locator>
<udpv4>
<port>17400</port>
</udpv4>
</locator>
</defaultUnicastLocatorList>
</rtps>
</participant>

<data_writer profile_name="simple_publisher_profile" is_default_profile="true">
<qos>
<reliability>
<kind>RELIABLE</kind>
</reliability>
<data_sharing>
<kind>OFF</kind>
</data_sharing>
</qos>
</data_writer>
<data_reader profile_name="simple_subscriber_profile" is_default_profile="true">
<qos>
<reliability>
<kind>RELIABLE</kind>
</reliability>
<data_sharing>
<kind>OFF</kind>
</data_sharing>
</qos>
</data_reader>

</profiles>
</dds>
8 changes: 8 additions & 0 deletions test/dds/communication/dyn_network/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,11 @@ configure_file(launch_subscriber.bash
add_test(NAME dds.communication.dynamic_interfaces
COMMAND ${DOCKER_EXECUTABLE} compose -f ${CMAKE_CURRENT_BINARY_DIR}/dynamic_interfaces.compose.yml up
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

configure_file(ds_init_no_interfaces.compose.yml
${CMAKE_CURRENT_BINARY_DIR}/ds_init_no_interfaces.compose.yml @ONLY)
configure_file(launch_ds_no_interfaces.bash
${CMAKE_CURRENT_BINARY_DIR}/launch_ds_no_interfaces.bash @ONLY)
add_test(NAME dds.commmunication.ds_init_with_no_interfaces
COMMAND ${DOCKER_EXECUTABLE} compose -f ${CMAKE_CURRENT_BINARY_DIR}/ds_init_no_interfaces.compose.yml up --exit-code-from server-pub-sub
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
14 changes: 14 additions & 0 deletions test/dds/communication/dyn_network/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,17 @@ ENV DEBIAN_FRONTEND=noninteractive

# Install apt dependencies
RUN apt-get update && apt-get install --yes net-tools && rm -rf /var/lib/apt/lists/*

FROM ubuntu:$ubuntu_version AS ubuntu-cli

# Needed for a dependency that forces to set timezone
ENV TZ=Europe/Madrid
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Avoids using interactions during building
ENV DEBIAN_FRONTEND=noninteractive

# Install apt dependencies
RUN apt-get update && apt-get install --yes python3 python3-pip && rm -rf /var/lib/apt/lists/*

RUN pip3 install psutil
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2025 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

services:
server-pub-sub:
build: .
image: ubuntu-cli:22.04
volumes:
- @PROJECT_BINARY_DIR@:@PROJECT_BINARY_DIR@
- @fastcdr_LIB_DIR@:@fastcdr_LIB_DIR@
- @CMAKE_INSTALL_PREFIX@:@CMAKE_INSTALL_PREFIX@
@TINYXML2_LIB_DIR_COMPOSE_VOLUME@
environment:
# Load also fastdds libraries to run the CLI
LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@:@CMAKE_INSTALL_PREFIX@/lib:$LD_LIBRARY_PATH
SERVER_IP: 127.0.0.1
working_dir: @PROJECT_BINARY_DIR@/test/dds/communication
command: @SHELL_EXECUTABLE@ "dyn_network/launch_ds_no_interfaces.bash"
network_mode: none
54 changes: 54 additions & 0 deletions test/dds/communication/dyn_network/launch_ds_no_interfaces.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2025 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/bin/bash

set -e

PREFIX="@CMAKE_INSTALL_PREFIX@"
EXAMPLE_DIR="@PROJECT_BINARY_DIR@/test/dds/communication"
export EXAMPLE_DIR

echo "[INFO] Starting discovery server"
"$PREFIX/bin/fastdds" discovery -i 0 -l 0.0.0.0 &
SERVER_PID=$!


# Publisher
echo "[INFO] Starting publisher"
"$EXAMPLE_DIR/DDSCommunicationPublisher" \
--xmlfile "$EXAMPLE_DIR/ds_client.xml" \
--wait 1 --samples 10 --loops 1 --seed 0 --magic T &
PUB_PID=$!

# Subscriber
echo "[INFO] Starting subscriber"
"$EXAMPLE_DIR/DDSCommunicationSubscriber" \
--xmlfile "$EXAMPLE_DIR/ds_client.xml" \
--samples 10 --seed 0 --magic T --rescan 2 &
SUB_PID=$!

sleep 15
# Discovery server process must still be running
if ! kill "$SERVER_PID" 2>/dev/null; then
echo "[ERROR] Discover server ended unexpectedly"
exit 1
else
echo "[INFO] Manually killing discovery server. Server execution successful"
fi

# PUBLISHER and SUBSCRIBER processes must end gracefully
wait $PUB_PID
wait $SUB_PID
echo "[INFO] Test completed successfully"
Loading