Skip to content

Commit 5a651d0

Browse files
authored
[macsecorch]: Fix deleting MACsec bug (sonic-net#2127)
* Fix delete MACsec bug Signed-off-by: Ze Gan <[email protected]> * Fix Signed-off-by: Ze Gan <[email protected]>
1 parent 45bdd19 commit 5a651d0

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

orchagent/macsecorch.cpp

+18-10
Original file line numberDiff line numberDiff line change
@@ -1277,16 +1277,18 @@ bool MACsecOrch::updateMACsecSCs(MACsecPort &macsec_port, std::function<bool(MAC
12771277
{
12781278
SWSS_LOG_ENTER();
12791279

1280-
for (auto &sc : macsec_port.m_egress_scs)
1280+
auto sc = macsec_port.m_egress_scs.begin();
1281+
while (sc != macsec_port.m_egress_scs.end())
12811282
{
1282-
if (!action(sc.second))
1283+
if (!action((sc++)->second))
12831284
{
12841285
return false;
12851286
}
12861287
}
1287-
for (auto &sc : macsec_port.m_ingress_scs)
1288+
sc = macsec_port.m_ingress_scs.begin();
1289+
while (sc != macsec_port.m_ingress_scs.end())
12881290
{
1289-
if (!action(sc.second))
1291+
if (!action((sc++)->second))
12901292
{
12911293
return false;
12921294
}
@@ -1307,17 +1309,21 @@ bool MACsecOrch::deleteMACsecPort(
13071309

13081310
bool result = true;
13091311

1310-
for (auto &sc : macsec_port.m_egress_scs)
1312+
auto sc = macsec_port.m_egress_scs.begin();
1313+
while (sc != macsec_port.m_egress_scs.end())
13111314
{
1312-
const std::string port_sci = swss::join(':', port_name, sc.first);
1315+
const std::string port_sci = swss::join(':', port_name, sc->first);
1316+
sc ++;
13131317
if (deleteMACsecSC(port_sci, SAI_MACSEC_DIRECTION_EGRESS) != task_success)
13141318
{
13151319
result &= false;
13161320
}
13171321
}
1318-
for (auto &sc : macsec_port.m_ingress_scs)
1322+
sc = macsec_port.m_ingress_scs.begin();
1323+
while (sc != macsec_port.m_ingress_scs.end())
13191324
{
1320-
const std::string port_sci = swss::join(':', port_name, sc.first);
1325+
const std::string port_sci = swss::join(':', port_name, sc->first);
1326+
sc ++;
13211327
if (deleteMACsecSC(port_sci, SAI_MACSEC_DIRECTION_INGRESS) != task_success)
13221328
{
13231329
result &= false;
@@ -1705,9 +1711,11 @@ task_process_status MACsecOrch::deleteMACsecSC(
17051711

17061712
auto result = task_success;
17071713

1708-
for (auto &sa : ctx.get_macsec_sc()->m_sa_ids)
1714+
auto sa = ctx.get_macsec_sc()->m_sa_ids.begin();
1715+
while (sa != ctx.get_macsec_sc()->m_sa_ids.end())
17091716
{
1710-
const std::string port_sci_an = swss::join(':', port_sci, sa.first);
1717+
const std::string port_sci_an = swss::join(':', port_sci, sa->first);
1718+
sa ++;
17111719
deleteMACsecSA(port_sci_an, direction);
17121720
}
17131721

0 commit comments

Comments
 (0)