@@ -50,6 +50,7 @@ extern sai_port_api_t *sai_port_api;
50
50
extern sai_object_id_t gSwitchId ;
51
51
extern PortsOrch* gPortsOrch ;
52
52
extern string gMySwitchType ;
53
+ extern IntfsOrch *gIntfsOrch ;
53
54
54
55
using namespace std ::rel_ops;
55
56
@@ -583,13 +584,31 @@ void MirrorOrch::setSessionState(const string& name, const MirrorEntry& session,
583
584
if (attr.empty () || attr == MIRROR_SESSION_MONITOR_PORT)
584
585
{
585
586
Port port;
586
- m_portsOrch->getPort (session.neighborInfo .portId , port);
587
+ if ((gMySwitchType == " voq" ) && (session.type == MIRROR_SESSION_ERSPAN) &&
588
+ (gIntfsOrch ->isRemoteSystemPortIntf (session.neighborInfo .neighbor .alias )))
589
+ {
590
+ if (!m_portsOrch->getRecircPort (port, " Rec" ))
591
+ {
592
+ SWSS_LOG_ERROR (" Failed to get recirc prot mirror session %s" , name.c_str ());
593
+ return ;
594
+ }
595
+ }
596
+ else
597
+ {
598
+ m_portsOrch->getPort (session.neighborInfo .portId , port);
599
+ }
587
600
fvVector.emplace_back (MIRROR_SESSION_MONITOR_PORT, port.m_alias );
588
601
}
589
602
590
603
if (attr.empty () || attr == MIRROR_SESSION_DST_MAC_ADDRESS)
591
604
{
592
- value = session.neighborInfo .mac .to_string ();
605
+ if ((gMySwitchType == " voq" ) && (session.type == MIRROR_SESSION_ERSPAN))
606
+ {
607
+ value = gMacAddress .to_string ();
608
+ } else
609
+ {
610
+ value = session.neighborInfo .mac .to_string ();
611
+ }
593
612
fvVector.emplace_back (MIRROR_SESSION_DST_MAC_ADDRESS, value);
594
613
}
595
614
@@ -999,9 +1018,9 @@ bool MirrorOrch::activateSession(const string& name, MirrorEntry& session)
999
1018
1000
1019
attr.id = SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS;
1001
1020
// Use router mac as mirror dst mac in voq switch.
1002
- if (gMySwitchType == " voq" )
1021
+ if (( gMySwitchType == " voq" ) && (session. type == MIRROR_SESSION_ERSPAN) )
1003
1022
{
1004
- memcpy (attr.value .mac , gMacAddress .getMac (), sizeof (sai_mac_t ));
1023
+ memcpy (attr.value .mac , gMacAddress .getMac (), sizeof (sai_mac_t ));
1005
1024
}
1006
1025
else
1007
1026
{
@@ -1115,19 +1134,19 @@ bool MirrorOrch::updateSessionDstMac(const string& name, MirrorEntry& session)
1115
1134
1116
1135
sai_attribute_t attr;
1117
1136
attr.id = SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS;
1118
- if (gMySwitchType == " voq" )
1137
+ if (( gMySwitchType == " voq" ) && (session. type == MIRROR_SESSION_ERSPAN) )
1119
1138
{
1120
- memcpy (attr.value .mac , gMacAddress .getMac (), sizeof (sai_mac_t ));
1139
+ memcpy (attr.value .mac , gMacAddress .getMac (), sizeof (sai_mac_t ));
1121
1140
} else
1122
1141
{
1123
- memcpy (attr.value .mac , session.neighborInfo .mac .getMac (), sizeof (sai_mac_t ));
1142
+ memcpy (attr.value .mac , session.neighborInfo .mac .getMac (), sizeof (sai_mac_t ));
1124
1143
}
1125
1144
1126
1145
sai_status_t status = sai_mirror_api->set_mirror_session_attribute (session.sessionId , &attr);
1127
1146
if (status != SAI_STATUS_SUCCESS)
1128
1147
{
1129
1148
SWSS_LOG_ERROR (" Failed to update mirror session %s destination MAC to %s, rv:%d" ,
1130
- name.c_str (), session. neighborInfo .mac . to_string ( ).c_str (), status);
1149
+ name.c_str (), sai_serialize_mac (attr. value .mac ).c_str (), status);
1131
1150
task_process_status handle_status = handleSaiSetStatus (SAI_API_MIRROR, status);
1132
1151
if (handle_status != task_success)
1133
1152
{
@@ -1136,7 +1155,7 @@ bool MirrorOrch::updateSessionDstMac(const string& name, MirrorEntry& session)
1136
1155
}
1137
1156
1138
1157
SWSS_LOG_NOTICE (" Update mirror session %s destination MAC to %s" ,
1139
- name.c_str (), session. neighborInfo .mac . to_string ( ).c_str ());
1158
+ name.c_str (), sai_serialize_mac (attr. value .mac ).c_str ());
1140
1159
1141
1160
setSessionState (name, session, MIRROR_SESSION_DST_MAC_ADDRESS);
1142
1161
@@ -1154,27 +1173,19 @@ bool MirrorOrch::updateSessionDstPort(const string& name, MirrorEntry& session)
1154
1173
1155
1174
sai_attribute_t attr;
1156
1175
attr.id = SAI_MIRROR_SESSION_ATTR_MONITOR_PORT;
1157
- if (session.type == MIRROR_SESSION_SPAN)
1176
+ // Set monitor port to recirc port in voq switch.
1177
+ if ((gMySwitchType == " voq" ) && (session.type == MIRROR_SESSION_ERSPAN))
1158
1178
{
1159
- attr.value .oid = session.neighborInfo .portId ;
1179
+ if (!m_portsOrch->getRecircPort (port, " Rec" ))
1180
+ {
1181
+ SWSS_LOG_ERROR (" Failed to get recirc prot mirror session %s" , name.c_str ());
1182
+ return false ;
1183
+ }
1184
+ attr.value .oid = port.m_port_id ;
1160
1185
}
1161
1186
else
1162
1187
{
1163
- // Set monitor port to recirc port in voq switch.
1164
- if (gMySwitchType == " voq" )
1165
- {
1166
- Port recirc_port;
1167
- if (!m_portsOrch->getRecircPort (recirc_port, " Rec" ))
1168
- {
1169
- SWSS_LOG_ERROR (" Failed to get recirc prot" );
1170
- return false ;
1171
- }
1172
- attr.value .oid = recirc_port.m_port_id ;
1173
- }
1174
- else
1175
- {
1176
- attr.value .oid = session.neighborInfo .portId ;
1177
- }
1188
+ attr.value .oid = session.neighborInfo .portId ;
1178
1189
}
1179
1190
1180
1191
sai_status_t status = sai_mirror_api->
0 commit comments