@@ -583,13 +583,30 @@ void MirrorOrch::setSessionState(const string& name, const MirrorEntry& session,
583
583
if (attr.empty () || attr == MIRROR_SESSION_MONITOR_PORT)
584
584
{
585
585
Port port;
586
- m_portsOrch->getPort (session.neighborInfo .portId , port);
586
+ if ((gMySwitchType == " voq" ) && (session.type == MIRROR_SESSION_ERSPAN))
587
+ {
588
+ if (!m_portsOrch->getRecircPort (port, " Rec" ))
589
+ {
590
+ SWSS_LOG_ERROR (" Failed to get recirc port for mirror session %s" , name.c_str ());
591
+ return ;
592
+ }
593
+ }
594
+ else
595
+ {
596
+ m_portsOrch->getPort (session.neighborInfo .portId , port);
597
+ }
587
598
fvVector.emplace_back (MIRROR_SESSION_MONITOR_PORT, port.m_alias );
588
599
}
589
600
590
601
if (attr.empty () || attr == MIRROR_SESSION_DST_MAC_ADDRESS)
591
602
{
592
- value = session.neighborInfo .mac .to_string ();
603
+ if ((gMySwitchType == " voq" ) && (session.type == MIRROR_SESSION_ERSPAN))
604
+ {
605
+ value = gMacAddress .to_string ();
606
+ } else
607
+ {
608
+ value = session.neighborInfo .mac .to_string ();
609
+ }
593
610
fvVector.emplace_back (MIRROR_SESSION_DST_MAC_ADDRESS, value);
594
611
}
595
612
@@ -928,7 +945,7 @@ bool MirrorOrch::activateSession(const string& name, MirrorEntry& session)
928
945
Port recirc_port;
929
946
if (!m_portsOrch->getRecircPort (recirc_port, " Rec" ))
930
947
{
931
- SWSS_LOG_ERROR (" Failed to get recirc prot " );
948
+ SWSS_LOG_ERROR (" Failed to get recirc port " );
932
949
return false ;
933
950
}
934
951
attr.value .oid = recirc_port.m_port_id ;
@@ -999,9 +1016,9 @@ bool MirrorOrch::activateSession(const string& name, MirrorEntry& session)
999
1016
1000
1017
attr.id = SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS;
1001
1018
// Use router mac as mirror dst mac in voq switch.
1002
- if (gMySwitchType == " voq" )
1019
+ if (( gMySwitchType == " voq" ) && (session. type == MIRROR_SESSION_ERSPAN) )
1003
1020
{
1004
- memcpy (attr.value .mac , gMacAddress .getMac (), sizeof (sai_mac_t ));
1021
+ memcpy (attr.value .mac , gMacAddress .getMac (), sizeof (sai_mac_t ));
1005
1022
}
1006
1023
else
1007
1024
{
@@ -1115,13 +1132,19 @@ bool MirrorOrch::updateSessionDstMac(const string& name, MirrorEntry& session)
1115
1132
1116
1133
sai_attribute_t attr;
1117
1134
attr.id = SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS;
1118
- memcpy (attr.value .mac , session.neighborInfo .mac .getMac (), sizeof (sai_mac_t ));
1135
+ if ((gMySwitchType == " voq" ) && (session.type == MIRROR_SESSION_ERSPAN))
1136
+ {
1137
+ memcpy (attr.value .mac , gMacAddress .getMac (), sizeof (sai_mac_t ));
1138
+ } else
1139
+ {
1140
+ memcpy (attr.value .mac , session.neighborInfo .mac .getMac (), sizeof (sai_mac_t ));
1141
+ }
1119
1142
1120
1143
sai_status_t status = sai_mirror_api->set_mirror_session_attribute (session.sessionId , &attr);
1121
1144
if (status != SAI_STATUS_SUCCESS)
1122
1145
{
1123
1146
SWSS_LOG_ERROR (" Failed to update mirror session %s destination MAC to %s, rv:%d" ,
1124
- name.c_str (), session. neighborInfo .mac . to_string ( ).c_str (), status);
1147
+ name.c_str (), sai_serialize_mac (attr. value .mac ).c_str (), status);
1125
1148
task_process_status handle_status = handleSaiSetStatus (SAI_API_MIRROR, status);
1126
1149
if (handle_status != task_success)
1127
1150
{
@@ -1130,7 +1153,7 @@ bool MirrorOrch::updateSessionDstMac(const string& name, MirrorEntry& session)
1130
1153
}
1131
1154
1132
1155
SWSS_LOG_NOTICE (" Update mirror session %s destination MAC to %s" ,
1133
- name.c_str (), session. neighborInfo .mac . to_string ( ).c_str ());
1156
+ name.c_str (), sai_serialize_mac (attr. value .mac ).c_str ());
1134
1157
1135
1158
setSessionState (name, session, MIRROR_SESSION_DST_MAC_ADDRESS);
1136
1159
@@ -1148,7 +1171,20 @@ bool MirrorOrch::updateSessionDstPort(const string& name, MirrorEntry& session)
1148
1171
1149
1172
sai_attribute_t attr;
1150
1173
attr.id = SAI_MIRROR_SESSION_ATTR_MONITOR_PORT;
1151
- attr.value .oid = session.neighborInfo .portId ;
1174
+ // Set monitor port to recirc port in voq switch.
1175
+ if ((gMySwitchType == " voq" ) && (session.type == MIRROR_SESSION_ERSPAN))
1176
+ {
1177
+ if (!m_portsOrch->getRecircPort (port, " Rec" ))
1178
+ {
1179
+ SWSS_LOG_ERROR (" Failed to get recirc port for mirror session %s" , name.c_str ());
1180
+ return false ;
1181
+ }
1182
+ attr.value .oid = port.m_port_id ;
1183
+ }
1184
+ else
1185
+ {
1186
+ attr.value .oid = session.neighborInfo .portId ;
1187
+ }
1152
1188
1153
1189
sai_status_t status = sai_mirror_api->
1154
1190
set_mirror_session_attribute (session.sessionId , &attr);
0 commit comments