Skip to content

Commit

Permalink
[orchagent]: Get bridge port ID from orchagent cache instead of SAI A…
Browse files Browse the repository at this point in the history
…PI (#2657)

* [fdborch]: Get bridge port ID from cache instead
  • Loading branch information
theasianpianist authored and StormLiangMS committed Mar 7, 2023
1 parent f4b88f3 commit 4a321f0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
28 changes: 11 additions & 17 deletions orchagent/fdborch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,29 +636,23 @@ bool FdbOrch::getPort(const MacAddress& mac, uint16_t vlan, Port& port)
return false;
}

sai_fdb_entry_t entry;
entry.switch_id = gSwitchId;
memcpy(entry.mac_address, mac.getMac(), sizeof(sai_mac_t));
FdbEntry entry;
entry.mac = mac;
entry.bv_id = port.m_vlan_info.vlan_oid;

sai_attribute_t attr;
attr.id = SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID;

sai_status_t status = sai_fdb_api->get_fdb_entry_attribute(&entry, 1, &attr);
if (status != SAI_STATUS_SUCCESS)
auto it = m_entries.find(entry);
if (it == m_entries.end())
{
SWSS_LOG_ERROR("Failed to get bridge port ID for FDB entry %s, rv:%d",
mac.to_string().c_str(), status);
task_process_status handle_status = handleSaiGetStatus(SAI_API_FDB, status);
if (handle_status != task_process_status::task_success)
{
return false;
}
// This message is now expected in many cases since orchagent will process events such as
// learning new neighbor entries prior to updating the m_entries FDB cache.
SWSS_LOG_INFO("Failed to get cached bridge port ID for FDB entry %s",
mac.to_string().c_str());
return false;
}

if (!m_portsOrch->getPortByBridgePortId(attr.value.oid, port))
if (!m_portsOrch->getPortByBridgePortId(it->second.bridge_port_id, port))
{
SWSS_LOG_ERROR("Failed to get port by bridge port ID 0x%" PRIx64, attr.value.oid);
SWSS_LOG_ERROR("Failed to get port by bridge port ID 0x%" PRIx64, it->second.bridge_port_id);
return false;
}

Expand Down
4 changes: 4 additions & 0 deletions orchagent/muxorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,8 @@ bool MuxCable::isIpInSubnet(IpAddress ip)

bool MuxCable::nbrHandler(bool enable, bool update_rt)
{
SWSS_LOG_NOTICE("Processing neighbors for mux %s, enable %d, state %d",
mux_name_.c_str(), enable, state_);
if (enable)
{
return nbr_handler_->enable(update_rt);
Expand All @@ -542,6 +544,8 @@ bool MuxCable::nbrHandler(bool enable, bool update_rt)

void MuxCable::updateNeighbor(NextHopKey nh, bool add)
{
SWSS_LOG_NOTICE("Processing update on neighbor %s for mux %s, add %d, state %d",
nh.ip_address.to_string().c_str(), mux_name_.c_str(), add, state_);
sai_object_id_t tnh = mux_orch_->getNextHopTunnelId(MUX_TUNNEL, peer_ip4_);
if (add && skip_neighbors_.find(nh.ip_address) != skip_neighbors_.end())
{
Expand Down

0 comments on commit 4a321f0

Please sign in to comment.