Skip to content

Commit

Permalink
during warm-reboot teamd need to use same system-id before warm-reboot
Browse files Browse the repository at this point in the history
Signed-off-by: shine.chen <[email protected]>
  • Loading branch information
shine.chen committed Jul 30, 2019
1 parent 7382995 commit 41d81b7
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions cfgmgr/teammgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "portmgr.h"

#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <thread>

Expand Down Expand Up @@ -373,8 +375,33 @@ task_process_status TeamMgr::addLag(const string &alias, int min_links, bool fal
string res;

stringstream conf;

const string dump_path = "/var/warmboot/teamd/";
MacAddress mac_boot = m_mac;
/*set portchannel mac same with mac before warmStart ,when warmStart there is a file written by teamd*/
ifstream aliasfile(dump_path + alias);
if (WarmStart::isWarmStart() && aliasfile.is_open())
{
# define PARTNER_SYSTEM_ID_OFFSET 40
string line;

while (getline(aliasfile, line))
{
ifstream memberfile(dump_path + line, ios::binary);
uint8_t mac_temp[ETHER_ADDR_LEN];

if (!memberfile.is_open())
continue;

memberfile.seekg(PARTNER_SYSTEM_ID_OFFSET, std::ios::beg);
memberfile.read((char *)mac_temp, ETHER_ADDR_LEN);
mac_boot = MacAddress(mac_temp);
break;
}
}

conf << "'{\"device\":\"" << alias << "\","
<< "\"hwaddr\":\"" << m_mac.to_string() << "\","
<< "\"hwaddr\":\"" << mac_boot.to_string() << "\","
<< "\"runner\":{"
<< "\"active\":true,"
<< "\"name\":\"lacp\"";
Expand All @@ -395,7 +422,6 @@ task_process_status TeamMgr::addLag(const string &alias, int min_links, bool fal
alias.c_str(), conf.str().c_str());

string warmstart_flag = WarmStart::isWarmStart() ? " -w -o " : " -r ";
const string dump_path = "/var/warmboot/teamd/";

cmd << TEAMD_CMD
<< warmstart_flag
Expand Down

0 comments on commit 41d81b7

Please sign in to comment.