Skip to content

Commit

Permalink
Use neighbor RIF in pre match logic (sonic-net#1026)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik authored Apr 1, 2022
1 parent 473c990 commit 0d163b1
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 0 deletions.
3 changes: 3 additions & 0 deletions syncd/AsicView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ void AsicView::fromDump(
case SAI_OBJECT_TYPE_NEIGHBOR_ENTRY:
sai_deserialize_neighbor_entry(o->m_str_object_id, o->m_meta_key.objectkey.key.neighbor_entry);
m_soNeighbors[o->m_str_object_id] = o;

m_neighborsByIp[sai_serialize_ip_address(o->m_meta_key.objectkey.key.neighbor_entry.ip_address)].push_back(o->m_str_object_id);

break;

case SAI_OBJECT_TYPE_ROUTE_ENTRY:
Expand Down
1 change: 1 addition & 0 deletions syncd/AsicView.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ namespace syncd
StrObjectIdToSaiObjectHash m_soAll;

std::unordered_map<std::string,std::vector<std::string>> m_routesByPrefix;
std::unordered_map<std::string,std::vector<std::string>> m_neighborsByIp;

ObjectIdToSaiObjectHash m_oOids;

Expand Down
40 changes: 40 additions & 0 deletions syncd/ComparisonLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2875,6 +2875,46 @@ void ComparisonLogic::createPreMatchMap(
createPreMatchMapForObject(cur, tmp, cObj, tObj, processed);
}

for (auto&pk: tmp.m_neighborsByIp)
{
auto& ip = pk.first;

// look only for unique neighbors

if (pk.second.size() != 1)
continue;

auto it = cur.m_neighborsByIp.find(ip);

if (it == cur.m_neighborsByIp.end())
continue;

if (it->second.size() != 1)
continue;

auto& tObj = tmp.m_soAll.at(pk.second.at(0));
auto& cObj = cur.m_soAll.at(it->second.at(0));

createPreMatchMapForObject(cur, tmp, cObj, tObj, processed);

sai_object_id_t tRifVid = tObj->m_meta_key.objectkey.key.neighbor_entry.rif_id;
sai_object_id_t cRifVid = cObj->m_meta_key.objectkey.key.neighbor_entry.rif_id;

if (processed.find(cObj->m_str_object_id) == processed.end())
{
SWSS_LOG_INFO("pre match Neighbor RIF: cur: %s, tmp: %s",
sai_serialize_object_id(cRifVid).c_str(),
sai_serialize_object_id(tRifVid).c_str());

tmp.m_preMatchMap[tRifVid] = cRifVid;

auto& cO = cur.m_oOids.at(cRifVid);
auto& tO = tmp.m_oOids.at(tRifVid);

createPreMatchMapForObject(cur, tmp, cO, tO, processed);
}
}

cretePreMatchForLagMembers(cur, tmp, processed);

size_t count = 0;
Expand Down
14 changes: 14 additions & 0 deletions tests/BCM56850.pl
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,22 @@ sub test_lag_member
play "test_lag_member.rec", 1;
}

sub test_neighbor_lag
{
fresh_start;

play "test_neighbor_lag.rec";
play "test_neighbor_lag.rec", 3;
play "test_neighbor_lag.rec", 3;
play "test_neighbor_lag.rec", 3;
play "test_neighbor_lag.rec", 3;
play "test_neighbor_lag.rec", 3;
play "test_neighbor_lag.rec", 3;
}

# RUN TESTS

test_neighbor_lag;
test_lag_member;
test_remove_port_serdes;
test_brcm_warm_new_object_port_serdes;
Expand Down
Loading

0 comments on commit 0d163b1

Please sign in to comment.