Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions fboss/led_service/LedManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,16 @@ void LedManager::triggerLedUpdate(const std::vector<PortID>& portIds) {
/*
* updateLedStatus
*
* This function does these two things:
* This function does these three things:
* 1. Look into the FSDB pushed data (switch states) in newSwitchState and
* updates the local structure portDisplayMap_ as per the operational values
* in latest switch state
* 2. Trigger an LED update (triggerLedUpdate. This will Compute LED colors for
* 2. Drop the ports which are no longer present in the switch state. The
* subscriber always builds newSwitchState from the full agent port map, so
* anything missing from it is not an active port anymore (ie: the port was
* removed by a breakout change). Keeping it would leave a phantom port in
* the LED aggregation of its siblings sharing the same LED.
* 3. Trigger an LED update (triggerLedUpdate. This will Compute LED colors for
* new state and if the color for a port is different than existing one then set
* the new color on LED
*/
Expand Down Expand Up @@ -150,6 +155,19 @@ void LedManager::updateLedStatus(
portsToTriggerLedUpdate.emplace_back(portId);
}

for (auto itr = portDisplayMap_.begin(); itr != portDisplayMap_.end();) {
if (newSwitchState.find(static_cast<short>(itr->first)) ==
newSwitchState.end()) {
XLOG(DBG2) << fmt::format(
"Port {:s} ({:d}) no longer in switch state, removing it from portDisplayMap_",
itr->second.portName,
itr->first);
itr = portDisplayMap_.erase(itr);
} else {
++itr;
}
}

triggerLedUpdate(portsToTriggerLedUpdate);
}

Expand Down