Skip to content

Commit c6e54ca

Browse files
mramezani95mlok-nokia
authored andcommitted
[mirror] erspan ipv6 underlay (see PR sonic-net#1817) (sonic-net#3317)
* Applied changes from PR sonic-net#1817 Why I did it Unlock erspan capability on td3 and beyond that supports erspan ipv6 encap. What I did Extend test_MirrorAddSetRemove, test_MirrorToVlanAddRemove, test_MirrorToLagAddRemove, test_MirrorDestMoveVlan, test_MirrorDestMoveLag to vs test erspan ipv6 encap On td3
1 parent 5f204ca commit c6e54ca

2 files changed

Lines changed: 179 additions & 97 deletions

File tree

orchagent/mirrororch.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434

3535
#define MIRROR_SESSION_DEFAULT_VLAN_PRI 0
3636
#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
3839
#define MIRROR_SESSION_DSCP_SHIFT 2
3940
#define MIRROR_SESSION_DSCP_MIN 0
4041
#define MIRROR_SESSION_DSCP_MAX 63
@@ -380,6 +381,9 @@ task_process_status MirrorOrch::createEntry(const string& key, const vector<Fiel
380381
{
381382
SWSS_LOG_ENTER();
382383

384+
bool src_ip_initialized = false;
385+
bool dst_ip_initialized = false;
386+
383387
auto session = m_syncdMirrors.find(key);
384388
if (session != m_syncdMirrors.end())
385389
{
@@ -396,20 +400,12 @@ task_process_status MirrorOrch::createEntry(const string& key, const vector<Fiel
396400
if (fvField(i) == MIRROR_SESSION_SRC_IP)
397401
{
398402
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;
404404
}
405405
else if (fvField(i) == MIRROR_SESSION_DST_IP)
406406
{
407407
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;
413409
}
414410
else if (fvField(i) == MIRROR_SESSION_GRE_TYPE)
415411
{
@@ -493,6 +489,12 @@ task_process_status MirrorOrch::createEntry(const string& key, const vector<Fiel
493489
return task_process_status::task_failed;
494490
}
495491
}
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+
}
496498

497499
if (!isHwResourcesAvailable())
498500
{
@@ -992,7 +994,7 @@ bool MirrorOrch::activateSession(const string& name, MirrorEntry& session)
992994
attrs.push_back(attr);
993995

994996
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;
996998
attrs.push_back(attr);
997999

9981000
// TOS value format is the following:
@@ -1341,7 +1343,7 @@ void MirrorOrch::updateNextHop(const NextHopUpdate& update)
13411343
else
13421344
{
13431345
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);
13451347
}
13461348

13471349
// Update State DB Nexthop

0 commit comments

Comments
 (0)