Skip to content
Merged
Show file tree
Hide file tree
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
42 changes: 33 additions & 9 deletions cfgmgr/teammgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,18 @@ TeamMgr::TeamMgr(DBConnector *confDb, DBConnector *applDb, DBConnector *statDb,
m_mac = MacAddress(it->second);

vector<FieldValueTuple> modeFvs;
std::string m_teamdMultiProcMode;
std::string m_teamdMode;
m_cfgModeTable.get("GLOBAL", modeFvs);
auto modeIt = find_if(modeFvs.begin(), modeFvs.end(), [](const FieldValueTuple &fv) {
return fv.first == "mode";
});

if (modeIt != modeFvs.end())
{
m_teamdMultiProcMode = modeIt->second;
m_teamdMode = modeIt->second;
}

if (m_teamdMultiProcMode == "multi-process")
{
m_teamdUnifiedProcMode = false;
SWSS_LOG_INFO("start multi process with teamd...");
}
else
if (m_teamdMode == "unified-process")
{
m_teamdUnifiedProcMode = true;
const string dump_path = "/var/warmboot/teamd/";
Expand All @@ -105,6 +100,11 @@ TeamMgr::TeamMgr(DBConnector *confDb, DBConnector *applDb, DBConnector *statDb,

SWSS_LOG_INFO("start single process with teamd...");
}
else
{
m_teamdUnifiedProcMode = false;
SWSS_LOG_INFO("start multi process with teamd...");
}

}

Expand Down Expand Up @@ -265,12 +265,22 @@ void TeamMgr::cleanTeamProcesses()
{
std::string alias = "teamd-unified";
pid_t pid;
stringstream cmd;
string res;
// Sleep for 10 milliseconds so as to not overwhelm the netlink
// socket buffers with events about interfaces going down
std::this_thread::sleep_for(std::chrono::milliseconds(10));

try
{
for (const auto& PC: m_lagList)
{
cmd << "unlink /run/teamd/" << PC << ".sock";
if (exec(cmd.str(), res) != 0)
{
SWSS_LOG_INFO("Failed to delete symlink for %s", PC.c_str());
}
}
ifstream pidFile("/var/run/teamd/" + alias + ".pid");
if (pidFile.is_open())
{
Expand Down Expand Up @@ -813,7 +823,13 @@ task_process_status TeamMgr::addLag(const string &alias, int min_links, bool fal
{
jsonConf = jsonConf.substr(1, jsonConf.size() - 2);
}
sendIpcToTeamd("PortChannelAdd", {alias, jsonConf});
sendIpcToTeamd("PortChannelAdd", {alias, jsonConf});
cmd << "ln -s /run/teamd/teamd-unified.sock /run/teamd/" << alias << ".sock";
if (exec(cmd.str(), res) != 0)
{
SWSS_LOG_INFO("Failed to create symbolic link for %s", alias.c_str());
return task_need_retry;
}
}
else
{
Expand All @@ -840,10 +856,18 @@ task_process_status TeamMgr::addLag(const string &alias, int min_links, bool fal
bool TeamMgr::removeLag(const string &alias)
{
SWSS_LOG_ENTER();
stringstream cmd;
string res;

if (m_teamdUnifiedProcMode)
{
sendIpcToTeamd("PortChannelRemove", { alias });
cmd << "unlink /run/teamd/" << alias << ".sock";
if (exec(cmd.str(), res) != 0)
{
SWSS_LOG_INFO("Failed to delete symlink for %s", alias.c_str());
return false;
}
}
else
{
Expand Down
6 changes: 2 additions & 4 deletions tests/mock_tests/teammgrd/teammgr_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ namespace teammgr_ut
std::vector<swss::FieldValueTuple> vec;
vec.emplace_back("mac", "01:23:45:67:89:ab");
metadata_table.set("localhost", vec);
swss::Table cfg_mode_table = swss::Table(m_config_db.get(), CFG_TEAMD_MODE_TABLE_NAME);
cfg_mode_table.set("GLOBAL",{ {"mode","multi-process"} });

TableConnector conf_lag_table(m_config_db.get(), CFG_LAG_TABLE_NAME);
TableConnector conf_lag_member_table(m_config_db.get(), CFG_LAG_MEMBER_TABLE_NAME);
Expand Down Expand Up @@ -285,9 +283,9 @@ namespace teammgr_ut

TEST_F(TeamMgrTest, testIpcSendRetry)
{
swss::Table cfg_mode_table(m_config_db.get(), CFG_TEAMD_MODE_TABLE_NAME);
swss::Table cfg_mode_table = swss::Table(m_config_db.get(), CFG_TEAMD_MODE_TABLE_NAME);
cfg_mode_table.set("GLOBAL",{ {"mode","unified-process"} });
swss::Table cfg_lag_table(m_config_db.get(), CFG_LAG_TABLE_NAME);
cfg_mode_table.del("GLOBAL");
cfg_lag_table.set("PortChannel123", {
{"admin_status", "up"},
{"mtu", "9100"},
Expand Down
12 changes: 6 additions & 6 deletions tlm_teamd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,25 @@ int main()
swss::Table table(&config_db, "TEAMD");
std::vector<swss::FieldValueTuple> values;

std::string m_teamdMultiProcMode = "unified";
std::string m_teamdMode = "multi-process";
bool key_exists = table.get("GLOBAL", values);

if (key_exists && !values.empty())
{
for (const auto& fv : values)
{
if (fv.first == "mode" && fv.second == "multi-process")
if (fv.first == "mode")

{
m_teamdMultiProcMode = fv.second;
m_teamdMode = fv.second;
break;
}
}
}
if (m_teamdMultiProcMode == "multi-process") {
teamdctl_mgr.m_teamdUnifiedProcMode = false;
} else {
if (m_teamdMode == "unified-process") {
teamdctl_mgr.m_teamdUnifiedProcMode = true;
} else {
teamdctl_mgr.m_teamdUnifiedProcMode = false;
}


Expand Down