Skip to content

Commit

Permalink
Remove built-in dnssd cache (#17114)
Browse files Browse the repository at this point in the history
Existing is already set to 0 across all platforms.

Implementation was only ever supported by the PlatformDnssd
implementation, which generally have their own cache (like avahi or
bonjour).
  • Loading branch information
andy31415 authored and pull[bot] committed Sep 22, 2023
1 parent 79ea3ca commit c41924e
Show file tree
Hide file tree
Showing 24 changed files with 4 additions and 436 deletions.
40 changes: 3 additions & 37 deletions src/app/CASESessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,42 +33,22 @@ CHIP_ERROR CASESessionManager::FindOrEstablishSession(PeerId peerId, Callback::C
{
Dnssd::ResolvedNodeData resolutionData;

bool nodeIDWasResolved =
#if CHIP_CONFIG_MDNS_CACHE_SIZE > 0
(mConfig.dnsCache != nullptr && mConfig.dnsCache->Lookup(peerId, resolutionData) == CHIP_NO_ERROR);
#else
false;
#endif

ChipLogDetail(CASESessionManager,
"FindOrEstablishSession: PeerId = " ChipLogFormatX64 ":" ChipLogFormatX64 ", NodeIdWasResolved = %d",
ChipLogValueX64(peerId.GetCompressedFabricId()), ChipLogValueX64(peerId.GetNodeId()), nodeIDWasResolved);
ChipLogDetail(CASESessionManager, "FindOrEstablishSession: PeerId = " ChipLogFormatX64 ":" ChipLogFormatX64,
ChipLogValueX64(peerId.GetCompressedFabricId()), ChipLogValueX64(peerId.GetNodeId()));

OperationalDeviceProxy * session = FindExistingSession(peerId);
if (session == nullptr)
{
ChipLogDetail(CASESessionManager, "FindOrEstablishSession: No existing session found");

// TODO - Implement LRU to evict least recently used session to handle mActiveSessions pool exhaustion
if (nodeIDWasResolved)
{
session = mConfig.devicePool->Allocate(mConfig.sessionInitParams, peerId, resolutionData);
}
else
{
session = mConfig.devicePool->Allocate(mConfig.sessionInitParams, peerId);
}
session = mConfig.devicePool->Allocate(mConfig.sessionInitParams, peerId);

if (session == nullptr)
{
onFailure->mCall(onFailure->mContext, peerId, CHIP_ERROR_NO_MEMORY);
return CHIP_ERROR_NO_MEMORY;
}
}
else if (nodeIDWasResolved)
{
session->OnNodeIdResolved(resolutionData);
}

CHIP_ERROR err = session->Connect(onConnection, onFailure);
if (err != CHIP_NO_ERROR)
Expand Down Expand Up @@ -97,20 +77,6 @@ void CASESessionManager::ReleaseAllSessions()

CHIP_ERROR CASESessionManager::GetPeerAddress(PeerId peerId, Transport::PeerAddress & addr)
{
#if CHIP_CONFIG_MDNS_CACHE_SIZE > 0
if (mConfig.dnsCache != nullptr)
{
Dnssd::ResolvedNodeData resolutionData;
// TODO(andy31415): DNS caching is generally not populated, need to move
// caching into a the address resolve layer and not have a global one anymore.
if (mConfig.dnsCache->Lookup(peerId, resolutionData) == CHIP_NO_ERROR)
{
addr = OperationalDeviceProxy::ToPeerAddress(resolutionData);
return CHIP_NO_ERROR;
}
}
#endif

OperationalDeviceProxy * session = FindExistingSession(peerId);
VerifyOrReturnError(session != nullptr, CHIP_ERROR_NOT_CONNECTED);
addr = session->GetPeerAddress();
Expand Down
4 changes: 0 additions & 4 deletions src/app/CASESessionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <app/OperationalDeviceProxyPool.h>
#include <lib/core/CHIPConfig.h>
#include <lib/core/CHIPCore.h>
#include <lib/dnssd/DnssdCache.h>
#include <lib/support/Pool.h>
#include <platform/CHIPDeviceLayer.h>
#include <transport/SessionDelegate.h>
Expand All @@ -35,9 +34,6 @@ namespace chip {
struct CASESessionManagerConfig
{
DeviceProxyInitParams sessionInitParams;
#if CHIP_CONFIG_MDNS_CACHE_SIZE > 0
Dnssd::DnssdCache<CHIP_CONFIG_MDNS_CACHE_SIZE> * dnsCache = nullptr;
#endif
OperationalDeviceProxyPoolDelegate * devicePool = nullptr;
};

Expand Down
3 changes: 0 additions & 3 deletions src/app/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,6 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
.clientPool = &mCASEClientPool,
.groupDataProvider = mGroupsProvider,
},
#if CHIP_CONFIG_MDNS_CACHE_SIZE > 0
.dnsCache = nullptr,
#endif
.devicePool = &mDevicePool,
};

Expand Down
5 changes: 1 addition & 4 deletions src/controller/CHIPDeviceControllerFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,7 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params)

CASESessionManagerConfig sessionManagerConfig = {
.sessionInitParams = deviceInitParams,
#if CHIP_CONFIG_MDNS_CACHE_SIZE > 0
.dnsCache = NoSuchThingWeWouldNeedToAddIt,
#endif
.devicePool = stateParams.operationalDevicePool,
.devicePool = stateParams.operationalDevicePool,
};

// TODO: Need to be able to create a CASESessionManagerConfig here!
Expand Down
12 changes: 0 additions & 12 deletions src/lib/core/CHIPConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -1320,18 +1320,6 @@ extern const char CHIP_NON_PRODUCTION_MARKER[];
#define CHIP_COMMISSIONING_HINT_INDEX_PRESS_RESET_UNTIL_BLINK_WITH_POWER 11
#endif

/**
* @def CHIP_CONFIG_MDNS_CACHE_SIZE
*
* @brief
* Define the size of the MDNS cache
*
* If CHIP_CONFIG_MDNS_CACHE_SIZE is 0, the builtin cache is not used.
*
*/
#ifndef CHIP_CONFIG_MDNS_CACHE_SIZE
#define CHIP_CONFIG_MDNS_CACHE_SIZE 0
#endif
/**
* @name Interaction Model object pool configuration.
*
Expand Down
1 change: 0 additions & 1 deletion src/lib/dnssd/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ static_library("dnssd") {

sources = [
"Advertiser.h",
"DnssdCache.h",
"Resolver.h",
"ServiceNaming.cpp",
"ServiceNaming.h",
Expand Down
1 change: 0 additions & 1 deletion src/lib/dnssd/Discovery_ImplPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <crypto/RandUtils.h>
#include <lib/core/CHIPConfig.h>
#include <lib/core/CHIPSafeCasts.h>
#include <lib/dnssd/DnssdCache.h>
#include <lib/dnssd/ServiceNaming.h>
#include <lib/dnssd/TxtFields.h>
#include <lib/dnssd/platform/Dnssd.h>
Expand Down
1 change: 0 additions & 1 deletion src/lib/dnssd/Discovery_ImplPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <lib/core/CHIPConfig.h>
#include <lib/core/CHIPError.h>
#include <lib/dnssd/Advertiser.h>
#include <lib/dnssd/DnssdCache.h>
#include <lib/dnssd/Resolver.h>
#include <lib/dnssd/ResolverProxy.h>
#include <lib/dnssd/platform/Dnssd.h>
Expand Down
187 changes: 0 additions & 187 deletions src/lib/dnssd/DnssdCache.h

This file was deleted.

3 changes: 0 additions & 3 deletions src/lib/dnssd/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ chip_test_suite("tests") {
"TestTxtFields.cpp",
]

if (chip_device_platform != "efr32") {
test_sources += [ "TestDnssdCache.cpp" ]
}
if (chip_mdns == "minimal") {
test_sources += [ "TestActiveResolveAttempts.cpp" ]
}
Expand Down
Loading

0 comments on commit c41924e

Please sign in to comment.