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

[teammgrd]during warm-reboot teamd need to recover system-id from saved lacp-pdu #1003

Merged
merged 2 commits into from
Dec 1, 2019
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
32 changes: 30 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,35 @@ 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 and there
// is a file written by teamd.
ifstream aliasfile(dump_path + alias);
if (WarmStart::isWarmStart() && aliasfile.is_open())
{
const int 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(reinterpret_cast<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 +424,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