Skip to content

Commit 1107049

Browse files
AntonMyron Sosyak
authored andcommitted
Add lacp_rate config
Signed-off-by: Myron Sosyak <[email protected]>
1 parent bea0b70 commit 1107049

File tree

3 files changed

+65
-6
lines changed

3 files changed

+65
-6
lines changed

cfgmgr/teammgr.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ void TeamMgr::doLagTask(Consumer &consumer)
206206
{
207207
int min_links = 0;
208208
bool fallback = false;
209+
bool fast_rate = false;
209210
string admin_status = DEFAULT_ADMIN_STATUS_STR;
210211
string mtu = DEFAULT_MTU_STR;
211212
string learn_mode;
@@ -247,12 +248,18 @@ void TeamMgr::doLagTask(Consumer &consumer)
247248
{
248249
tpid = fvValue(i);
249250
SWSS_LOG_INFO("Get TPID %s", tpid.c_str());
250-
}
251+
}
252+
else if (fvField(i) == "fast_rate")
253+
{
254+
fast_rate = fvValue(i) == "true";
255+
SWSS_LOG_INFO("Get fast_rate `%s`",
256+
fast_rate ? "true" : "false");
257+
}
251258
}
252259

253260
if (m_lagList.find(alias) == m_lagList.end())
254261
{
255-
if (addLag(alias, min_links, fallback) == task_need_retry)
262+
if (addLag(alias, min_links, fallback, fast_rate) == task_need_retry)
256263
{
257264
it++;
258265
continue;
@@ -496,7 +503,7 @@ bool TeamMgr::setLagLearnMode(const string &alias, const string &learn_mode)
496503
return true;
497504
}
498505

499-
task_process_status TeamMgr::addLag(const string &alias, int min_links, bool fallback)
506+
task_process_status TeamMgr::addLag(const string &alias, int min_links, bool fallback, bool fast_rate)
500507
{
501508
SWSS_LOG_ENTER();
502509

@@ -553,6 +560,11 @@ task_process_status TeamMgr::addLag(const string &alias, int min_links, bool fal
553560
conf << ",\"fallback\":true";
554561
}
555562

563+
if (fast_rate)
564+
{
565+
conf << ",\"fast_rate\":true";
566+
}
567+
556568
conf << "}}'";
557569

558570
SWSS_LOG_INFO("Port channel %s teamd configuration: %s",
@@ -595,7 +607,7 @@ bool TeamMgr::removeLag(const string &alias)
595607
}
596608

597609
// Port-channel names are in the pattern of "PortChannel####"
598-
//
610+
//
599611
// The LACP key could be generated in 3 ways based on the value in config DB:
600612
// 1. "auto" - LACP key is extracted from the port-channel name and is set to be the number at the end of the port-channel name
601613
// We are adding 1 at the beginning to avoid LACP key collisions between similar LACP keys e.g. PortChannel10 and PortChannel010.

cfgmgr/teammgr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class TeamMgr : public Orch
4040
void doLagMemberTask(Consumer &consumer);
4141
void doPortUpdateTask(Consumer &consumer);
4242

43-
task_process_status addLag(const std::string &alias, int min_links, bool fall_back);
43+
task_process_status addLag(const std::string &alias, int min_links, bool fall_back, bool fast_rate);
4444
bool removeLag(const std::string &alias);
4545
task_process_status addLagMember(const std::string &lag, const std::string &member);
4646
bool removeLagMember(const std::string &lag, const std::string &member);

tests/test_portchannel.py

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,53 @@ def test_Portchannel(self, dvs, testlog):
8989
lagms = lagmtbl.getKeys()
9090
assert len(lagms) == 0
9191

92+
def test_Portchannel_fast_rate(self, dvs, testlog):
93+
portchannel_slow = ("PortChannel0003", "Ethernet16", 0)
94+
portchannel_fast = ("PortChannel0004", "Ethernet20", 0)
95+
96+
self.cdb = swsscommon.DBConnector(4, dvs.redis_sock, 0)
97+
98+
# Create PortChannels
99+
tbl = swsscommon.Table(self.cdb, "PORTCHANNEL")
100+
fvs_base = [("admin_status", "up"), ("mtu", "9100"), ("oper_status", "up"), ("lacp_key", "auto")]
101+
102+
fvs_slow = swsscommon.FieldValuePairs(fvs_base + [("fast_rate", "false")])
103+
tbl.set(portchannel_slow[0], fvs_slow)
104+
105+
fvs_fast = swsscommon.FieldValuePairs(fvs_base + [("fast_rate", "true")])
106+
tbl.set(portchannel_fast[0], fvs_fast)
107+
time.sleep(1)
108+
109+
# Add members to PortChannels
110+
tbl = swsscommon.Table(self.cdb, "PORTCHANNEL_MEMBER")
111+
fvs = swsscommon.FieldValuePairs([("NULL", "NULL")])
112+
113+
for portchannel in portchannel_slow, portchannel_fast:
114+
tbl.set(portchannel[0] + "|" + portchannel[1], fvs)
115+
time.sleep(1)
116+
117+
# test fast rate was not set on portchannel_slow
118+
output = dvs.runcmd("teamdctl {} state dump".format(portchannel_slow[0]))[1]
119+
port_state_dump = json.loads(output)
120+
assert not port_state_dump["runner"]["fast_rate"]
121+
122+
# test fast rate was set on portchannel_fast
123+
output = dvs.runcmd("teamdctl {} state dump".format(portchannel_fast[0]))[1]
124+
port_state_dump = json.loads(output)
125+
assert port_state_dump["runner"]["fast_rate"]
126+
127+
# remove PortChannel members
128+
tbl = swsscommon.Table(self.cdb, "PORTCHANNEL_MEMBER")
129+
for portchannel in portchannel_slow, portchannel_fast:
130+
tbl._del(portchannel[0] + "|" + portchannel[1])
131+
time.sleep(1)
132+
133+
# remove PortChannel
134+
tbl = swsscommon.Table(self.cdb, "PORTCHANNEL")
135+
for portchannel in portchannel_slow, portchannel_fast:
136+
tbl._del(portchannel[0])
137+
time.sleep(1)
138+
92139
def test_Portchannel_lacpkey(self, dvs, testlog):
93140
portchannelNamesAuto = [("PortChannel001", "Ethernet0", 1001),
94141
("PortChannel002", "Ethernet4", 1002),
@@ -108,7 +155,7 @@ def test_Portchannel_lacpkey(self, dvs, testlog):
108155

109156
for portchannel in portchannelNamesAuto:
110157
tbl.set(portchannel[0], fvs)
111-
158+
112159
fvs_no_lacp_key = swsscommon.FieldValuePairs(
113160
[("admin_status", "up"), ("mtu", "9100"), ("oper_status", "up")])
114161
tbl.set(portchannelNames[0][0], fvs_no_lacp_key)

0 commit comments

Comments
 (0)