Skip to content

Commit 62e2c4e

Browse files
author
vedganes
committed
[neighorch] VOQ encap index change handling
Signed-off-by: vedganes <[email protected]> For the remote neighbors in the VOQ systems when there is change in the encap index (due to syncd restart), the previously programmed remote neighs should be re-written with the new changed encap index. The current voq system neigh handling api in neighorch only checks for the change of mac address. Because of this the change in the encap index is ignored. This causes mismatch of encap index in the neighbor records in owner asic and the remote asics after syncd restart situations like config reload or failure recovery. This results in packet forwarding failures for the packets forwarded across fabric and egressing in different asics than ingress asics. The encap index that was previously allocated by SAI and synced to the CHASSIS_APP_DB may change for the same neighbor when syncd is restarted after config reload or any failure recovery situations. When syncd restarts, the SAI may undergo full re-initialization and may loose the memory of previous encap index allocation for the neighbors. During reprogramming of the neighbors they may not get the same encap index that were allocated before restart. This fix is to store the allocated encap index in the orchagent (neighorch) and compare with received encap index if the neighbor entry already exits. This comparison of encap index is new to voq chassis. This is done in addition to checking for mac change. For any received (synced) neigh (received from CHASSIS_APP_DB) if neigh entry already exists and if there is change in encap index, the current neigh entry is removed and re-added. As of now, since current SAI does not support change of encap index (i.e, set of operaton of encap index attribute for neigh records) del and re-add is done.
1 parent 6c88e47 commit 62e2c4e

File tree

2 files changed

+51
-22
lines changed

2 files changed

+51
-22
lines changed

orchagent/neighorch.cpp

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -783,16 +783,16 @@ bool NeighOrch::addNeighbor(const NeighborEntry &neighborEntry, const MacAddress
783783
MuxOrch* mux_orch = gDirectory.get<MuxOrch*>();
784784
bool hw_config = isHwConfigured(neighborEntry);
785785

786-
if (!hw_config && mux_orch->isNeighborActive(ip_address, macAddress, alias))
786+
if (gMySwitchType == "voq")
787787
{
788-
if (gMySwitchType == "voq")
788+
if (!addVoqEncapIndex(alias, ip_address, neighbor_attrs))
789789
{
790-
if (!addVoqEncapIndex(alias, ip_address, neighbor_attrs))
791-
{
792-
return false;
793-
}
790+
return false;
794791
}
792+
}
795793

794+
if (!hw_config && mux_orch->isNeighborActive(ip_address, macAddress, alias))
795+
{
796796
status = sai_neighbor_api->create_neighbor_entry(&neighbor_entry,
797797
(uint32_t)neighbor_attrs.size(), neighbor_attrs.data());
798798
if (status != SAI_STATUS_SUCCESS)
@@ -1230,8 +1230,30 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)
12301230
}
12311231

12321232
if (m_syncdNeighbors.find(neighbor_entry) == m_syncdNeighbors.end() ||
1233-
m_syncdNeighbors[neighbor_entry].mac != mac_address)
1233+
m_syncdNeighbors[neighbor_entry].mac != mac_address ||
1234+
m_syncdNeighbors[neighbor_entry].voq_encap_index != encap_index)
12341235
{
1236+
// Handle encap index change. SAI does not support change of encap index for
1237+
// existing neighbors. Remove the neighbor but do not errase from consumer sync
1238+
// buffer. The next iteration will add the neighbor back with new encap index
1239+
1240+
if (m_syncdNeighbors.find(neighbor_entry) != m_syncdNeighbors.end() &&
1241+
m_syncdNeighbors[neighbor_entry].voq_encap_index != encap_index)
1242+
{
1243+
//Remove neigh from SAI
1244+
if (removeNeighbor(neighbor_entry))
1245+
{
1246+
//neigh successfully deleted from SAI. Set STATE DB to signal to remove entries from kernel
1247+
m_stateSystemNeighTable->del(state_key);
1248+
}
1249+
else
1250+
{
1251+
SWSS_LOG_ERROR("Failed to remove voq neighbor %s from SAI during encap index change", kfvKey(t).c_str());
1252+
}
1253+
it++;
1254+
continue;
1255+
}
1256+
12351257
//Add neigh to SAI
12361258
if (addNeighbor(neighbor_entry, mac_address))
12371259
{
@@ -1467,6 +1489,27 @@ void NeighOrch::voqSyncAddNeigh(string &alias, IpAddress &ip_address, const MacA
14671489
sai_attribute_t attr;
14681490
sai_status_t status;
14691491

1492+
// Get the encap index and store it for handling change of
1493+
// encap index for remote neighbors synced via CHASSIS_APP_DB
1494+
1495+
attr.id = SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_INDEX;
1496+
1497+
status = sai_neighbor_api->get_neighbor_entry_attribute(&neighbor_entry, 1, &attr);
1498+
if (status != SAI_STATUS_SUCCESS)
1499+
{
1500+
SWSS_LOG_ERROR("Failed to get neighbor attribute for %s on %s, rv:%d", ip_address.to_string().c_str(), alias.c_str(), status);
1501+
return;
1502+
}
1503+
1504+
if (!attr.value.u32)
1505+
{
1506+
SWSS_LOG_ERROR("Invalid neighbor encap_index for %s on %s", ip_address.to_string().c_str(), alias.c_str());
1507+
return;
1508+
}
1509+
1510+
NeighborEntry nbrEntry = {ip_address, alias};
1511+
m_syncdNeighbors[nbrEntry].voq_encap_index = attr.value.u32;
1512+
14701513
//Sync only local neigh. Confirm for the local neigh and
14711514
//get the system port alias for key for syncing to CHASSIS_APP_DB
14721515
Port port;
@@ -1495,21 +1538,6 @@ void NeighOrch::voqSyncAddNeigh(string &alias, IpAddress &ip_address, const MacA
14951538
return;
14961539
}
14971540

1498-
attr.id = SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_INDEX;
1499-
1500-
status = sai_neighbor_api->get_neighbor_entry_attribute(&neighbor_entry, 1, &attr);
1501-
if (status != SAI_STATUS_SUCCESS)
1502-
{
1503-
SWSS_LOG_ERROR("Failed to get neighbor attribute for %s on %s, rv:%d", ip_address.to_string().c_str(), alias.c_str(), status);
1504-
return;
1505-
}
1506-
1507-
if (!attr.value.u32)
1508-
{
1509-
SWSS_LOG_ERROR("Invalid neighbor encap_index for %s on %s", ip_address.to_string().c_str(), alias.c_str());
1510-
return;
1511-
}
1512-
15131541
vector<FieldValueTuple> attrs;
15141542

15151543
FieldValueTuple eiFv ("encap_index", to_string(attr.value.u32));

orchagent/neighorch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct NeighborData
2727
{
2828
MacAddress mac;
2929
bool hw_configured = false; // False means, entry is not written to HW
30+
uint32_t voq_encap_index = 0;
3031
};
3132

3233
/* NeighborTable: NeighborEntry, neighbor MAC address */

0 commit comments

Comments
 (0)