Remove PDR's based on Terminus Handle
The current pldm infrastructure is written in way that
it deletes all the PDR's which are marked as "remote",when
we get a PDR refresh entire repository signal comes from remote
PLDM terminus,this does not work in muti-host scenario where BMC
talks to more than one HOST that talks pldm.
When a repository refresh signal comes form a remote PLDM terminus,
BMC is supposed to only delete the PDR's corresponding to the same
PLDM terminus.
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: I51f77c3f9537da722a00d97070674958c5baf1b4
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index 707c9ff..fe825d7 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -471,8 +471,8 @@
int Handler::pldmPDRRepositoryChgEvent(const pldm_msg* request,
size_t payloadLength,
- uint8_t /*formatVersion*/,
- uint8_t /*tid*/, size_t eventDataOffset)
+ uint8_t /*formatVersion*/, uint8_t tid,
+ size_t eventDataOffset)
{
uint8_t eventDataFormat{};
uint8_t numberOfChangeRecords{};
@@ -544,6 +544,24 @@
}
if (hostPDRHandler)
{
+ // if we get a Repository change event with the eventDataFormat
+ // as REFRESH_ENTIRE_REPOSITORY, then delete all the PDR's that
+ // have the matched Terminus handle
+ if (eventDataFormat == REFRESH_ENTIRE_REPOSITORY)
+ {
+ // We cannot get the Repo change event from the Terminus
+ // that is not already added to the BMC repository
+
+ for (const auto& [terminusHandle, terminusInfo] :
+ hostPDRHandler->tlPDRInfo)
+ {
+ if (std::get<0>(terminusInfo) == tid)
+ {
+ pldm_pdr_remove_pdrs_by_terminus_handle(pdrRepo.getPdr(),
+ terminusHandle);
+ }
+ }
+ }
hostPDRHandler->fetchPDR(std::move(pdrRecordHandles));
}