34
34
35
35
#define MIRROR_SESSION_DEFAULT_VLAN_PRI 0
36
36
#define MIRROR_SESSION_DEFAULT_VLAN_CFI 0
37
- #define MIRROR_SESSION_DEFAULT_IP_HDR_VER 4
37
+ #define MIRROR_SESSION_IP_HDR_VER_4 4
38
+ #define MIRROR_SESSION_IP_HDR_VER_6 6
38
39
#define MIRROR_SESSION_DSCP_SHIFT 2
39
40
#define MIRROR_SESSION_DSCP_MIN 0
40
41
#define MIRROR_SESSION_DSCP_MAX 63
@@ -380,6 +381,9 @@ task_process_status MirrorOrch::createEntry(const string& key, const vector<Fiel
380
381
{
381
382
SWSS_LOG_ENTER ();
382
383
384
+ bool src_ip_initialized = false ;
385
+ bool dst_ip_initialized = false ;
386
+
383
387
auto session = m_syncdMirrors.find (key);
384
388
if (session != m_syncdMirrors.end ())
385
389
{
@@ -396,20 +400,12 @@ task_process_status MirrorOrch::createEntry(const string& key, const vector<Fiel
396
400
if (fvField (i) == MIRROR_SESSION_SRC_IP)
397
401
{
398
402
entry.srcIp = fvValue (i);
399
- if (!entry.srcIp .isV4 ())
400
- {
401
- SWSS_LOG_ERROR (" Unsupported version of sessions %s source IP address" , key.c_str ());
402
- return task_process_status::task_invalid_entry;
403
- }
403
+ src_ip_initialized = true ;
404
404
}
405
405
else if (fvField (i) == MIRROR_SESSION_DST_IP)
406
406
{
407
407
entry.dstIp = fvValue (i);
408
- if (!entry.dstIp .isV4 ())
409
- {
410
- SWSS_LOG_ERROR (" Unsupported version of sessions %s destination IP address" , key.c_str ());
411
- return task_process_status::task_invalid_entry;
412
- }
408
+ dst_ip_initialized = true ;
413
409
}
414
410
else if (fvField (i) == MIRROR_SESSION_GRE_TYPE)
415
411
{
@@ -493,6 +489,12 @@ task_process_status MirrorOrch::createEntry(const string& key, const vector<Fiel
493
489
return task_process_status::task_failed;
494
490
}
495
491
}
492
+ // Entry validation as a whole
493
+ if (src_ip_initialized && dst_ip_initialized && entry.srcIp .getIp ().family != entry.dstIp .getIp ().family )
494
+ {
495
+ SWSS_LOG_ERROR (" Address family of source and destination IPs is different" );
496
+ return task_process_status::task_invalid_entry;
497
+ }
496
498
497
499
if (!isHwResourcesAvailable ())
498
500
{
@@ -992,7 +994,7 @@ bool MirrorOrch::activateSession(const string& name, MirrorEntry& session)
992
994
attrs.push_back (attr);
993
995
994
996
attr.id = SAI_MIRROR_SESSION_ATTR_IPHDR_VERSION;
995
- attr.value .u8 = MIRROR_SESSION_DEFAULT_IP_HDR_VER ;
997
+ attr.value .u8 = session. dstIp . isV4 () ? MIRROR_SESSION_IP_HDR_VER_4 : MIRROR_SESSION_IP_HDR_VER_6 ;
996
998
attrs.push_back (attr);
997
999
998
1000
// TOS value format is the following:
@@ -1341,7 +1343,7 @@ void MirrorOrch::updateNextHop(const NextHopUpdate& update)
1341
1343
else
1342
1344
{
1343
1345
string alias = " " ;
1344
- session.nexthopInfo .nexthop = NextHopKey (" 0.0.0.0" , alias);
1346
+ session.nexthopInfo .nexthop = session. dstIp . isV4 () ? NextHopKey (" 0.0.0.0" , alias) : NextHopKey ( " :: " , alias);
1345
1347
}
1346
1348
1347
1349
// Update State DB Nexthop
0 commit comments