Skip to content

Commit

Permalink
[Everflow/ERSPAN] Set correct destination port and mac address when the
Browse files Browse the repository at this point in the history
nexthop is updated for ERSPAN mirror destination

Signed-off-by: Sakthivadivu Saravanaraj <sakthivadivu.saravanaraj@nokia.com>
  • Loading branch information
saksarav-nokia committed Aug 3, 2022
1 parent 3161eaa commit f2fded5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 6 deletions.
31 changes: 29 additions & 2 deletions orchagent/mirrororch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,13 @@ bool MirrorOrch::updateSessionDstMac(const string& name, MirrorEntry& session)

sai_attribute_t attr;
attr.id = SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS;
memcpy(attr.value.mac, session.neighborInfo.mac.getMac(), sizeof(sai_mac_t));
if (gMySwitchType == "voq")
{
memcpy(attr.value.mac, gMacAddress.getMac(), sizeof(sai_mac_t));
} else
{
memcpy(attr.value.mac, session.neighborInfo.mac.getMac(), sizeof(sai_mac_t));
}

sai_status_t status = sai_mirror_api->set_mirror_session_attribute(session.sessionId, &attr);
if (status != SAI_STATUS_SUCCESS)
Expand Down Expand Up @@ -1148,7 +1154,28 @@ bool MirrorOrch::updateSessionDstPort(const string& name, MirrorEntry& session)

sai_attribute_t attr;
attr.id = SAI_MIRROR_SESSION_ATTR_MONITOR_PORT;
attr.value.oid = session.neighborInfo.portId;
if (session.type == MIRROR_SESSION_SPAN)
{
attr.value.oid = session.neighborInfo.portId;
}
else
{
// Set monitor port to recirc port in voq switch.
if (gMySwitchType == "voq")
{
Port recirc_port;
if (!m_portsOrch->getRecircPort(recirc_port, "Rec"))
{
SWSS_LOG_ERROR("Failed to get recirc prot");
return false;
}
attr.value.oid = recirc_port.m_port_id;
}
else
{
attr.value.oid = session.neighborInfo.portId;
}
}

sai_status_t status = sai_mirror_api->
set_mirror_session_attribute(session.sessionId, &attr);
Expand Down
27 changes: 23 additions & 4 deletions orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,18 +597,37 @@ void NeighOrch::decreaseNextHopRefCount(const NextHopKey &nexthop, uint32_t coun

bool NeighOrch::getNeighborEntry(const NextHopKey &nexthop, NeighborEntry &neighborEntry, MacAddress &macAddress)
{
Port inbp;
string nbr_alias;
if (!hasNextHop(nexthop))
{
return false;
}
if (gMySwitchType == "voq")
{
gPortsOrch->getInbandPort(inbp);
assert(inbp.m_alias.length());
}

for (const auto &entry : m_syncdNeighbors)
{
if (entry.first.ip_address == nexthop.ip_address && entry.first.alias == nexthop.alias)
if (entry.first.ip_address == nexthop.ip_address)
{
neighborEntry = entry.first;
macAddress = entry.second.mac;
return true;
if (m_intfsOrch->isRemoteSystemPortIntf(entry.first.alias))
{
//For remote system ports, nexthops are always on inband.
nbr_alias = inbp.m_alias;
}
else
{
nbr_alias = entry.first.alias;
}
if (nbr_alias == nexthop.alias)
{
neighborEntry = entry.first;
macAddress = entry.second.mac;
return true;
}
}
}

Expand Down

0 comments on commit f2fded5

Please sign in to comment.