Skip to content

Commit

Permalink
Internal refactor on port handling (#3440)
Browse files Browse the repository at this point in the history
* Refs #18002. Avoid mutation of multicast ports.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #18002. Move security initalization up.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #18002. Prepare for refactor of locators setup.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #18002. Refactor metatraffic related code.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #18002. Refactor initial peers related code.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #18002. Refactor user traffic related code.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #18002. Refactor output traffic related code.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #18002. Safe metatraffic unicast port on a new attribute.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #18002. User unicast port calculated on participant instead of NetworkFactory.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #18002. Update metatraffic_unicast_port_ inside applyLocatorAdaptRule.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Apply suggestion

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #18002. Always create unicast receiver resources first.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #18002. Improve warning message.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #18002. Refactor createReceiverResources

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #18002. Improve SHM.SamePortUnicastMulticast blackbox test

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
(cherry picked from commit ea5af48)
  • Loading branch information
MiguelCompany committed May 14, 2024
1 parent 57ddaf4 commit 5b6bc33
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 128 deletions.
11 changes: 4 additions & 7 deletions src/cpp/rtps/network/NetworkFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,30 +402,27 @@ bool NetworkFactory::configureInitialPeerLocator(
}

bool NetworkFactory::getDefaultUnicastLocators(
uint32_t domain_id,
LocatorList_t& locators,
const RTPSParticipantAttributes& m_att) const
uint32_t port) const
{
bool result = false;
for (auto& transport : mRegisteredTransports)
{
result |= transport->getDefaultUnicastLocators(locators, calculate_well_known_port(domain_id, m_att, false));
result |= transport->getDefaultUnicastLocators(locators, port);
}
return result;
}

bool NetworkFactory::fill_default_locator_port(
uint32_t domain_id,
Locator_t& locator,
const RTPSParticipantAttributes& m_att,
bool is_multicast) const
uint32_t port) const
{
bool result = false;
for (auto& transport : mRegisteredTransports)
{
if (transport->IsLocatorSupported(locator))
{
result |= transport->fillUnicastLocator(locator, calculate_well_known_port(domain_id, m_att, is_multicast));
result |= transport->fillUnicastLocator(locator, port);
}
}
return result;
Expand Down
23 changes: 10 additions & 13 deletions src/cpp/rtps/network/NetworkFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,15 @@ class NetworkFactory
* Add locators to the default unicast configuration.
* */
bool getDefaultUnicastLocators(
uint32_t domain_id,
LocatorList_t& locators,
const RTPSParticipantAttributes& m_att) const;
uint32_t port) const;

/**
* Fill the locator with the default unicast configuration.
* */
bool fill_default_locator_port(
uint32_t domain_id,
Locator_t& locator,
const RTPSParticipantAttributes& m_att,
bool is_multicast) const;
uint32_t port) const;

/**
* Shutdown method to close the connections of the transports.
Expand All @@ -259,6 +256,14 @@ class NetworkFactory
const LocatorList_t& remote_participant_locators,
const LocatorList_t& participant_initial_peers) const;

/**
* Calculate well-known ports.
*/
uint16_t calculate_well_known_port(
uint32_t domain_id,
const RTPSParticipantAttributes& att,
bool is_multicast) const;

private:

std::vector<std::unique_ptr<fastdds::rtps::TransportInterface>> mRegisteredTransports;
Expand All @@ -275,14 +280,6 @@ class NetworkFactory

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

/**
* Calculate well-known ports.
*/
uint16_t calculate_well_known_port(
uint32_t domain_id,
const RTPSParticipantAttributes& att,
bool is_multicast) const;
};

} // namespace rtps
Expand Down
Loading

0 comments on commit 5b6bc33

Please sign in to comment.