Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macsecorch]: Fix deleting MACsec bug #2127

Merged
merged 2 commits into from
Feb 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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