Skip to content

Fixing macsecmgrd memory corruption #3611

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 10 additions & 8 deletions cfgmgr/macsecmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,14 +503,11 @@ task_process_status MACsecMgr::enableMACsec(
return task_need_retry;
}

// Create MKA Session object
auto port = m_macsec_ports.emplace(
std::piecewise_construct,
std::make_tuple(port_name),
std::make_tuple());
if (!port.second)
// Handle existing macsec profile
auto port_itr = m_macsec_ports.find(port_name);
if (port_itr != m_macsec_ports.end())
{
if (port.first->second.profile_name == profile_name)
if (port_itr->second.profile_name == profile_name)
{
SWSS_LOG_NOTICE(
"The MACsec profile '%s' on the port '%s' has been loaded",
Expand All @@ -523,7 +520,7 @@ task_process_status MACsecMgr::enableMACsec(
SWSS_LOG_NOTICE(
"The MACsec profile '%s' on the port '%s' "
"will be replaced by the MACsec profile '%s'",
port.first->second.profile_name.c_str(),
port_itr->second.profile_name.c_str(),
port_name.c_str(),
profile_name.c_str());
auto result = disableMACsec(port_name, port_attr);
Expand All @@ -533,6 +530,11 @@ task_process_status MACsecMgr::enableMACsec(
}
}
}
// Create MKA Session object
auto port = m_macsec_ports.emplace(
std::piecewise_construct,
std::make_tuple(port_name),
std::make_tuple());
auto & session = port.first->second;
session.profile_name = profile_name;
ostringstream ostream;
Expand Down
Loading