From af94cb5e7dbdf7d8bed324368fbded13ccbc275f Mon Sep 17 00:00:00 2001 From: Eduardo Ponz Segrelles Date: Tue, 6 Aug 2024 07:41:22 +0200 Subject: [PATCH] Discard local SHM locators that cannot be openned (#5118) * Refs #19036: NetworkFactory.h -> NetworkFactory.hpp Signed-off-by: eduponz * Refs #19036: Add NetworkFactory::is_locator_reachable API Signed-off-by: eduponz * Refs #19036: ProxyDataFilters::filter_locators delegates locator checking to the NetworkFactory Signed-off-by: eduponz * Refs #19036: NetworkFactory::is_locator_reachable iterates over the transports until one reports locator reachability Signed-off-by: eduponz * Refs #19036: SharedMemTransport::is_locator_reachable discards non-shm non-local ports, and shm local ports that cannot open to write Signed-off-by: eduponz * Refs #19036: Apply suggestions Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #19036: Protect openned_ports_ collection Signed-off-by: Mario Dominguez * Refs #19036: Add missing protection Signed-off-by: Mario Dominguez --------- Signed-off-by: eduponz Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> Signed-off-by: Mario Dominguez Co-authored-by: elianalf <62831776+elianalf@users.noreply.github.com> Co-authored-by: Mario Dominguez --- .../rtps/transport/ChainingTransport.hpp | 10 +++ .../rtps/transport/TransportInterface.hpp | 11 ++++ .../builtin/data/ParticipantProxyData.cpp | 18 +++--- .../builtin/data/ParticipantProxyData.hpp | 7 +- .../rtps/builtin/data/ProxyDataFilters.hpp | 25 +++----- src/cpp/rtps/builtin/data/ReaderProxyData.cpp | 14 ++-- src/cpp/rtps/builtin/data/ReaderProxyData.hpp | 4 +- src/cpp/rtps/builtin/data/WriterProxyData.cpp | 14 ++-- src/cpp/rtps/builtin/data/WriterProxyData.hpp | 3 +- .../discovery/endpoint/EDPSimpleListeners.cpp | 12 ++-- .../discovery/participant/PDPListener.cpp | 2 +- .../participant/PDPServerListener.cpp | 1 - src/cpp/rtps/network/NetworkFactory.cpp | 16 ++++- .../{NetworkFactory.h => NetworkFactory.hpp} | 17 ++++- .../rtps/participant/RTPSParticipantImpl.cpp | 3 - .../rtps/participant/RTPSParticipantImpl.h | 2 +- src/cpp/rtps/security/SecurityManager.cpp | 2 +- src/cpp/rtps/transport/TCPv4Transport.cpp | 6 ++ src/cpp/rtps/transport/TCPv4Transport.h | 4 ++ src/cpp/rtps/transport/TCPv6Transport.cpp | 6 ++ src/cpp/rtps/transport/TCPv6Transport.h | 4 ++ src/cpp/rtps/transport/UDPv4Transport.cpp | 6 ++ src/cpp/rtps/transport/UDPv4Transport.h | 4 ++ src/cpp/rtps/transport/UDPv6Transport.cpp | 6 ++ src/cpp/rtps/transport/UDPv6Transport.h | 4 ++ .../shared_mem/SharedMemTransport.cpp | 48 ++++++++++++-- .../transport/shared_mem/SharedMemTransport.h | 6 ++ .../{NetworkFactory.h => NetworkFactory.hpp} | 12 +++- .../rtps/participant/RTPSParticipantImpl.h | 2 +- .../rtps/builtin/data/ReaderProxyData.hpp | 3 +- .../builtin/BuiltinDataSerializationTests.cpp | 64 +++++++++---------- .../rtps/network/NetworkFactoryTests.cpp | 2 +- .../rtps/network/mock/MockTransport.cpp | 6 ++ .../rtps/network/mock/MockTransport.h | 5 ++ test/unittest/transport/TCPv6Tests.cpp | 2 +- 35 files changed, 238 insertions(+), 113 deletions(-) rename src/cpp/rtps/network/{NetworkFactory.h => NetworkFactory.hpp} (95%) rename test/mock/rtps/NetworkFactory/rtps/network/{NetworkFactory.h => NetworkFactory.hpp} (91%) diff --git a/include/fastdds/rtps/transport/ChainingTransport.hpp b/include/fastdds/rtps/transport/ChainingTransport.hpp index 1fa44fe28e4..c1c84af9723 100644 --- a/include/fastdds/rtps/transport/ChainingTransport.hpp +++ b/include/fastdds/rtps/transport/ChainingTransport.hpp @@ -389,6 +389,16 @@ class ChainingTransport : public TransportInterface return low_level_transport_->is_locator_allowed(locator); } + /*! + * Call the low-level transport `is_locator_reachable()`. + * Must report whether the given locator is reachable by this transport. + */ + FASTDDS_EXPORTED_API bool is_locator_reachable( + const fastdds::rtps::Locator_t& locator) override + { + return low_level_transport_->is_locator_reachable(locator); + } + protected: std::unique_ptr low_level_transport_; diff --git a/include/fastdds/rtps/transport/TransportInterface.hpp b/include/fastdds/rtps/transport/TransportInterface.hpp index 7f2e6329b8f..aa14e8f13cb 100644 --- a/include/fastdds/rtps/transport/TransportInterface.hpp +++ b/include/fastdds/rtps/transport/TransportInterface.hpp @@ -117,6 +117,17 @@ class FASTDDS_EXPORTED_API TransportInterface virtual bool is_locator_allowed( const Locator&) const = 0; + /** + * Must report whether the given locator is reachable by this transport. + * + * @param [in] locator @ref Locator for which the reachability is checked. + * + * @return true if the input locator is reachable by this transport, false otherwise. + */ + virtual bool is_locator_reachable( + const Locator_t& locator) = 0; + + //! Returns the locator describing the main (most general) channel that can write to the provided remote locator. virtual Locator RemoteToMainLocal( const Locator& remote) const = 0; diff --git a/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp b/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp index b9746004f03..9e494efdecf 100644 --- a/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include @@ -446,16 +446,15 @@ bool ParticipantProxyData::writeToCDRMessage( bool ParticipantProxyData::readFromCDRMessage( CDRMessage_t* msg, bool use_encapsulation, - const NetworkFactory& network, - bool is_shm_transport_available, + NetworkFactory& network, bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id) { auto param_process = - [this, &network, &is_shm_transport_available, &should_filter_locators, source_vendor_id]( + [this, &network, &should_filter_locators, source_vendor_id]( CDRMessage_t* msg, const ParameterId_t& pid, uint16_t plength) { - static_cast(source_vendor_id); + m_VendorId = source_vendor_id; switch (pid){ case fastdds::dds::PID_KEY_HASH: { @@ -503,7 +502,6 @@ bool ParticipantProxyData::readFromCDRMessage( m_VendorId[0] = p.vendorId[0]; m_VendorId[1] = p.vendorId[1]; - is_shm_transport_available &= (m_VendorId == c_VendorId_eProsima); break; } case fastdds::dds::PID_PRODUCT_VERSION: @@ -613,7 +611,7 @@ bool ParticipantProxyData::readFromCDRMessage( m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( - is_shm_transport_available, + network, metatraffic_locators, temp_locator, false); @@ -643,7 +641,7 @@ bool ParticipantProxyData::readFromCDRMessage( m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( - is_shm_transport_available, + network, metatraffic_locators, temp_locator, true); @@ -673,7 +671,7 @@ bool ParticipantProxyData::readFromCDRMessage( m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( - is_shm_transport_available, + network, default_locators, temp_locator, true); @@ -703,7 +701,7 @@ bool ParticipantProxyData::readFromCDRMessage( m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( - is_shm_transport_available, + network, default_locators, temp_locator, false); diff --git a/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp b/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp index 540c80010f6..09e65d13219 100644 --- a/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp +++ b/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp @@ -28,11 +28,13 @@ #include #include #include +#include #include #include -#include #include +#include + namespace eprosima { namespace fastdds { namespace rtps { @@ -157,8 +159,7 @@ class ParticipantProxyData bool readFromCDRMessage( CDRMessage_t* msg, bool use_encapsulation, - const NetworkFactory& network, - bool is_shm_transport_available, + NetworkFactory& network, bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id = c_VendorId_eProsima); diff --git a/src/cpp/rtps/builtin/data/ProxyDataFilters.hpp b/src/cpp/rtps/builtin/data/ProxyDataFilters.hpp index 00270d6e200..5a6f802a3ce 100644 --- a/src/cpp/rtps/builtin/data/ProxyDataFilters.hpp +++ b/src/cpp/rtps/builtin/data/ProxyDataFilters.hpp @@ -12,10 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef _FASTDDS_RTPS_BUILTIN_DATA_PROXYDATAFILTERS_H_ -#define _FASTDDS_RTPS_BUILTIN_DATA_PROXYDATAFILTERS_H_ +#ifndef FASTDDS_RTPS_BUILTIN_DATA__PROXYDATAFILTERS_HPP +#define FASTDDS_RTPS_BUILTIN_DATA__PROXYDATAFILTERS_HPP #include + +#include #include namespace eprosima { @@ -30,27 +32,20 @@ class ProxyDataFilters public: /** - * This function filters out SHM locators when they cannot be used for communication on the local host. - * @param [in] is_shm_transport_available Indicates whether the participant has SHM transport enabled. + * @brief This function filters out unreachable locators. + * + * @param [in] network_factory Reference to the @ref NetworkFactory * @param [in,out] target_locators_list List where parsed locators are stored * @param [in] temp_locator New locator to parse * @param [in] is_unicast true if temp_locator is unicast, false if it is multicast */ static void filter_locators( - bool is_shm_transport_available, + NetworkFactory& network_factory, RemoteLocatorList& target_locators_list, const Locator_t& temp_locator, bool is_unicast) { - using SHMLocator = eprosima::fastdds::rtps::SHMLocator; - - bool can_use_locator = LOCATOR_KIND_SHM != temp_locator.kind; - if (!can_use_locator) - { - can_use_locator = is_shm_transport_available && SHMLocator::is_shm_and_from_this_host(temp_locator); - } - - if (can_use_locator) + if (network_factory.is_locator_reachable(temp_locator)) { if (is_unicast) { @@ -69,4 +64,4 @@ class ProxyDataFilters } /* namespace fastdds */ } /* namespace eprosima */ -#endif // _FASTDDS_RTPS_BUILTIN_DATA_PROXYDATAFILTERS_H_ +#endif // FASTDDS_RTPS_BUILTIN_DATA__PROXYDATAFILTERS_HPP diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp index eedb89d3f88..0a75a6a84b9 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include "ProxyDataFilters.hpp" @@ -647,15 +647,14 @@ bool ReaderProxyData::writeToCDRMessage( bool ReaderProxyData::readFromCDRMessage( CDRMessage_t* msg, - const NetworkFactory& network, - bool is_shm_transport_available, + NetworkFactory& network, bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id) { - auto param_process = [this, &network, &is_shm_transport_available, &should_filter_locators, source_vendor_id]( + auto param_process = [this, &network, &should_filter_locators, source_vendor_id]( CDRMessage_t* msg, const ParameterId_t& pid, uint16_t plength) { - VendorId_t vendor_id = c_VendorId_Unknown; + VendorId_t vendor_id = source_vendor_id; switch (pid) { @@ -668,7 +667,6 @@ bool ReaderProxyData::readFromCDRMessage( return false; } - is_shm_transport_available &= (p.vendorId == c_VendorId_eProsima); vendor_id = p.vendorId; break; } @@ -902,7 +900,7 @@ bool ReaderProxyData::readFromCDRMessage( m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( - is_shm_transport_available, + network, remote_locators_, temp_locator, true); @@ -930,7 +928,7 @@ bool ReaderProxyData::readFromCDRMessage( m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( - is_shm_transport_available, + network, remote_locators_, temp_locator, false); diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.hpp b/src/cpp/rtps/builtin/data/ReaderProxyData.hpp index 7712ef2ea61..9511c31d140 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.hpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.hpp @@ -424,15 +424,13 @@ class ReaderProxyData * parameter list. * @param msg Pointer to the message. * @param network Reference to network factory for locator validation and transformation - * @param is_shm_transport_available Indicates whether the Reader is reachable by SHM. * @param should_filter_locators Whether to retrieve the locators before the external locators filtering * @param source_vendor_id VendorId of the source participant from which the message was received * @return true on success */ bool readFromCDRMessage( CDRMessage_t* msg, - const NetworkFactory& network, - bool is_shm_transport_available, + NetworkFactory& network, bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id = c_VendorId_eProsima); diff --git a/src/cpp/rtps/builtin/data/WriterProxyData.cpp b/src/cpp/rtps/builtin/data/WriterProxyData.cpp index c892798988f..857668b00a9 100644 --- a/src/cpp/rtps/builtin/data/WriterProxyData.cpp +++ b/src/cpp/rtps/builtin/data/WriterProxyData.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include "ProxyDataFilters.hpp" @@ -614,15 +614,14 @@ bool WriterProxyData::writeToCDRMessage( bool WriterProxyData::readFromCDRMessage( CDRMessage_t* msg, - const NetworkFactory& network, - bool is_shm_transport_available, + NetworkFactory& network, bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id) { - auto param_process = [this, &network, &is_shm_transport_available, &should_filter_locators, source_vendor_id]( + auto param_process = [this, &network, &should_filter_locators, source_vendor_id]( CDRMessage_t* msg, const ParameterId_t& pid, uint16_t plength) { - VendorId_t vendor_id = c_VendorId_Unknown; + VendorId_t vendor_id = source_vendor_id; switch (pid) { @@ -635,7 +634,6 @@ bool WriterProxyData::readFromCDRMessage( return false; } - is_shm_transport_available &= (p.vendorId == c_VendorId_eProsima); vendor_id = p.vendorId; break; } @@ -899,7 +897,7 @@ bool WriterProxyData::readFromCDRMessage( m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( - is_shm_transport_available, + network, remote_locators_, temp_locator, true); @@ -926,7 +924,7 @@ bool WriterProxyData::readFromCDRMessage( m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( - is_shm_transport_available, + network, remote_locators_, temp_locator, false); diff --git a/src/cpp/rtps/builtin/data/WriterProxyData.hpp b/src/cpp/rtps/builtin/data/WriterProxyData.hpp index 7eb674628a3..7b0729f159c 100644 --- a/src/cpp/rtps/builtin/data/WriterProxyData.hpp +++ b/src/cpp/rtps/builtin/data/WriterProxyData.hpp @@ -451,8 +451,7 @@ class WriterProxyData //!Read a parameter list from a CDRMessage_t. bool readFromCDRMessage( CDRMessage_t* msg, - const NetworkFactory& network, - bool is_shm_transport_possible, + NetworkFactory& network, bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id = c_VendorId_eProsima); diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp index b201eef08a5..c133fb3950c 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include @@ -70,13 +70,12 @@ void EDPBasePUBListener::add_writer_from_change( const EndpointAddedCallback& writer_added_callback /* = nullptr*/) { //LOAD INFORMATION IN DESTINATION WRITER PROXY DATA - const NetworkFactory& network = edp->mp_RTPSParticipant->network_factory(); + NetworkFactory& network = edp->mp_RTPSParticipant->network_factory(); CDRMessage_t tempMsg(change->serializedPayload); auto temp_writer_data = edp->get_temporary_writer_proxies_pool().get(); const auto type_server = change->writerGUID; - if (temp_writer_data->readFromCDRMessage(&tempMsg, network, - edp->mp_RTPSParticipant->has_shm_transport(), true, change->vendor_id)) + if (temp_writer_data->readFromCDRMessage(&tempMsg, network, true, change->vendor_id)) { if (temp_writer_data->guid().guidPrefix == edp->mp_RTPSParticipant->getGuid().guidPrefix) { @@ -215,13 +214,12 @@ void EDPBaseSUBListener::add_reader_from_change( const EndpointAddedCallback& reader_added_callback /* = nullptr*/) { //LOAD INFORMATION IN TEMPORAL READER PROXY DATA - const NetworkFactory& network = edp->mp_RTPSParticipant->network_factory(); + NetworkFactory& network = edp->mp_RTPSParticipant->network_factory(); CDRMessage_t tempMsg(change->serializedPayload); auto temp_reader_data = edp->get_temporary_reader_proxies_pool().get(); const auto type_server = change->writerGUID; - if (temp_reader_data->readFromCDRMessage(&tempMsg, network, - edp->mp_RTPSParticipant->has_shm_transport(), true, change->vendor_id)) + if (temp_reader_data->readFromCDRMessage(&tempMsg, network, true, change->vendor_id)) { if (temp_reader_data->guid().guidPrefix == edp->mp_RTPSParticipant->getGuid().guidPrefix) { diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp index f5563ef5af5..5e135c4c390 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp @@ -106,7 +106,7 @@ void PDPListener::on_new_cache_change_added( CDRMessage_t msg(change->serializedPayload); temp_participant_data_.clear(); if (temp_participant_data_.readFromCDRMessage(&msg, true, parent_pdp_->getRTPSParticipant()->network_factory(), - parent_pdp_->getRTPSParticipant()->has_shm_transport(), true, change_in->vendor_id)) + true, change_in->vendor_id)) { // After correctly reading it change->instanceHandle = temp_participant_data_.m_key; diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp index 9f054fbb0c0..d928d9ab4c8 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp @@ -139,7 +139,6 @@ void PDPServerListener::on_new_cache_change_added( &msg, true, pdp_server()->getRTPSParticipant()->network_factory(), - pdp_server()->getRTPSParticipant()->has_shm_transport(), true, change_in->vendor_id)) { diff --git a/src/cpp/rtps/network/NetworkFactory.cpp b/src/cpp/rtps/network/NetworkFactory.cpp index 6102d017b4f..6e948c85553 100644 --- a/src/cpp/rtps/network/NetworkFactory.cpp +++ b/src/cpp/rtps/network/NetworkFactory.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#include #include #include @@ -284,6 +284,20 @@ bool NetworkFactory::is_locator_remote_or_allowed( return (is_locator_supported(locator) && !is_fastdds_local) || is_locator_allowed(locator); } +bool NetworkFactory::is_locator_reachable( + const Locator_t& locator) +{ + for (auto& transport : mRegisteredTransports) + { + if (transport->is_locator_reachable(locator)) + { + return true; + } + } + + return false; +} + void NetworkFactory::select_locators( LocatorSelector& selector) const { diff --git a/src/cpp/rtps/network/NetworkFactory.h b/src/cpp/rtps/network/NetworkFactory.hpp similarity index 95% rename from src/cpp/rtps/network/NetworkFactory.h rename to src/cpp/rtps/network/NetworkFactory.hpp index 34e9a592809..4e282106988 100644 --- a/src/cpp/rtps/network/NetworkFactory.h +++ b/src/cpp/rtps/network/NetworkFactory.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef FASTDDS_RTPS_NETWORK__NETWORKFACTORY_H -#define FASTDDS_RTPS_NETWORK__NETWORKFACTORY_H +#ifndef FASTDDS_RTPS_NETWORK__NETWORKFACTORY_HPP +#define FASTDDS_RTPS_NETWORK__NETWORKFACTORY_HPP #include #include @@ -195,6 +195,17 @@ class NetworkFactory const Locator_t& locator, bool is_fastdds_local) const; + /** + * Must report whether the given locator is reachable by at least one of the registered transports. + * + * @param [in] locator @ref Locator for which the reachability is checked. + * + * @return true if the input locator is reachable by at least one of the registered transports, + * false otherwise. + */ + bool is_locator_reachable( + const Locator_t& locator); + /** * Perform the locator selection algorithm. * @@ -351,4 +362,4 @@ class NetworkFactory } // namespace fastdds } // namespace eprosima -#endif // FASTDDS_RTPS_NETWORK__NETWORKFACTORY_H +#endif // FASTDDS_RTPS_NETWORK__NETWORKFACTORY_HPP diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 9977c77ad30..47e6ad5ffe1 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -3006,7 +3006,6 @@ bool RTPSParticipantImpl::fill_discovery_data_from_cdr_message( &serialized_msg, true, network_factory(), - has_shm_transport(), false, c_VendorId_eProsima); @@ -3038,7 +3037,6 @@ bool RTPSParticipantImpl::fill_discovery_data_from_cdr_message( ret = writer_data.readFromCDRMessage( &serialized_msg, network_factory(), - has_shm_transport(), false, c_VendorId_eProsima); @@ -3074,7 +3072,6 @@ bool RTPSParticipantImpl::fill_discovery_data_from_cdr_message( ret = reader_data.readFromCDRMessage( &serialized_msg, network_factory(), - has_shm_transport(), false, c_VendorId_eProsima); diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.h b/src/cpp/rtps/participant/RTPSParticipantImpl.h index 74ed6940d7a..b6477c99072 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.h +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.h @@ -54,7 +54,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/cpp/rtps/security/SecurityManager.cpp b/src/cpp/rtps/security/SecurityManager.cpp index ca68fce8bfc..a11f5159a1f 100644 --- a/src/cpp/rtps/security/SecurityManager.cpp +++ b/src/cpp/rtps/security/SecurityManager.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/cpp/rtps/transport/TCPv4Transport.cpp b/src/cpp/rtps/transport/TCPv4Transport.cpp index 6552edf7a56..9f6b75b09bd 100644 --- a/src/cpp/rtps/transport/TCPv4Transport.cpp +++ b/src/cpp/rtps/transport/TCPv4Transport.cpp @@ -434,6 +434,12 @@ bool TCPv4Transport::is_locator_allowed( return is_interface_allowed(IPLocator::toIPv4string(locator)); } +bool TCPv4Transport::is_locator_reachable( + const Locator_t& locator) +{ + return IsLocatorSupported(locator); +} + bool TCPv4Transport::compare_locator_ip( const Locator& lh, const Locator& rh) const diff --git a/src/cpp/rtps/transport/TCPv4Transport.h b/src/cpp/rtps/transport/TCPv4Transport.h index 190b4d8302d..a21a4206988 100644 --- a/src/cpp/rtps/transport/TCPv4Transport.h +++ b/src/cpp/rtps/transport/TCPv4Transport.h @@ -96,6 +96,10 @@ class TCPv4Transport : public TCPTransportInterface bool is_locator_allowed( const Locator& locator) const override; + //! Checks for whether locator is reachable. + bool is_locator_reachable( + const Locator_t&) override; + //! Checks if the given ip has been included in the white list to use it. virtual bool is_interface_allowed( const std::string& iface) const override; diff --git a/src/cpp/rtps/transport/TCPv6Transport.cpp b/src/cpp/rtps/transport/TCPv6Transport.cpp index 5c9d727d894..9cb3d58a43d 100644 --- a/src/cpp/rtps/transport/TCPv6Transport.cpp +++ b/src/cpp/rtps/transport/TCPv6Transport.cpp @@ -317,6 +317,12 @@ bool TCPv6Transport::is_locator_allowed( return is_interface_allowed(IPLocator::toIPv6string(locator)); } +bool TCPv6Transport::is_locator_reachable( + const Locator_t& locator) +{ + return IsLocatorSupported(locator); +} + bool TCPv6Transport::is_interface_whitelist_empty() const { return interface_whitelist_.empty(); diff --git a/src/cpp/rtps/transport/TCPv6Transport.h b/src/cpp/rtps/transport/TCPv6Transport.h index dd3d40b7ade..03d90fdd6bb 100644 --- a/src/cpp/rtps/transport/TCPv6Transport.h +++ b/src/cpp/rtps/transport/TCPv6Transport.h @@ -98,6 +98,10 @@ class TCPv6Transport : public TCPTransportInterface bool is_locator_allowed( const Locator& locator) const override; + //! Checks for whether locator is reachable. + bool is_locator_reachable( + const Locator_t&) override; + //! Checks if the interfaces white list is empty. virtual bool is_interface_whitelist_empty() const override; diff --git a/src/cpp/rtps/transport/UDPv4Transport.cpp b/src/cpp/rtps/transport/UDPv4Transport.cpp index dd24c2b97f7..d04ee7e5499 100644 --- a/src/cpp/rtps/transport/UDPv4Transport.cpp +++ b/src/cpp/rtps/transport/UDPv4Transport.cpp @@ -603,6 +603,12 @@ bool UDPv4Transport::is_locator_allowed( return is_interface_allowed(IPLocator::toIPv4string(locator)); } +bool UDPv4Transport::is_locator_reachable( + const Locator_t& locator) +{ + return IsLocatorSupported(locator); +} + LocatorList UDPv4Transport::NormalizeLocator( const Locator& locator) { diff --git a/src/cpp/rtps/transport/UDPv4Transport.h b/src/cpp/rtps/transport/UDPv4Transport.h index 8f1d2c37f33..ceabb4c4a3a 100644 --- a/src/cpp/rtps/transport/UDPv4Transport.h +++ b/src/cpp/rtps/transport/UDPv4Transport.h @@ -147,6 +147,10 @@ class UDPv4Transport : public UDPTransportInterface bool is_locator_allowed( const Locator&) const override; + //! Checks for whether locator is reachable. + bool is_locator_reachable( + const Locator_t&) override; + //! Checks if the given interface is allowed by the white list. bool is_interface_allowed( const asio::ip::address_v4& ip) const; diff --git a/src/cpp/rtps/transport/UDPv6Transport.cpp b/src/cpp/rtps/transport/UDPv6Transport.cpp index af9447cda39..437b3c8825f 100644 --- a/src/cpp/rtps/transport/UDPv6Transport.cpp +++ b/src/cpp/rtps/transport/UDPv6Transport.cpp @@ -608,6 +608,12 @@ bool UDPv6Transport::is_locator_allowed( return is_interface_allowed(IPLocator::toIPv6string(locator)); } +bool UDPv6Transport::is_locator_reachable( + const Locator_t& locator) +{ + return IsLocatorSupported(locator); +} + LocatorList UDPv6Transport::NormalizeLocator( const Locator& locator) { diff --git a/src/cpp/rtps/transport/UDPv6Transport.h b/src/cpp/rtps/transport/UDPv6Transport.h index a96071371e4..0f4d4fb5758 100644 --- a/src/cpp/rtps/transport/UDPv6Transport.h +++ b/src/cpp/rtps/transport/UDPv6Transport.h @@ -134,6 +134,10 @@ class UDPv6Transport : public UDPTransportInterface bool is_locator_allowed( const Locator&) const override; + //! Checks for whether locator is reachable. + bool is_locator_reachable( + const Locator_t&) override; + /** * Method to get a list of interfaces to bind the socket associated to the given locator. * @return Vector of interfaces in string format. diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp b/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp index 6d78649f870..5f5710df5a7 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp +++ b/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp @@ -152,6 +152,29 @@ bool SharedMemTransport::is_locator_allowed( return IsLocatorSupported(locator); } +bool SharedMemTransport::is_locator_reachable( + const Locator_t& locator) +{ + bool is_reachable = SHMLocator::is_shm_and_from_this_host(locator); + + if (is_reachable) + { + try + { + is_reachable = (nullptr != find_port(locator.port)); + } + catch (const std::exception& e) + { + EPROSIMA_LOG_INFO(RTPS_MSG_OUT, + "Local SHM locator '" << locator << + "' is not reachable; discarding. Reason: " << e.what()); + is_reachable = false; + } + } + + return is_reachable; +} + LocatorList SharedMemTransport::NormalizeLocator( const Locator& locator) { @@ -209,7 +232,10 @@ void SharedMemTransport::clean_up() try { // Delete send ports - opened_ports_.clear(); + { + std::lock_guard lock(opened_ports_mutex_); + opened_ports_.clear(); + } // Delete input channels { @@ -516,6 +542,7 @@ bool SharedMemTransport::send( void SharedMemTransport::cleanup_output_ports() { + std::lock_guard lock(opened_ports_mutex_); auto it = opened_ports_.begin(); while (it != opened_ports_.end()) { @@ -533,12 +560,17 @@ void SharedMemTransport::cleanup_output_ports() std::shared_ptr SharedMemTransport::find_port( uint32_t port_id) { - auto ports_it = opened_ports_.find(port_id); - // The port is already opened - if (ports_it != opened_ports_.end()) { - return (*ports_it).second; + std::lock_guard lock(opened_ports_mutex_); + + auto ports_it = opened_ports_.find(port_id); + + // The port is already opened + if (ports_it != opened_ports_.end()) + { + return (*ports_it).second; + } } // The port is not opened @@ -546,7 +578,10 @@ std::shared_ptr SharedMemTransport::find_port( open_port(port_id, configuration_.port_queue_capacity(), configuration_.healthy_check_timeout_ms(), SharedMemGlobal::Port::OpenMode::Write); - opened_ports_[port_id] = port; + { + std::lock_guard lock(opened_ports_mutex_); + opened_ports_[port_id] = port; + } return port; } @@ -569,6 +604,7 @@ bool SharedMemTransport::push_discard( } else { + std::lock_guard lock(opened_ports_mutex_); EPROSIMA_LOG_WARNING(RTPS_MSG_OUT, "Port " << remote_locator.port << " inconsistent. Port dropped"); opened_ports_.erase(remote_locator.port); } diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemTransport.h b/src/cpp/rtps/transport/shared_mem/SharedMemTransport.h index 28d2ea52035..0e71462ad64 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemTransport.h +++ b/src/cpp/rtps/transport/shared_mem/SharedMemTransport.h @@ -225,6 +225,10 @@ class SharedMemTransport : public TransportInterface bool is_locator_allowed( const Locator&) const override; + //! Checks for whether locator is reachable. + bool is_locator_reachable( + const Locator_t&) override; + protected: std::shared_ptr shared_mem_manager_; @@ -233,6 +237,8 @@ class SharedMemTransport : public TransportInterface void clean_up(); + mutable std::mutex opened_ports_mutex_; + std::map> opened_ports_; mutable std::recursive_mutex input_channels_mutex_; diff --git a/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h b/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.hpp similarity index 91% rename from test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h rename to test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.hpp index fae7800f8e1..c57c7162c03 100644 --- a/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h +++ b/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef FASTDDS_RTPS_NETWORK__NETWORKFACTORY_H -#define FASTDDS_RTPS_NETWORK__NETWORKFACTORY_H +#ifndef FASTDDS_RTPS_NETWORK__NETWORKFACTORY_HPP +#define FASTDDS_RTPS_NETWORK__NETWORKFACTORY_HPP #include #include @@ -90,6 +90,12 @@ class NetworkFactory return true; } + bool is_locator_reachable( + const Locator_t&) + { + return true; + } + uint32_t get_min_send_buffer_size() { return 65536; @@ -117,4 +123,4 @@ class NetworkFactory } // namespace fastdds } // namespace eprosima -#endif // FASTDDS_RTPS_NETWORK__NETWORKFACTORY_H +#endif // FASTDDS_RTPS_NETWORK__NETWORKFACTORY_HPP diff --git a/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.h b/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.h index 90f5ac80ce0..5bf03ed9132 100644 --- a/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.h +++ b/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.h @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include #if HAVE_SECURITY diff --git a/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp b/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp index f2565882519..554adccbddf 100644 --- a/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp +++ b/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp @@ -141,8 +141,7 @@ class ReaderProxyData bool readFromCDRMessage( CDRMessage_t* /*msg*/, - const NetworkFactory& /*network*/, - bool /*is_shm_transport_possible*/, + NetworkFactory& /*network*/, fastdds::rtps::VendorId_t /*source_vendor_id*/) { return true; diff --git a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp index 706c955a72e..61d6dbb8e86 100644 --- a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp +++ b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace eprosima { namespace fastdds { @@ -118,7 +118,7 @@ TEST(BuiltinDataSerializationTests, ok_with_defaults) // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); // EXPECT_EQ(in, out); } @@ -137,7 +137,7 @@ TEST(BuiltinDataSerializationTests, ok_with_defaults) // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); } } @@ -150,7 +150,7 @@ TEST(BuiltinDataSerializationTests, msg_with_product_version) msg.init(buffer, buffer_length); msg.length = msg.max_size; - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, true, network, false, false, + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, true, network, false, c_VendorId_eProsima))); }; @@ -210,7 +210,7 @@ TEST(BuiltinDataSerializationTests, msg_without_datasharing) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - out.readFromCDRMessage(&msg, network, false, true); + out.readFromCDRMessage(&msg, network, true); ASSERT_EQ(out.m_qos.data_sharing.kind(), dds::OFF); } @@ -227,7 +227,7 @@ TEST(BuiltinDataSerializationTests, msg_without_datasharing) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - out.readFromCDRMessage(&msg, network, false, true); + out.readFromCDRMessage(&msg, network, true); ASSERT_EQ(out.m_qos.data_sharing.kind(), dds::OFF); } } @@ -250,7 +250,7 @@ TEST(BuiltinDataSerializationTests, msg_with_datasharing) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - out.readFromCDRMessage(&msg, network, false, true); + out.readFromCDRMessage(&msg, network, true); ASSERT_EQ(out.m_qos.data_sharing.kind(), dds::ON); } @@ -270,7 +270,7 @@ TEST(BuiltinDataSerializationTests, msg_with_datasharing) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - out.readFromCDRMessage(&msg, network, false, true); + out.readFromCDRMessage(&msg, network, true); ASSERT_EQ(out.m_qos.data_sharing.kind(), dds::ON); } } @@ -339,7 +339,7 @@ TEST(BuiltinDataSerializationTests, interoperability_with_opendds_3_27) msg.length = msg.max_size; WriterProxyData out(max_unicast_locators, max_multicast_locators); - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, true))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true))); } // DATA(r) @@ -401,7 +401,7 @@ TEST(BuiltinDataSerializationTests, interoperability_with_opendds_3_27) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, true))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true))); } } @@ -516,7 +516,7 @@ TEST(BuiltinDataSerializationTests, ignore_unsupported_type_object) msg.length = msg.max_size; WriterProxyData out(max_unicast_locators, max_multicast_locators); - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, true))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true))); } } @@ -594,7 +594,7 @@ TEST(BuiltinDataSerializationTests, property_list_with_binary_properties) msg.length = msg.max_size; ParticipantProxyData out(RTPSParticipantAllocationAttributes{}); - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, true, network, false, true))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, true, network, true))); } // Regression test for redmine tickets 20306 and 20307 @@ -607,7 +607,7 @@ TEST(BuiltinDataSerializationTests, other_vendor_parameter_list_with_custom_pids msg.init(buffer, buffer_length); msg.length = msg.max_size; - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, true, network, false, false, + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, true, network, false, fastdds::rtps::VendorId_t({2, 0})))); }; @@ -617,7 +617,7 @@ TEST(BuiltinDataSerializationTests, other_vendor_parameter_list_with_custom_pids msg.init(buffer, buffer_length); msg.length = msg.max_size; - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, false, + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, fastdds::rtps::VendorId_t({2, 0})))); }; @@ -627,7 +627,7 @@ TEST(BuiltinDataSerializationTests, other_vendor_parameter_list_with_custom_pids msg.init(buffer, buffer_length); msg.length = msg.max_size; - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, false, + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, fastdds::rtps::VendorId_t({2, 0})))); }; @@ -869,7 +869,7 @@ TEST(BuiltinDataSerializationTests, rti_parameter_list_with_custom_pids) msg.init(buffer, buffer_length); msg.length = msg.max_size; - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, true, network, false, false, + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, true, network, false, fastdds::rtps::c_VendorId_rti_connext))); }; @@ -879,7 +879,7 @@ TEST(BuiltinDataSerializationTests, rti_parameter_list_with_custom_pids) msg.init(buffer, buffer_length); msg.length = msg.max_size; - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, false, + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, fastdds::rtps::c_VendorId_rti_connext))); }; @@ -889,7 +889,7 @@ TEST(BuiltinDataSerializationTests, rti_parameter_list_with_custom_pids) msg.init(buffer, buffer_length); msg.length = msg.max_size; - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, false, + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, fastdds::rtps::c_VendorId_rti_connext))); }; @@ -1099,7 +1099,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_without_parameters) // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); ASSERT_EQ(in.content_filter().content_filtered_topic_name, out.content_filter().content_filtered_topic_name); ASSERT_EQ(in.content_filter().related_topic_name, out.content_filter().related_topic_name); @@ -1140,7 +1140,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_with_parameters) // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); ASSERT_EQ(in.content_filter().content_filtered_topic_name, out.content_filter().content_filtered_topic_name); ASSERT_EQ(in.content_filter().related_topic_name, out.content_filter().related_topic_name); @@ -1232,7 +1232,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_wrong_topic_name_deser EXPECT_TRUE(fastdds::dds::ParameterSerializer::add_parameter_sentinel(&msg)); msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1281,7 +1281,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_wrong_topic_name_deser EXPECT_TRUE(fastdds::dds::ParameterSerializer::add_parameter_sentinel(&msg)); msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1366,7 +1366,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_wrong_related_topic_na EXPECT_TRUE(fastdds::dds::ParameterSerializer::add_parameter_sentinel(&msg)); msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1415,7 +1415,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_wrong_related_topic_na EXPECT_TRUE(fastdds::dds::ParameterSerializer::add_parameter_sentinel(&msg)); msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1449,7 +1449,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_empty_filter_class) // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1504,7 +1504,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_wrong_filter_class_des EXPECT_TRUE(fastdds::dds::ParameterSerializer::add_parameter_sentinel(&msg)); msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1553,7 +1553,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_wrong_filter_class_des EXPECT_TRUE(fastdds::dds::ParameterSerializer::add_parameter_sentinel(&msg)); msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1587,7 +1587,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_empty_filter_expressio // Perform deserialization msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1642,7 +1642,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_wrong_filter_expressio EXPECT_TRUE(fastdds::dds::ParameterSerializer::add_parameter_sentinel(&msg)); msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); assert_is_empty_content_filter(out.content_filter()); } @@ -1829,7 +1829,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_interoperability) msg.length = msg.max_size; ReaderProxyData out(max_unicast_locators, max_multicast_locators); - EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, false, true))); + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true))); ASSERT_EQ("ContentFilter_0", out.content_filter().content_filtered_topic_name.to_string()); ASSERT_EQ("Square", out.content_filter().related_topic_name.to_string()); @@ -1898,7 +1898,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_max_parameter_check) EXPECT_TRUE(fastdds::dds::ParameterSerializer::add_parameter_sentinel(&msg)); msg.pos = 0; - EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true, true)); + EXPECT_TRUE(out.readFromCDRMessage(&msg, network, true)); ASSERT_EQ(100, out.content_filter().expression_parameters.size()); @@ -1942,7 +1942,7 @@ TEST(BuiltinDataSerializationTests, contentfilterproperty_max_parameter_check) msg_fault.pos = 0; // Deserialization of messages with more than 100 parameters should fail - ASSERT_FALSE(out.readFromCDRMessage(&msg_fault, network, true, true)); + ASSERT_FALSE(out.readFromCDRMessage(&msg_fault, network, true)); } } diff --git a/test/unittest/rtps/network/NetworkFactoryTests.cpp b/test/unittest/rtps/network/NetworkFactoryTests.cpp index b8dd570d480..5b073d52a2f 100644 --- a/test/unittest/rtps/network/NetworkFactoryTests.cpp +++ b/test/unittest/rtps/network/NetworkFactoryTests.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include using namespace eprosima::fastdds; using namespace eprosima::fastdds::rtps; diff --git a/test/unittest/rtps/network/mock/MockTransport.cpp b/test/unittest/rtps/network/mock/MockTransport.cpp index 4bcb4cc94f1..8867715e617 100644 --- a/test/unittest/rtps/network/mock/MockTransport.cpp +++ b/test/unittest/rtps/network/mock/MockTransport.cpp @@ -73,6 +73,12 @@ bool MockTransport::is_locator_allowed( return true; } +bool MockTransport::is_locator_reachable( + const Locator_t& /*locator*/) +{ + return true; +} + bool MockTransport::OpenOutputChannel( fastdds::rtps::SendResourceList& send_resource_list, const Locator_t& locator) diff --git a/test/unittest/rtps/network/mock/MockTransport.h b/test/unittest/rtps/network/mock/MockTransport.h index 2955afa8a1e..5dc6cf49f16 100644 --- a/test/unittest/rtps/network/mock/MockTransport.h +++ b/test/unittest/rtps/network/mock/MockTransport.h @@ -86,8 +86,13 @@ class MockTransport : public fastdds::rtps::TransportInterface bool IsLocatorSupported( const Locator_t&) const override; + bool is_locator_allowed( const Locator_t& locator) const override; + + bool is_locator_reachable( + const Locator_t&) override; + bool DoInputLocatorsMatch( const Locator_t&, const Locator_t&) const override; diff --git a/test/unittest/transport/TCPv6Tests.cpp b/test/unittest/transport/TCPv6Tests.cpp index f87aed21774..11e8faf1696 100644 --- a/test/unittest/transport/TCPv6Tests.cpp +++ b/test/unittest/transport/TCPv6Tests.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include