Skip to content

Commit

Permalink
[macsecorch]: Fix deleting MACsec bug (sonic-net#2127)
Browse files Browse the repository at this point in the history
* Fix delete MACsec bug

Signed-off-by: Ze Gan <[email protected]>

* Fix

Signed-off-by: Ze Gan <[email protected]>
  • Loading branch information
Pterosaur authored Feb 18, 2022
1 parent 45bdd19 commit 5a651d0
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions orchagent/macsecorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1277,16 +1277,18 @@ bool MACsecOrch::updateMACsecSCs(MACsecPort &macsec_port, std::function<bool(MAC
{
SWSS_LOG_ENTER();

for (auto &sc : macsec_port.m_egress_scs)
auto sc = macsec_port.m_egress_scs.begin();
while (sc != macsec_port.m_egress_scs.end())
{
if (!action(sc.second))
if (!action((sc++)->second))
{
return false;
}
}
for (auto &sc : macsec_port.m_ingress_scs)
sc = macsec_port.m_ingress_scs.begin();
while (sc != macsec_port.m_ingress_scs.end())
{
if (!action(sc.second))
if (!action((sc++)->second))
{
return false;
}
Expand All @@ -1307,17 +1309,21 @@ bool MACsecOrch::deleteMACsecPort(

bool result = true;

for (auto &sc : macsec_port.m_egress_scs)
auto sc = macsec_port.m_egress_scs.begin();
while (sc != macsec_port.m_egress_scs.end())
{
const std::string port_sci = swss::join(':', port_name, sc.first);
const std::string port_sci = swss::join(':', port_name, sc->first);
sc ++;
if (deleteMACsecSC(port_sci, SAI_MACSEC_DIRECTION_EGRESS) != task_success)
{
result &= false;
}
}
for (auto &sc : macsec_port.m_ingress_scs)
sc = macsec_port.m_ingress_scs.begin();
while (sc != macsec_port.m_ingress_scs.end())
{
const std::string port_sci = swss::join(':', port_name, sc.first);
const std::string port_sci = swss::join(':', port_name, sc->first);
sc ++;
if (deleteMACsecSC(port_sci, SAI_MACSEC_DIRECTION_INGRESS) != task_success)
{
result &= false;
Expand Down Expand Up @@ -1705,9 +1711,11 @@ task_process_status MACsecOrch::deleteMACsecSC(

auto result = task_success;

for (auto &sa : ctx.get_macsec_sc()->m_sa_ids)
auto sa = ctx.get_macsec_sc()->m_sa_ids.begin();
while (sa != ctx.get_macsec_sc()->m_sa_ids.end())
{
const std::string port_sci_an = swss::join(':', port_sci, sa.first);
const std::string port_sci_an = swss::join(':', port_sci, sa->first);
sa ++;
deleteMACsecSA(port_sci_an, direction);
}

Expand Down

0 comments on commit 5a651d0

Please sign in to comment.