Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2046,13 +2046,13 @@ bool NeighOrch::enableNeighbors(std::list<NeighborContext>& bulk_ctx_list)
for (auto ctx = bulk_ctx_list.begin(); ctx != bulk_ctx_list.end(); ctx++)
{
const NeighborEntry& neighborEntry = ctx->neighborEntry;
ctx->mac = m_syncdNeighbors[neighborEntry].mac;

if (m_syncdNeighbors.find(neighborEntry) == m_syncdNeighbors.end())
auto neighborIt = m_syncdNeighbors.find(neighborEntry);
if (neighborIt == m_syncdNeighbors.end())
{
SWSS_LOG_INFO("Neighbor %s not found", neighborEntry.ip_address.to_string().c_str());
continue;
}
ctx->mac = neighborIt->second.mac;

if (isHwConfigured(neighborEntry))
{
Expand Down
10 changes: 10 additions & 0 deletions tests/mock_tests/neighorch_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ namespace neighorch_test
ASSERT_EQ(gNeighOrch->m_syncdNeighbors.count(VLAN2000_NEIGH), 0);
}

TEST_F(NeighOrchTest, EnableNeighborsDoesNotInsertMissingNeighbor)
{
list<NeighborContext> contexts;
contexts.emplace_back(VLAN1000_NEIGH, true);

ASSERT_EQ(gNeighOrch->m_syncdNeighbors.count(VLAN1000_NEIGH), 0u);
EXPECT_TRUE(gNeighOrch->enableNeighbors(contexts));
EXPECT_EQ(gNeighOrch->m_syncdNeighbors.count(VLAN1000_NEIGH), 0u);
}

TEST_F(NeighOrchTest, MultiVlanUnableToRemoveNeighbor)
{
EXPECT_CALL(*mock_sai_neighbor_api, create_neighbor_entry);
Expand Down
Loading