Skip to content

Commit

Permalink
Applied changed in PR sonic-net#1817
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Oct 8, 2024
1 parent 8b99543 commit 57034ae
Show file tree
Hide file tree
Showing 2 changed files with 158 additions and 97 deletions.
23 changes: 10 additions & 13 deletions orchagent/mirrororch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@

#define MIRROR_SESSION_DEFAULT_VLAN_PRI 0
#define MIRROR_SESSION_DEFAULT_VLAN_CFI 0
#define MIRROR_SESSION_DEFAULT_IP_HDR_VER 4
#define MIRROR_SESSION_IP_HDR_VER_4 4
#define MIRROR_SESSION_IP_HDR_VER_6 6
#define MIRROR_SESSION_DSCP_SHIFT 2
#define MIRROR_SESSION_DSCP_MIN 0
#define MIRROR_SESSION_DSCP_MAX 63
Expand Down Expand Up @@ -396,20 +397,10 @@ task_process_status MirrorOrch::createEntry(const string& key, const vector<Fiel
if (fvField(i) == MIRROR_SESSION_SRC_IP)
{
entry.srcIp = fvValue(i);
if (!entry.srcIp.isV4())
{
SWSS_LOG_ERROR("Unsupported version of sessions %s source IP address", key.c_str());
return task_process_status::task_invalid_entry;
}
}
else if (fvField(i) == MIRROR_SESSION_DST_IP)
{
entry.dstIp = fvValue(i);
if (!entry.dstIp.isV4())
{
SWSS_LOG_ERROR("Unsupported version of sessions %s destination IP address", key.c_str());
return task_process_status::task_invalid_entry;
}
}
else if (fvField(i) == MIRROR_SESSION_GRE_TYPE)
{
Expand Down Expand Up @@ -493,6 +484,12 @@ task_process_status MirrorOrch::createEntry(const string& key, const vector<Fiel
return task_process_status::task_failed;
}
}
// Entry validation as a whole
if (entry.srcIp.getIp().family != entry.dstIp.getIp().family)
{
SWSS_LOG_ERROR("Address family of source and destination IPs is different");
return task_process_status::task_invalid_entry;
}

if (!isHwResourcesAvailable())
{
Expand Down Expand Up @@ -992,7 +989,7 @@ bool MirrorOrch::activateSession(const string& name, MirrorEntry& session)
attrs.push_back(attr);

attr.id = SAI_MIRROR_SESSION_ATTR_IPHDR_VERSION;
attr.value.u8 = MIRROR_SESSION_DEFAULT_IP_HDR_VER;
attr.value.u8 = session.dstIp.isV4() ? MIRROR_SESSION_IP_HDR_VER_4 : MIRROR_SESSION_IP_HDR_VER_6;
attrs.push_back(attr);

// TOS value format is the following:
Expand Down Expand Up @@ -1341,7 +1338,7 @@ void MirrorOrch::updateNextHop(const NextHopUpdate& update)
else
{
string alias = "";
session.nexthopInfo.nexthop = NextHopKey("0.0.0.0", alias);
session.nexthopInfo.nexthop = session.dstIp.isV4() ? NextHopKey("0.0.0.0", alias) : NextHopKey("::", alias);
}

// Update State DB Nexthop
Expand Down
Loading

0 comments on commit 57034ae

Please sign in to comment.