Skip to content

Commit c2b01ba

Browse files
[orchagent]: Get bridge port ID from orchagent cache instead of SAI API (sonic-net#2657)
* [fdborch]: Get bridge port ID from cache instead
1 parent d8a1cb7 commit c2b01ba

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

orchagent/fdborch.cpp

+11-17
Original file line numberDiff line numberDiff line change
@@ -636,29 +636,23 @@ bool FdbOrch::getPort(const MacAddress& mac, uint16_t vlan, Port& port)
636636
return false;
637637
}
638638

639-
sai_fdb_entry_t entry;
640-
entry.switch_id = gSwitchId;
641-
memcpy(entry.mac_address, mac.getMac(), sizeof(sai_mac_t));
639+
FdbEntry entry;
640+
entry.mac = mac;
642641
entry.bv_id = port.m_vlan_info.vlan_oid;
643642

644-
sai_attribute_t attr;
645-
attr.id = SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID;
646-
647-
sai_status_t status = sai_fdb_api->get_fdb_entry_attribute(&entry, 1, &attr);
648-
if (status != SAI_STATUS_SUCCESS)
643+
auto it = m_entries.find(entry);
644+
if (it == m_entries.end())
649645
{
650-
SWSS_LOG_ERROR("Failed to get bridge port ID for FDB entry %s, rv:%d",
651-
mac.to_string().c_str(), status);
652-
task_process_status handle_status = handleSaiGetStatus(SAI_API_FDB, status);
653-
if (handle_status != task_process_status::task_success)
654-
{
655-
return false;
656-
}
646+
// This message is now expected in many cases since orchagent will process events such as
647+
// learning new neighbor entries prior to updating the m_entries FDB cache.
648+
SWSS_LOG_INFO("Failed to get cached bridge port ID for FDB entry %s",
649+
mac.to_string().c_str());
650+
return false;
657651
}
658652

659-
if (!m_portsOrch->getPortByBridgePortId(attr.value.oid, port))
653+
if (!m_portsOrch->getPortByBridgePortId(it->second.bridge_port_id, port))
660654
{
661-
SWSS_LOG_ERROR("Failed to get port by bridge port ID 0x%" PRIx64, attr.value.oid);
655+
SWSS_LOG_ERROR("Failed to get port by bridge port ID 0x%" PRIx64, it->second.bridge_port_id);
662656
return false;
663657
}
664658

orchagent/muxorch.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,8 @@ bool MuxCable::isIpInSubnet(IpAddress ip)
534534

535535
bool MuxCable::nbrHandler(bool enable, bool update_rt)
536536
{
537+
SWSS_LOG_NOTICE("Processing neighbors for mux %s, enable %d, state %d",
538+
mux_name_.c_str(), enable, state_);
537539
if (enable)
538540
{
539541
return nbr_handler_->enable(update_rt);
@@ -553,6 +555,8 @@ bool MuxCable::nbrHandler(bool enable, bool update_rt)
553555

554556
void MuxCable::updateNeighbor(NextHopKey nh, bool add)
555557
{
558+
SWSS_LOG_NOTICE("Processing update on neighbor %s for mux %s, add %d, state %d",
559+
nh.ip_address.to_string().c_str(), mux_name_.c_str(), add, state_);
556560
sai_object_id_t tnh = mux_orch_->getNextHopTunnelId(MUX_TUNNEL, peer_ip4_);
557561
nbr_handler_->update(nh, tnh, add, state_);
558562
if (add)

0 commit comments

Comments
 (0)