Skip to content

Commit

Permalink
Disable MDNS lookup on first message deliver failure be default (#22678)
Browse files Browse the repository at this point in the history
* Disable MDNS lookup on first message deliver failure

* Restyle

* Reorder config entry

* Address PR comments and clean up config comment

* Address PR comments
  • Loading branch information
tehampson authored and pull[bot] committed Nov 16, 2022
1 parent 895cfe7 commit 2411164
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/messaging/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import("//build_overrides/chip.gni")
declare_args() {
# Allows to change time between retries during the case session
chip_case_retry_delta = ""

chip_config_resolve_peer_on_first_transmit_failure = ""
}

defines = []
Expand All @@ -26,6 +28,10 @@ if (chip_case_retry_delta != "") {
[ "CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL=${chip_case_retry_delta}" ]
}

if (chip_config_resolve_peer_on_first_transmit_failure != "") {
defines += [ "CHIP_CONFIG_RESOLVE_PEER_ON_FIRST_TRANSMIT_FAILURE=${chip_config_resolve_peer_on_first_transmit_failure}" ]
}

source_set("messaging_mrp_config") {
sources = [ "ReliableMessageProtocolConfig.h" ]

Expand Down
2 changes: 2 additions & 0 deletions src/messaging/ReliableMessageMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ CHIP_ERROR ReliableMessageMgr::SendFromRetransTable(RetransTableEntry * entry)

if (err == CHIP_NO_ERROR)
{
#if CHIP_CONFIG_RESOLVE_PEER_ON_FIRST_TRANSMIT_FAILURE
const ExchangeManager * exchangeMgr = entry->ec->GetExchangeMgr();
// TODO: investigate why in ReliableMessageMgr::CheckResendApplicationMessageWithPeerExchange unit test released exchange
// context with mExchangeMgr==nullptr is used.
Expand All @@ -329,6 +330,7 @@ CHIP_ERROR ReliableMessageMgr::SendFromRetransTable(RetransTableEntry * entry)
mSessionUpdateDelegate->UpdatePeerAddress(entry->ec->GetSessionHandle()->GetPeer());
}
}
#endif // CHIP_CONFIG_RESOLVE_PEER_ON_FIRST_TRANSMIT_FAILURE
}
else
{
Expand Down
20 changes: 20 additions & 0 deletions src/messaging/ReliableMessageProtocolConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@ namespace chip {
#define CHIP_CONFIG_RMP_DEFAULT_ACK_TIMEOUT (200_ms32)
#endif // CHIP_CONFIG_RMP_DEFAULT_ACK_TIMEOUT

/**
* @def CHIP_CONFIG_RESOLVE_PEER_ON_FIRST_TRANSMIT_FAILURE
*
* @brief
* Should an address lookup of the peer happen on every first message that fails
* to send on the link.
*
* The default value to not perform lookup was selected because most implementations
* of address lookup are not cache the and a request is sent on the link. Failing
* to deliver the first message is far more likely to happen due to lossy link
* than an actual address change where the peer did not reset. In the lossy link
* situation, doing further DNS resolutions on a degraded link can exacerbate that
* problem greatly. Additionally, every message that arrives from a peer updates the
* address. If the peer has fallen off the link due to any other reason, a re-resolve
* may not achieve an address that is reachable, even if a resolve response occurs.
*/
#ifndef CHIP_CONFIG_RESOLVE_PEER_ON_FIRST_TRANSMIT_FAILURE
#define CHIP_CONFIG_RESOLVE_PEER_ON_FIRST_TRANSMIT_FAILURE 0
#endif // CHIP_CONFIG_RESOLVE_PEER_ON_FIRST_TRANSMIT_FAILURE

/**
* @def CHIP_CONFIG_RMP_RETRANS_TABLE_SIZE
*
Expand Down

0 comments on commit 2411164

Please sign in to comment.