Skip to content

Commit

Permalink
[neighorch] VOQ Inband interface port code review comments fix 4
Browse files Browse the repository at this point in the history
- Changes to avoid calling function to add encap index attribute for
inband interface host neighbor. Since encap index attribute is supplied
only for the remote neighbors and since the inband interface neighbor is
local encap index will not added even if this function is called. So
removed calling the api addVoqEncapIndex() while constructing neighbor
add message for inband interface host.
- Added changes to handle encap index change for the remote neighbors.
During config re-load, there is a chance that SAI may allocate a
different encap index than the index allocated before config-reload for
the same neighbor. Since the mac addresss and ip address are same,
neighorch, while processing this synced remote neighbors, considers this as
duplicate and ignores it. This is fixed by making neighorch consider encap index
received from CHASSIS_APP_DB in addition to mac and ip address to check
for duplicate neighbor.

Signed-off-by: vedganes <[email protected]>
  • Loading branch information
vedganes committed Apr 9, 2021
1 parent 8248ed1 commit 8730bd8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
44 changes: 23 additions & 21 deletions orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,8 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)
}

if (m_syncdNeighbors.find(neighbor_entry) == m_syncdNeighbors.end() ||
m_syncdNeighbors[neighbor_entry].mac != mac_address)
m_syncdNeighbors[neighbor_entry].mac != mac_address ||
m_syncdNeighbors[neighbor_entry].voq_encap_index != encap_index)
{
//Add neigh to SAI
if (addNeighbor(neighbor_entry, mac_address))
Expand Down Expand Up @@ -1199,11 +1200,6 @@ bool NeighOrch::addInbandNeighbor(string alias, IpAddress ip_address)
memcpy(attr.value.mac, inband_mac.getMac(), 6);
neighbor_attrs.push_back(attr);

if(!addVoqEncapIndex(alias, ip_address, neighbor_attrs))
{
return false;
}

//No host route for neighbor of the Inband IP address
attr.id = SAI_NEIGHBOR_ENTRY_ATTR_NO_HOST_ROUTE;
attr.value.booldata = true;
Expand Down Expand Up @@ -1347,6 +1343,27 @@ void NeighOrch::voqSyncAddNeigh(string &alias, IpAddress &ip_address, const MacA
sai_attribute_t attr;
sai_status_t status;

// Get the encap index and store it for handling change of
// encap index for remote neighbors synced via CHASSIS_APP_DB

attr.id = SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_INDEX;

status = sai_neighbor_api->get_neighbor_entry_attribute(&neighbor_entry, 1, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to get neighbor attribute for %s on %s, rv:%d", ip_address.to_string().c_str(), alias.c_str(), status);
return;
}

if (!attr.value.u32)
{
SWSS_LOG_ERROR("Invalid neighbor encap_index for %s on %s", ip_address.to_string().c_str(), alias.c_str());
return;
}

NeighborEntry nbrEntry = {ip_address, alias};
m_syncdNeighbors[nbrEntry].voq_encap_index = attr.value.u32;

//Sync only local neigh. Confirm for the local neigh and
//get the system port alias for key for syncing to CHASSIS_APP_DB
Port port;
Expand Down Expand Up @@ -1375,21 +1392,6 @@ void NeighOrch::voqSyncAddNeigh(string &alias, IpAddress &ip_address, const MacA
return;
}

attr.id = SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_INDEX;

status = sai_neighbor_api->get_neighbor_entry_attribute(&neighbor_entry, 1, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to get neighbor attribute for %s on %s, rv:%d", ip_address.to_string().c_str(), alias.c_str(), status);
return;
}

if (!attr.value.u32)
{
SWSS_LOG_ERROR("Invalid neighbor encap_index for %s on %s", ip_address.to_string().c_str(), alias.c_str());
return;
}

vector<FieldValueTuple> attrs;

FieldValueTuple eiFv ("encap_index", to_string(attr.value.u32));
Expand Down
1 change: 1 addition & 0 deletions orchagent/neighorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct NeighborData
{
MacAddress mac;
bool hw_configured = false; // False means, entry is not written to HW
uint32_t voq_encap_index = 0;
};

/* NeighborTable: NeighborEntry, neighbor MAC address */
Expand Down

0 comments on commit 8730bd8

Please sign in to comment.