Skip to content
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

Bugfix/asymetric whitelist eprosima integration #3819

Merged
Merged
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
36 changes: 36 additions & 0 deletions include/fastdds/dds/core/policy/ParameterTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ enum ParameterId_t : uint16_t
PID_RELATED_SAMPLE_IDENTITY = 0x800f,
PID_DISABLE_POSITIVE_ACKS = 0x8005,
PID_DATASHARING = 0x8006,
PID_NETWORK_CONFIGURATION_SET = 0x8007,
};

/*!
Expand Down Expand Up @@ -880,6 +881,41 @@ class ParameterBuiltinEndpointSet_t : public Parameter_t

#define PARAMETER_BUILTINENDPOINTSET_LENGTH 4

/**
* @ingroup PARAMETER_MODULE
*/
class ParameterNetworkConfigSet_t : public Parameter_t
{
public:

//!Network Config Set <br> By default, 0.
fastrtps::rtps::NetworkConfigSet_t netconfigSet;

/**
* @brief Constructor without parameters
*/
ParameterNetworkConfigSet_t()
: netconfigSet(0)
{
}

/**
* Constructor using a parameter PID and the parameter length
*
* @param pid Pid of the parameter
* @param in_length Its associated length
*/
ParameterNetworkConfigSet_t(
ParameterId_t pid,
uint16_t in_length)
: Parameter_t(pid, in_length)
, netconfigSet(0)
{
}

};

#define PARAMETER_NETWORKCONFIGSET_LENGTH 4

/**
* @ingroup PARAMETER_MODULE
Expand Down
5 changes: 5 additions & 0 deletions include/fastdds/rtps/attributes/RTPSParticipantAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <fastdds/rtps/common/Locator.h>
#include <fastdds/rtps/common/PortParameters.h>
#include <fastdds/rtps/common/Time_t.h>
#include <fastdds/rtps/common/Types.h>
#include <fastdds/rtps/flowcontrol/FlowControllerDescriptor.hpp>
#include <fastdds/rtps/flowcontrol/ThroughputControllerDescriptor.h>
#include <fastdds/rtps/resources/ResourceManagement.h>
Expand Down Expand Up @@ -381,6 +382,9 @@ class BuiltinAttributes
//! TypeLookup Service settings
TypeLookupSettings typelookup_config;

//! Network Configuration
NetworkConfigSet_t network_configuration;

//! Metatraffic Unicast Locator List
LocatorList_t metatrafficUnicastLocatorList;

Expand Down Expand Up @@ -424,6 +428,7 @@ class BuiltinAttributes
(this->use_WriterLivelinessProtocol == b.use_WriterLivelinessProtocol) &&
(typelookup_config.use_client == b.typelookup_config.use_client) &&
(typelookup_config.use_server == b.typelookup_config.use_server) &&
(this->network_configuration == b.network_configuration) &&
(this->metatrafficUnicastLocatorList == b.metatrafficUnicastLocatorList) &&
(this->metatrafficMulticastLocatorList == b.metatrafficMulticastLocatorList) &&
(this->metatraffic_external_unicast_locators == b.metatraffic_external_unicast_locators) &&
Expand Down
7 changes: 3 additions & 4 deletions include/fastdds/rtps/builtin/BuiltinProtocols.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,10 @@ class BuiltinProtocols
LocatorList_t& loclist);

/**
* Traverses the list of discover servers translating from remote to local locators
* if possible
* @param nf NetworkFactory used to make the translation
* Traverses the list of discover servers filtering out unsupported or not allowed remote locators
* @param nf NetworkFactory used to make the filtering
*/
void transform_server_remote_locators(
void filter_server_remote_locators(
NetworkFactory& nf);

//!BuiltinAttributes of the builtin protocols.
Expand Down
24 changes: 24 additions & 0 deletions include/fastdds/rtps/builtin/data/NetworkConfiguration.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2023 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.

/**
* @file NetworkConfiguration.hpp
*/

#ifndef FASTDDS_RTPS_BUILTIN_DATA__NETWORKCONFIGURATION_HPP
#define FASTDDS_RTPS_BUILTIN_DATA__NETWORKCONFIGURATION_HPP

#define DISC_NETWORK_CONFIGURATION_LISTENING_LOCALHOST_ALL (0x0000000F)

#endif // FASTDDS_RTPS_BUILTIN_DATA__NETWORKCONFIGURATION_HPP
2 changes: 2 additions & 0 deletions include/fastdds/rtps/builtin/data/ParticipantProxyData.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class ParticipantProxyData
bool m_expectsInlineQos;
//!Available builtin endpoints
BuiltinEndpointSet_t m_availableBuiltinEndpoints;
//!Network configuration
NetworkConfigSet_t m_networkConfiguration;
//!Metatraffic locators
RemoteLocatorList metatraffic_locators;
//!Default locators
Expand Down
24 changes: 24 additions & 0 deletions include/fastdds/rtps/builtin/data/ReaderProxyData.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,28 @@ class ReaderProxyData
return m_guid;
}

