Skip to content

Commit

Permalink
Replace neighOrch hasNextHop() asserts with .at()
Browse files Browse the repository at this point in the history
  • Loading branch information
abanu-ms authored and TACappleman committed Aug 27, 2021
1 parent 3cc584a commit b99ed4d
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ NeighOrch::NeighOrch(DBConnector *appDb, string tableName, IntfsOrch *intfsOrch,
SWSS_LOG_ENTER();

m_fdbOrch->attach(this);

if(gMySwitchType == "voq")
{
//Add subscriber to process VOQ system neigh
Expand Down Expand Up @@ -469,14 +469,14 @@ bool NeighOrch::removeMplsNextHop(const NextHopKey& nh)

gFgNhgOrch->invalidNextHopInNextHopGroup(nexthop);

if (m_syncdNextHops[nexthop].ref_count > 0)
if (m_syncdNextHops.at(nexthop).ref_count > 0)
{
SWSS_LOG_ERROR("Failed to remove still referenced next hop %s",
nexthop.to_string().c_str());
return false;
}

sai_object_id_t next_hop_id = m_syncdNextHops[nexthop].next_hop_id;
sai_object_id_t next_hop_id = m_syncdNextHops.at(nexthop).next_hop_id;
sai_status_t status = sai_next_hop_api->remove_next_hop(next_hop_id);

/*
Expand Down Expand Up @@ -520,9 +520,7 @@ bool NeighOrch::removeOverlayNextHop(const NextHopKey &nexthop)
{
SWSS_LOG_ENTER();

assert(hasNextHop(nexthop));

if (m_syncdNextHops[nexthop].ref_count > 0)
if (m_syncdNextHops.at(nexthop).ref_count > 0)
{
SWSS_LOG_ERROR("Failed to remove still referenced next hop %s on %s",
nexthop.ip_address.to_string().c_str(), nexthop.alias.c_str());
Expand All @@ -545,8 +543,6 @@ sai_object_id_t NeighOrch::getLocalNextHopId(const NextHopKey& nexthop)

sai_object_id_t NeighOrch::getNextHopId(const NextHopKey &nexthop)
{
assert(hasNextHop(nexthop));

/*
* The nexthop id could be varying depending on the use-case
* For e.g, a route could have a direct neighbor but may require
Expand All @@ -558,31 +554,22 @@ sai_object_id_t NeighOrch::getNextHopId(const NextHopKey &nexthop)
{
return nhid;
}
return m_syncdNextHops[nexthop].next_hop_id;
return m_syncdNextHops.at(nexthop).next_hop_id;
}

int NeighOrch::getNextHopRefCount(const NextHopKey &nexthop)
{
assert(hasNextHop(nexthop));
return m_syncdNextHops[nexthop].ref_count;
return m_syncdNextHops.at(nexthop).ref_count;
}

void NeighOrch::increaseNextHopRefCount(const NextHopKey &nexthop, uint32_t count)
{
assert(hasNextHop(nexthop));
if (m_syncdNextHops.find(nexthop) != m_syncdNextHops.end())
{
m_syncdNextHops[nexthop].ref_count += count;
}
m_syncdNextHops.at(nexthop).ref_count += count;
}

void NeighOrch::decreaseNextHopRefCount(const NextHopKey &nexthop, uint32_t count)
{
assert(hasNextHop(nexthop));
if (m_syncdNextHops.find(nexthop) != m_syncdNextHops.end())
{
m_syncdNextHops[nexthop].ref_count -= count;
}
m_syncdNextHops.at(nexthop).ref_count -= count;
}

bool NeighOrch::getNeighborEntry(const NextHopKey &nexthop, NeighborEntry &neighborEntry, MacAddress &macAddress)
Expand Down Expand Up @@ -1028,7 +1015,7 @@ bool NeighOrch::removeNeighbor(const NeighborEntry &neighborEntry, bool disable)

NeighborUpdate update = { neighborEntry, MacAddress(), false };
notify(SUBJECT_TYPE_NEIGH_CHANGE, static_cast<void *>(&update));

if(gMySwitchType == "voq")
{
//Sync the neighbor to delete from the CHASSIS_APP_DB
Expand Down Expand Up @@ -1302,7 +1289,7 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)
// the owner asic's mac is not readily avaiable here, the owner asic mac is derived from
// the switch id and lower 5 bytes of asic mac which is assumed to be same for all asics
// in the VS system.
// Therefore to make VOQ chassis systems work in VS platform based setups like the setups
// Therefore to make VOQ chassis systems work in VS platform based setups like the setups
// using KVMs, it is required that all asics have same base mac in the format given below
// <lower 5 bytes of mac same for all asics>:<6th byte = switch_id>

Expand Down

0 comments on commit b99ed4d

Please sign in to comment.