Skip to content

Commit

Permalink
[everflow]: Fix minor everflow issues. (sonic-net#215)
Browse files Browse the repository at this point in the history
- Fix issue with session update observed when more than one
  session exist with destination IP address from the same subnet.

- Fix issue with deletion of ACL rules attached to everflow session
  in inactive state.
  • Loading branch information
oleksandrivantsiv authored and Shuotian Cheng committed May 11, 2017
1 parent 3c1dbd8 commit 427ffc5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
21 changes: 19 additions & 2 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,13 @@ bool AclRuleMirror::create()
throw runtime_error("Failed to get mirror session state");
}

// Increase session reference count regardless of state to deny
// attempt to remove mirror session with attached ACL rules.
if (!m_pMirrorOrch->increaseRefCount(m_sessionName))
{
throw runtime_error("Failed to increase mirror session reference count");
}

if (!state)
{
return true;
Expand All @@ -607,19 +614,29 @@ bool AclRuleMirror::create()

m_state = true;

return m_pMirrorOrch->increaseRefCount(m_sessionName);
return true;
}

bool AclRuleMirror::remove()
{
if (!m_pMirrorOrch->decreaseRefCount(m_sessionName))
{
throw runtime_error("Failed to decrease mirror session reference count");
}

if (!m_state)
{
return true;
}

if (!AclRule::remove())
{
return false;
}

m_state = false;

return m_pMirrorOrch->decreaseRefCount(m_sessionName);
return true;
}

void AclRuleMirror::update(SubjectType type, void *cntx)
Expand Down
20 changes: 10 additions & 10 deletions orchagent/mirrororch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ void MirrorOrch::updateNextHop(const NextHopUpdate& update)
// and current next hop is still in next hop group - do nothing.
if (session.nexthopInfo.prefix == update.prefix && update.nexthopGroup.getIpAddresses().count(session.nexthopInfo.nexthop))
{
return;
continue;
}
}

Expand All @@ -582,26 +582,26 @@ void MirrorOrch::updateNextHop(const NextHopUpdate& update)
{
deactivateSession(name, session);
}
return;
continue;
}

if (session.status)
{
if (!updateSessionDstMac(name, session))
{
return;
continue;
}

if (!updateSessionDstPort(name, session))
{
return;
continue;
}
}
else
{
if (!activateSession(name, session))
{
return;
continue;
}
}
}
Expand Down Expand Up @@ -638,19 +638,19 @@ void MirrorOrch::updateNeighbor(const NeighborUpdate& update)
{
deactivateSession(name, session);
}
return;
continue;
}

if (session.status)
{
if (!updateSessionDstMac(name, session))
{
return;
continue;
}

if (!updateSessionDstPort(name, session))
{
return;
continue;
}
}
else
Expand Down Expand Up @@ -748,7 +748,7 @@ void MirrorOrch::updateLagMember(const LagMemberUpdate& update)
// We interesting only in first LAG member
if (update.lag.m_members.size() > 1)
{
return;
continue;
}

const string& memberName = *update.lag.m_members.begin();
Expand All @@ -771,7 +771,7 @@ void MirrorOrch::updateLagMember(const LagMemberUpdate& update)
deactivateSession(name, session);
session.neighborInfo.portId = SAI_OBJECT_TYPE_NULL;

return;
continue;
}

// Get another LAG member and update session
Expand Down

0 comments on commit 427ffc5

Please sign in to comment.