RTPS_DllAPI void networkConfiguration(
const NetworkConfigSet_t& networkConfiguration)
{
m_networkConfiguration = networkConfiguration;
}

RTPS_DllAPI void networkConfiguration(
NetworkConfigSet_t&& networkConfiguration)
{
m_networkConfiguration = std::move(networkConfiguration);
}

RTPS_DllAPI const NetworkConfigSet_t& networkConfiguration() const
{
return m_networkConfiguration;
}

RTPS_DllAPI NetworkConfigSet_t& networkConfiguration()
{
return m_networkConfiguration;
}

RTPS_DllAPI bool has_locators() const
{
return !remote_locators_.unicast.empty() || !remote_locators_.multicast.empty();
Expand Down Expand Up @@ -459,6 +481,8 @@ class ReaderProxyData

//!GUID
GUID_t m_guid;
//!Network configuration
NetworkConfigSet_t m_networkConfiguration;
//!Holds locator information
RemoteLocatorList remote_locators_;
//!GUID_t of the Reader converted to InstanceHandle_t
Expand Down
25 changes: 25 additions & 0 deletions include/fastdds/rtps/builtin/data/WriterProxyData.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,28 @@ class WriterProxyData
return m_guid;
}

RTPS_DllAPI void networkConfiguration(
const NetworkConfigSet_t& networkConfiguration)
{
m_networkConfiguration = networkConfiguration;
}

RTPS_DllAPI void networkConfiguration(
NetworkConfigSet_t&& networkConfiguration)
{
m_networkConfiguration = std::move(networkConfiguration);
}

RTPS_DllAPI const NetworkConfigSet_t& networkConfiguration() const
{
return m_networkConfiguration;
}

RTPS_DllAPI NetworkConfigSet_t& networkConfiguration()
{
return m_networkConfiguration;
}

RTPS_DllAPI void persistence_guid(
const GUID_t& guid)
{
Expand Down Expand Up @@ -440,6 +462,9 @@ class WriterProxyData
//!GUID
GUID_t m_guid;

//!Network configuration
NetworkConfigSet_t m_networkConfiguration;

//!Holds locator information
RemoteLocatorList remote_locators_;

Expand Down
1 change: 1 addition & 0 deletions include/fastdds/rtps/common/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ using octet = unsigned char;
//typedef unsigned short ushort;
using SubmessageFlag = unsigned char;
using BuiltinEndpointSet_t = uint32_t;
using NetworkConfigSet_t = uint32_t;
using Count_t = uint32_t;

#define BIT0 0x01u
Expand Down
31 changes: 29 additions & 2 deletions include/fastdds/rtps/network/NetworkFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,30 @@ class NetworkFactory
* Transform a remote locator into a locator optimized for local communications.
*
* If the remote locator corresponds to one of the local interfaces, it is converted
* to the corresponding local address.
* to the corresponding local address if allowed by both local and remote transports.
*
* @param [in] remote_locator Locator to be converted.
* @param [out] result_locator Converted locator.
* @param [in] remote_network_config Remote network configuration.
*
* @return false if the input locator is not supported/allowed by any of the registered transports,
* true otherwise.
*/
bool transform_remote_locator(
const Locator_t& remote_locator,
Locator_t& result_locator) const;
Locator_t& result_locator,
const NetworkConfigSet_t& remote_network_config) const;

/**
* Must report whether the given locator is allowed by at least one of the registered transports.
*
* @param [in] locator Locator to check if allowed.
*
* @return false if the input locator is not supported/allowed by any of the registered transports,
* true otherwise.
*/
bool is_locator_allowed(
const Locator_t& locator) const;

/**
* Perform the locator selection algorithm.
Expand Down Expand Up @@ -136,6 +149,11 @@ class NetworkFactory
return minSendBufferSize_;
}

NetworkConfigSet_t network_configuration() const
{
return network_configuration_;
}

/**
* Fill ret_locators with the list of all possible locators in the local machine at the given
* physical_port of the locator_kind.
Expand Down Expand Up @@ -223,6 +241,15 @@ class NetworkFactory

uint32_t minSendBufferSize_;

// Whether unicast metatraffic on SHM transport should always be used
bool enforce_shm_unicast_metatraffic_ = false;

// Whether multicast metatraffic on SHM transport should always be used
bool enforce_shm_multicast_metatraffic_ = false;

// Mask using transport kinds to indicate whether the transports allows localhost
NetworkConfigSet_t network_configuration_;

/**
* Calculate well-known ports.
*/
Expand Down
32 changes: 27 additions & 5 deletions include/fastdds/rtps/transport/ChainingTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,12 @@ class ChainingTransport : public TransportInterface
}

