blob: 00527ee27f4af6fe755b3fba416608c81bcdf740 [file] [log] [blame]
Gilbert Chen44524a52022-02-14 12:12:25 +00001#include "config.h"
2
Tom Josephfb3bc062021-08-17 07:48:11 -07003#include "mctp_endpoint_discovery.hpp"
4
Tom Josephfb3bc062021-08-17 07:48:11 -07005#include "common/types.hpp"
6#include "common/utils.hpp"
7
Thu Nguyen90274972024-07-17 07:02:16 +00008#include <linux/mctp.h>
9
Gilbert Chen44524a52022-02-14 12:12:25 +000010#include <phosphor-logging/lg2.hpp>
11
Tom Josephfb3bc062021-08-17 07:48:11 -070012#include <algorithm>
Gilbert Chen44524a52022-02-14 12:12:25 +000013#include <fstream>
14#include <iostream>
Tom Josephfb3bc062021-08-17 07:48:11 -070015#include <map>
16#include <string>
17#include <string_view>
18#include <vector>
19
Gilbert Chen44524a52022-02-14 12:12:25 +000020using namespace sdbusplus::bus::match::rules;
21
22PHOSPHOR_LOG2_USING;
23
Tom Josephfb3bc062021-08-17 07:48:11 -070024namespace pldm
25{
Gilbert Chen44524a52022-02-14 12:12:25 +000026MctpDiscovery::MctpDiscovery(
Patrick Williamsba741d52024-05-08 02:32:10 -050027 sdbusplus::bus_t& bus,
Gilbert Chen44524a52022-02-14 12:12:25 +000028 std::initializer_list<MctpDiscoveryHandlerIntf*> list) :
Eric Yang70eca962025-05-11 01:48:15 +080029 bus(bus),
30 mctpEndpointAddedSignal(
31 bus, interfacesAdded(MCTPPath),
32 [this](sdbusplus::message_t& msg) { this->discoverEndpoints(msg); }),
Gilbert Chen44524a52022-02-14 12:12:25 +000033 mctpEndpointRemovedSignal(
34 bus, interfacesRemoved(MCTPPath),
Eric Yang70eca962025-05-11 01:48:15 +080035 [this](sdbusplus::message_t& msg) { this->removeEndpoints(msg); }),
Chau Ly75e00422024-03-19 12:33:08 +000036 mctpEndpointPropChangedSignal(
37 bus, propertiesChangedNamespace(MCTPPath, MCTPInterfaceCC),
Eric Yang70eca962025-05-11 01:48:15 +080038 [this](sdbusplus::message_t& msg) { this->propertiesChangedCb(msg); }),
Gilbert Chen44524a52022-02-14 12:12:25 +000039 handlers(list)
Tom Josephfb3bc062021-08-17 07:48:11 -070040{
Chau Ly75e00422024-03-19 12:33:08 +000041 std::map<MctpInfo, Availability> currentMctpInfoMap;
42 getMctpInfos(currentMctpInfoMap);
43 for (const auto& mapIt : currentMctpInfoMap)
44 {
45 if (mapIt.second)
46 {
47 // Only add the available endpoints to the terminus
48 // Let the propertiesChanged signal tells us when it comes back
49 // to Available again
50 addToExistingMctpInfos(MctpInfos(1, mapIt.first));
51 }
52 }
Gilbert Chen44524a52022-02-14 12:12:25 +000053 handleMctpEndpoints(existingMctpInfos);
54}
Tom Josephfb3bc062021-08-17 07:48:11 -070055
Chau Ly75e00422024-03-19 12:33:08 +000056void MctpDiscovery::getMctpInfos(std::map<MctpInfo, Availability>& mctpInfoMap)
Gilbert Chen44524a52022-02-14 12:12:25 +000057{
58 // Find all implementations of the MCTP Endpoint interface
59 pldm::utils::GetSubTreeResponse mapperResponse;
Tom Josephfb3bc062021-08-17 07:48:11 -070060 try
61 {
Gilbert Chen44524a52022-02-14 12:12:25 +000062 mapperResponse = pldm::utils::DBusHandler().getSubtree(
Alexander Hansen1f2794d2025-11-11 15:58:13 +010063 MCTPPath, 0, std::vector<std::string>({MCTPEndpoint::interface}));
Tom Josephfb3bc062021-08-17 07:48:11 -070064 }
Gilbert Chen44524a52022-02-14 12:12:25 +000065 catch (const sdbusplus::exception_t& e)
Tom Josephfb3bc062021-08-17 07:48:11 -070066 {
Riya Dixit087a7512024-04-06 14:28:08 -050067 error(
68 "Failed to getSubtree call at path '{PATH}' and interface '{INTERFACE}', error - {ERROR} ",
Alexander Hansen1f2794d2025-11-11 15:58:13 +010069 "ERROR", e, "PATH", MCTPPath, "INTERFACE", MCTPEndpoint::interface);
Tom Josephfb3bc062021-08-17 07:48:11 -070070 return;
71 }
72
Gilbert Chen44524a52022-02-14 12:12:25 +000073 for (const auto& [path, services] : mapperResponse)
Tom Josephfb3bc062021-08-17 07:48:11 -070074 {
Gilbert Chen44524a52022-02-14 12:12:25 +000075 for (const auto& serviceIter : services)
Tom Josephfb3bc062021-08-17 07:48:11 -070076 {
Gilbert Chen44524a52022-02-14 12:12:25 +000077 const std::string& service = serviceIter.first;
Thu Nguyen90274972024-07-17 07:02:16 +000078 const MctpEndpointProps& epProps =
79 getMctpEndpointProps(service, path);
80 const UUID& uuid = getEndpointUUIDProp(service, path);
Chau Ly75e00422024-03-19 12:33:08 +000081 const Availability& availability =
82 getEndpointConnectivityProp(path);
Thu Nguyen90274972024-07-17 07:02:16 +000083 auto types = std::get<MCTPMsgTypes>(epProps);
84 if (std::find(types.begin(), types.end(), mctpTypePLDM) !=
85 types.end())
Tom Josephfb3bc062021-08-17 07:48:11 -070086 {
Unive Tienc40d4a62025-03-12 11:36:07 +080087 auto mctpInfo =
88 MctpInfo(std::get<eid>(epProps), uuid, "",
89 std::get<NetworkId>(epProps), std::nullopt);
90 searchConfigurationFor(pldm::utils::DBusHandler(), mctpInfo);
91 mctpInfoMap[std::move(mctpInfo)] = availability;
Gilbert Chen44524a52022-02-14 12:12:25 +000092 }
Tom Josephfb3bc062021-08-17 07:48:11 -070093 }
94 }
Tom Josephfb3bc062021-08-17 07:48:11 -070095}
96
Thu Nguyen90274972024-07-17 07:02:16 +000097MctpEndpointProps MctpDiscovery::getMctpEndpointProps(
98 const std::string& service, const std::string& path)
99{
100 try
101 {
102 auto properties = pldm::utils::DBusHandler().getDbusPropertiesVariant(
Alexander Hansen1f2794d2025-11-11 15:58:13 +0100103 service.c_str(), path.c_str(), MCTPEndpoint::interface);
Thu Nguyen90274972024-07-17 07:02:16 +0000104
Alexander Hansen1f2794d2025-11-11 15:58:13 +0100105 if (properties.contains(MCTPEndpoint::property_names::network_id) &&
106 properties.contains(MCTPEndpoint::property_names::eid) &&
107 properties.contains(
108 MCTPEndpoint::property_names::supported_message_types))
Thu Nguyen90274972024-07-17 07:02:16 +0000109 {
Alexander Hansen1f2794d2025-11-11 15:58:13 +0100110 auto networkId = std::get<NetworkId>(
111 properties.at(MCTPEndpoint::property_names::network_id));
112 auto eid = std::get<mctp_eid_t>(
113 properties.at(MCTPEndpoint::property_names::eid));
114 auto types = std::get<std::vector<uint8_t>>(properties.at(
115 MCTPEndpoint::property_names::supported_message_types));
Thu Nguyen90274972024-07-17 07:02:16 +0000116 return MctpEndpointProps(networkId, eid, types);
117 }
118 }
119 catch (const sdbusplus::exception_t& e)
120 {
121 error(
122 "Error reading MCTP Endpoint property at path '{PATH}' and service '{SERVICE}', error - {ERROR}",
123 "SERVICE", service, "PATH", path, "ERROR", e);
124 return MctpEndpointProps(0, MCTP_ADDR_ANY, {});
125 }
126
127 return MctpEndpointProps(0, MCTP_ADDR_ANY, {});
128}
129
130UUID MctpDiscovery::getEndpointUUIDProp(const std::string& service,
131 const std::string& path)
132{
133 try
134 {
135 auto properties = pldm::utils::DBusHandler().getDbusPropertiesVariant(
Alexander Hansend20f0ac2025-11-26 14:16:01 +0100136 service.c_str(), path.c_str(), CommonUUID::interface);
Thu Nguyen90274972024-07-17 07:02:16 +0000137
138 if (properties.contains("UUID"))
139 {
140 return std::get<UUID>(properties.at("UUID"));
141 }
142 }
143 catch (const sdbusplus::exception_t& e)
144 {
145 error(
146 "Error reading Endpoint UUID property at path '{PATH}' and service '{SERVICE}', error - {ERROR}",
147 "SERVICE", service, "PATH", path, "ERROR", e);
148 return static_cast<UUID>(emptyUUID);
149 }
150
151 return static_cast<UUID>(emptyUUID);
152}
153
Chau Ly75e00422024-03-19 12:33:08 +0000154Availability MctpDiscovery::getEndpointConnectivityProp(const std::string& path)
155{
156 Availability available = false;
157 try
158 {
159 pldm::utils::PropertyValue propertyValue =
160 pldm::utils::DBusHandler().getDbusPropertyVariant(
161 path.c_str(), MCTPConnectivityProp, MCTPInterfaceCC);
162 if (std::get<std::string>(propertyValue) == "Available")
163 {
164 available = true;
165 }
166 }
167 catch (const sdbusplus::exception_t& e)
168 {
169 error(
170 "Error reading Endpoint Connectivity property at path '{PATH}', error - {ERROR}",
171 "PATH", path, "ERROR", e);
172 }
173
174 return available;
175}
176
Gilbert Chen44524a52022-02-14 12:12:25 +0000177void MctpDiscovery::getAddedMctpInfos(sdbusplus::message_t& msg,
178 MctpInfos& mctpInfos)
Tom Josephfb3bc062021-08-17 07:48:11 -0700179{
Gilbert Chen44524a52022-02-14 12:12:25 +0000180 using ObjectPath = sdbusplus::message::object_path;
181 ObjectPath objPath;
182 using Property = std::string;
183 using PropertyMap = std::map<Property, dbus::Value>;
184 std::map<std::string, PropertyMap> interfaces;
Thu Nguyen90274972024-07-17 07:02:16 +0000185 std::string uuid = emptyUUID;
Tom Josephfb3bc062021-08-17 07:48:11 -0700186
Gilbert Chen44524a52022-02-14 12:12:25 +0000187 try
188 {
189 msg.read(objPath, interfaces);
190 }
191 catch (const sdbusplus::exception_t& e)
192 {
Riya Dixit087a7512024-04-06 14:28:08 -0500193 error(
194 "Error reading MCTP Endpoint added interface message, error - {ERROR}",
195 "ERROR", e);
Gilbert Chen44524a52022-02-14 12:12:25 +0000196 return;
197 }
Chau Ly75e00422024-03-19 12:33:08 +0000198 const Availability& availability = getEndpointConnectivityProp(objPath.str);
Tom Josephfb3bc062021-08-17 07:48:11 -0700199
Thu Nguyen90274972024-07-17 07:02:16 +0000200 /* Get UUID */
201 try
202 {
203 auto service = pldm::utils::DBusHandler().getService(
Alexander Hansend20f0ac2025-11-26 14:16:01 +0100204 objPath.str.c_str(), CommonUUID::interface);
Thu Nguyen90274972024-07-17 07:02:16 +0000205 uuid = getEndpointUUIDProp(service, objPath.str);
206 }
207 catch (const sdbusplus::exception_t& e)
208 {
209 error("Error getting Endpoint UUID D-Bus interface, error - {ERROR}",
210 "ERROR", e);
211 }
212
Tom Josephfb3bc062021-08-17 07:48:11 -0700213 for (const auto& [intfName, properties] : interfaces)
214 {
Alexander Hansen1f2794d2025-11-11 15:58:13 +0100215 if (intfName == MCTPEndpoint::interface)
Tom Josephfb3bc062021-08-17 07:48:11 -0700216 {
Alexander Hansen1f2794d2025-11-11 15:58:13 +0100217 if (properties.contains(MCTPEndpoint::property_names::network_id) &&
218 properties.contains(MCTPEndpoint::property_names::eid) &&
219 properties.contains(
220 MCTPEndpoint::property_names::supported_message_types))
Tom Josephfb3bc062021-08-17 07:48:11 -0700221 {
Alexander Hansen1f2794d2025-11-11 15:58:13 +0100222 auto networkId = std::get<NetworkId>(
223 properties.at(MCTPEndpoint::property_names::network_id));
224 auto eid = std::get<mctp_eid_t>(
225 properties.at(MCTPEndpoint::property_names::eid));
226 auto types = std::get<std::vector<uint8_t>>(properties.at(
227 MCTPEndpoint::property_names::supported_message_types));
Chau Ly75e00422024-03-19 12:33:08 +0000228
229 if (!availability)
230 {
231 // Log an error message here, but still add it to the
232 // terminus
233 error(
234 "mctpd added a DEGRADED endpoint {EID} networkId {NET} to D-Bus",
235 "NET", networkId, "EID", static_cast<unsigned>(eid));
236 }
Tom Josephfb3bc062021-08-17 07:48:11 -0700237 if (std::find(types.begin(), types.end(), mctpTypePLDM) !=
238 types.end())
239 {
Riya Dixit087a7512024-04-06 14:28:08 -0500240 info(
Thu Nguyen90274972024-07-17 07:02:16 +0000241 "Adding Endpoint networkId '{NETWORK}' and EID '{EID}' UUID '{UUID}'",
242 "NETWORK", networkId, "EID", eid, "UUID", uuid);
Unive Tienc40d4a62025-03-12 11:36:07 +0800243 auto mctpInfo =
244 MctpInfo(eid, uuid, "", networkId, std::nullopt);
245 searchConfigurationFor(pldm::utils::DBusHandler(),
246 mctpInfo);
247 mctpInfos.emplace_back(std::move(mctpInfo));
Tom Josephfb3bc062021-08-17 07:48:11 -0700248 }
249 }
250 }
251 }
Gilbert Chen44524a52022-02-14 12:12:25 +0000252}
Tom Josephfb3bc062021-08-17 07:48:11 -0700253
Gilbert Chen44524a52022-02-14 12:12:25 +0000254void MctpDiscovery::addToExistingMctpInfos(const MctpInfos& addedInfos)
255{
256 for (const auto& mctpInfo : addedInfos)
Tom Josephfb3bc062021-08-17 07:48:11 -0700257 {
Gilbert Chen44524a52022-02-14 12:12:25 +0000258 if (std::find(existingMctpInfos.begin(), existingMctpInfos.end(),
259 mctpInfo) == existingMctpInfos.end())
260 {
261 existingMctpInfos.emplace_back(mctpInfo);
262 }
263 }
264}
265
266void MctpDiscovery::removeFromExistingMctpInfos(MctpInfos& mctpInfos,
267 MctpInfos& removedInfos)
268{
269 for (const auto& mctpInfo : existingMctpInfos)
270 {
271 if (std::find(mctpInfos.begin(), mctpInfos.end(), mctpInfo) ==
272 mctpInfos.end())
273 {
274 removedInfos.emplace_back(mctpInfo);
275 }
276 }
277 for (const auto& mctpInfo : removedInfos)
278 {
Riya Dixit087a7512024-04-06 14:28:08 -0500279 info("Removing Endpoint networkId '{NETWORK}' and EID '{EID}'",
Riya Dixit1e5c81e2024-05-03 07:54:00 -0500280 "NETWORK", std::get<3>(mctpInfo), "EID", std::get<0>(mctpInfo));
Gilbert Chen44524a52022-02-14 12:12:25 +0000281 existingMctpInfos.erase(std::remove(existingMctpInfos.begin(),
282 existingMctpInfos.end(), mctpInfo),
283 existingMctpInfos.end());
284 }
285}
286
Chau Ly75e00422024-03-19 12:33:08 +0000287void MctpDiscovery::propertiesChangedCb(sdbusplus::message_t& msg)
288{
289 using Interface = std::string;
290 using Property = std::string;
291 using Value = std::string;
292 using Properties = std::map<Property, std::variant<Value>>;
293
294 Interface interface;
295 Properties properties;
296 std::string objPath{};
297 std::string service{};
298
299 try
300 {
301 msg.read(interface, properties);
302 objPath = msg.get_path();
303 }
304 catch (const sdbusplus::exception_t& e)
305 {
306 error(
307 "Error handling Connectivity property changed message, error - {ERROR}",
308 "ERROR", e);
309 return;
310 }
311
312 for (const auto& [key, valueVariant] : properties)
313 {
314 Value propVal = std::get<std::string>(valueVariant);
315 auto availability = (propVal == "Available") ? true : false;
316
317 if (key == MCTPConnectivityProp)
318 {
Luka Strizicb249a642025-12-02 19:36:53 +0000319 try
320 {
321 service = pldm::utils::DBusHandler().getService(
322 objPath.c_str(), MCTPEndpoint::interface);
323 }
324 catch (const sdbusplus::exception_t& e)
325 {
326 error(
327 "Error getting service for path '{PATH}', error - {ERROR}",
328 "PATH", objPath, "ERROR", e);
329 return;
330 }
Chau Ly75e00422024-03-19 12:33:08 +0000331 const MctpEndpointProps& epProps =
332 getMctpEndpointProps(service, objPath);
333
334 auto types = std::get<MCTPMsgTypes>(epProps);
335 if (!std::ranges::contains(types, mctpTypePLDM))
336 {
337 return;
338 }
339 const UUID& uuid = getEndpointUUIDProp(service, objPath);
340
341 MctpInfo mctpInfo(std::get<eid>(epProps), uuid, "",
Unive Tienc40d4a62025-03-12 11:36:07 +0800342 std::get<NetworkId>(epProps), std::nullopt);
343 searchConfigurationFor(pldm::utils::DBusHandler(), mctpInfo);
Chau Ly75e00422024-03-19 12:33:08 +0000344 if (!std::ranges::contains(existingMctpInfos, mctpInfo))
345 {
346 if (availability)
347 {
348 // The endpoint not in existingMctpInfos and is
349 // available Add it to existingMctpInfos
350 info(
351 "Adding Endpoint networkId {NETWORK} ID {EID} by propertiesChanged signal",
352 "NETWORK", std::get<3>(mctpInfo), "EID",
353 unsigned(std::get<0>(mctpInfo)));
354 addToExistingMctpInfos(MctpInfos(1, mctpInfo));
355 handleMctpEndpoints(MctpInfos(1, mctpInfo));
356 }
357 }
358 else
359 {
360 // The endpoint already in existingMctpInfos
361 updateMctpEndpointAvailability(mctpInfo, availability);
362 }
363 }
364 }
365}
366
Gilbert Chen44524a52022-02-14 12:12:25 +0000367void MctpDiscovery::discoverEndpoints(sdbusplus::message_t& msg)
368{
369 MctpInfos addedInfos;
370 getAddedMctpInfos(msg, addedInfos);
371 addToExistingMctpInfos(addedInfos);
372 handleMctpEndpoints(addedInfos);
373}
374
375void MctpDiscovery::removeEndpoints(sdbusplus::message_t&)
376{
377 MctpInfos mctpInfos;
378 MctpInfos removedInfos;
Chau Ly75e00422024-03-19 12:33:08 +0000379 std::map<MctpInfo, Availability> currentMctpInfoMap;
380 getMctpInfos(currentMctpInfoMap);
381 for (const auto& mapIt : currentMctpInfoMap)
382 {
383 mctpInfos.push_back(mapIt.first);
384 }
Gilbert Chen44524a52022-02-14 12:12:25 +0000385 removeFromExistingMctpInfos(mctpInfos, removedInfos);
386 handleRemovedMctpEndpoints(removedInfos);
Unive Tienc40d4a62025-03-12 11:36:07 +0800387 removeConfigs(removedInfos);
Gilbert Chen44524a52022-02-14 12:12:25 +0000388}
389
390void MctpDiscovery::handleMctpEndpoints(const MctpInfos& mctpInfos)
391{
392 for (const auto& handler : handlers)
393 {
394 if (handler)
395 {
Unive Tienc40d4a62025-03-12 11:36:07 +0800396 handler->handleConfigurations(configurations);
Gilbert Chen44524a52022-02-14 12:12:25 +0000397 handler->handleMctpEndpoints(mctpInfos);
398 }
399 }
400}
401
402void MctpDiscovery::handleRemovedMctpEndpoints(const MctpInfos& mctpInfos)
403{
404 for (const auto& handler : handlers)
405 {
406 if (handler)
407 {
408 handler->handleRemovedMctpEndpoints(mctpInfos);
409 }
Tom Josephfb3bc062021-08-17 07:48:11 -0700410 }
411}
412
Chau Ly75e00422024-03-19 12:33:08 +0000413void MctpDiscovery::updateMctpEndpointAvailability(const MctpInfo& mctpInfo,
414 Availability availability)
415{
416 for (const auto& handler : handlers)
417 {
418 if (handler)
419 {
420 handler->updateMctpEndpointAvailability(mctpInfo, availability);
421 }
422 }
423}
424
Unive Tienc40d4a62025-03-12 11:36:07 +0800425std::string MctpDiscovery::getNameFromProperties(
426 const utils::PropertyMap& properties)
427{
428 if (!properties.contains("Name"))
429 {
430 error("Missing name property");
431 return "";
432 }
433 return std::get<std::string>(properties.at("Name"));
434}
435
436std::string MctpDiscovery::constructMctpReactorObjectPath(
437 const MctpInfo& mctpInfo)
438{
439 const auto networkId = std::get<NetworkId>(mctpInfo);
440 const auto eid = std::get<pldm::eid>(mctpInfo);
441 return std::string{MCTPPath} + "/networks/" + std::to_string(networkId) +
442 "/endpoints/" + std::to_string(eid) + "/configured_by";
443}
444
445void MctpDiscovery::searchConfigurationFor(
446 const pldm::utils::DBusHandler& handler, MctpInfo& mctpInfo)
447{
448 const auto mctpReactorObjectPath = constructMctpReactorObjectPath(mctpInfo);
449 try
450 {
451 std::string associatedObjPath;
452 std::string associatedService;
453 std::string associatedInterface;
454 sdbusplus::message::object_path inventorySubtreePath(
455 inventorySubtreePathStr);
456
457 //"/{board or chassis type}/{board or chassis}/{device}"
458 auto constexpr subTreeDepth = 3;
459 auto response = handler.getAssociatedSubTree(
460 mctpReactorObjectPath, inventorySubtreePath, subTreeDepth,
461 interfaceFilter);
462 if (response.empty())
463 {
464 warning("No associated subtree found for path {PATH}", "PATH",
465 mctpReactorObjectPath);
466 return;
467 }
468 // Assume the first entry is the one we want
469 auto subTree = response.begin();
470 associatedObjPath = subTree->first;
471 auto associatedServiceProp = subTree->second;
472 if (associatedServiceProp.empty())
473 {
474 warning("No associated service found for path {PATH}", "PATH",
475 mctpReactorObjectPath);
476 return;
477 }
478 // Assume the first entry is the one we want
479 auto entry = associatedServiceProp.begin();
480 associatedService = entry->first;
481 auto dBusIntfList = entry->second;
482 auto associatedInterfaceItr = std::find_if(
483 dBusIntfList.begin(), dBusIntfList.end(), [](const auto& intf) {
484 return std::find(interfaceFilter.begin(), interfaceFilter.end(),
485 intf) != interfaceFilter.end();
486 });
487 if (associatedInterfaceItr == dBusIntfList.end())
488 {
489 error("No associated interface found for path {PATH}", "PATH",
490 mctpReactorObjectPath);
491 return;
492 }
493 associatedInterface = *associatedInterfaceItr;
494 auto mctpTargetProperties = handler.getDbusPropertiesVariant(
495 associatedService.c_str(), associatedObjPath.c_str(),
496 associatedInterface.c_str());
497 auto name = getNameFromProperties(mctpTargetProperties);
498 if (!name.empty())
499 {
500 std::get<std::optional<std::string>>(mctpInfo) = name;
501 }
502 configurations.emplace(associatedObjPath, mctpInfo);
503 }
504 catch (const std::exception& e)
505 {
506 error(
507 "Error getting associated subtree for path {PATH}, error - {ERROR}",
508 "PATH", mctpReactorObjectPath, "ERROR", e);
509 return;
510 }
511}
512
513void MctpDiscovery::removeConfigs(const MctpInfos& removedInfos)
514{
515 for (const auto& mctpInfo : removedInfos)
516 {
Eric Yang6449a3b2025-10-08 10:53:04 +0000517 const auto eidToRemove = std::get<eid>(mctpInfo);
518 const auto netToRemove = std::get<NetworkId>(mctpInfo);
519
520 std::erase_if(configurations, [eidToRemove,
521 netToRemove](const auto& config) {
522 const auto& [__, mctpInfo] = config;
523 const auto eidValue = std::get<eid>(mctpInfo);
524 const auto netValue = std::get<NetworkId>(mctpInfo);
525
526 return eidValue == eidToRemove && netValue == netToRemove;
Unive Tienc40d4a62025-03-12 11:36:07 +0800527 });
528 }
529}
530
Andrew Jeffery27a022c2022-08-10 23:12:49 +0930531} // namespace pldm