/*!
* Call the low-level transport `is_locator_allowed()`.
* Must report whether the given locator is allowed by this transport.
* Call the low-level transport `is_localhost_allowed()`.
* Must report whether localhost locator is allowed
*/
RTPS_DllAPI bool is_locator_allowed(
const fastrtps::rtps::Locator_t& locator) const override
RTPS_DllAPI bool is_localhost_allowed() const override
{
return low_level_transport_->is_locator_allowed(locator);
return low_level_transport_->is_localhost_allowed();
}

/*!
Expand Down Expand Up @@ -351,6 +350,29 @@ class ChainingTransport : public TransportInterface
low_level_transport_->update_network_interfaces();
}

//! Call the low-level transport `transform_remote_locator()`.
//! Transforms a remote locator into a locator optimized for local communications,
//! if allowed by both local and remote transports.
RTPS_DllAPI bool transform_remote_locator(
const fastrtps::rtps::Locator_t& remote_locator,
fastrtps::rtps::Locator_t& result_locator,
bool allowed_remote_localhost,
bool allowed_local_localhost) const override
{
return low_level_transport_->transform_remote_locator(remote_locator, result_locator, allowed_remote_localhost,
allowed_local_localhost);
}

/*!
* Call the low-level transport `is_locator_allowed()`.
* Must report whether the given locator is allowed by this transport.
*/
RTPS_DllAPI bool is_locator_allowed(
const fastrtps::rtps::Locator_t& locator) const override
{
return low_level_transport_->is_locator_allowed(locator);
}

protected:

std::unique_ptr<TransportInterface> low_level_transport_;
Expand Down
32 changes: 31 additions & 1 deletion include/fastdds/rtps/transport/TransportInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include <fastdds/rtps/common/Locator.h>
#include <fastdds/rtps/common/LocatorSelector.hpp>
#include <fastdds/rtps/common/PortParameters.h>
#include <fastdds/rtps/network/SenderResource.h>
#include <fastdds/rtps/transport/TransportDescriptorInterface.h>
#include <fastdds/rtps/transport/TransportReceiverInterface.h>
#include <fastdds/rtps/network/SenderResource.h>
#include <fastdds/rtps/attributes/PropertyPolicy.h>

namespace eprosima {
Expand Down Expand Up @@ -245,6 +245,36 @@ class RTPS_DllAPI TransportInterface
return transport_kind_;
}

/**
* Transforms a remote locator into a locator optimized for local communications.
*
* If the remote locator corresponds to one of the local interfaces, it is converted
* to the corresponding local address if allowed by both local and remote transports.
*
* @param [in] remote_locator Locator to be converted.
* @param [out] result_locator Converted locator.
* @param [in] allowed_remote_localhost Whether localhost is allowed (and hence used) in the remote transport.
* @param [in] allowed_local_localhost Whether localhost is allowed locally (by this or other transport).
*
* @return false if the input locator is not supported/allowed by this transport, true otherwise.
*/
virtual bool transform_remote_locator(
const Locator& remote_locator,
Locator& result_locator,
bool allowed_remote_localhost,
bool allowed_local_localhost) const
{
static_cast<void>(allowed_remote_localhost);
static_cast<void>(allowed_local_localhost);
return transform_remote_locator(remote_locator, result_locator);
}

//! Must report whether localhost locator is allowed
virtual bool is_localhost_allowed() const
{
return true;
}

protected:

TransportInterface(
Expand Down
7 changes: 4 additions & 3 deletions include/fastrtps/qos/ParameterTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#if HAVE_SECURITY
#include <fastdds/rtps/security/accesscontrol/ParticipantSecurityAttributes.h>
#include <fastdds/rtps/security/accesscontrol/EndpointSecurityAttributes.h>
#endif
#endif // if HAVE_SECURITY

#include <string>
#include <vector>
Expand All @@ -54,16 +54,17 @@ using ParameterCount_t = fastdds::dds::ParameterCount_t;
using ParameterEntityId_t = fastdds::dds::ParameterEntityId_t;
using ParameterTime_t = fastdds::dds::ParameterTime_t;
using ParameterBuiltinEndpointSet_t = fastdds::dds::ParameterBuiltinEndpointSet_t;
using ParameterNetworkConfigSet_t = fastdds::dds::ParameterNetworkConfigSet_t;
using ParameterPropertyList_t = fastdds::dds::ParameterPropertyList_t;
using ParameterSampleIdentity_t = fastdds::dds::ParameterSampleIdentity_t;
#if HAVE_SECURITY
using ParameterToken_t = fastdds::dds::ParameterToken_t;
using ParameterParticipantSecurityInfo_t = fastdds::dds::ParameterParticipantSecurityInfo_t;
using ParameterEndpointSecurityInfo_t = fastdds::dds::ParameterEndpointSecurityInfo_t;
#endif
#endif // if HAVE_SECURITY

} //end of namespace
} //end of namespace eprosima

#endif
#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
#endif /* PARAMETERTYPES_H_ */
Loading
Loading