Skip to content

Commit

Permalink
Add feature check
Browse files Browse the repository at this point in the history
Signed-off-by: Ze Gan <ganze718@gmail.com>
  • Loading branch information
Pterosaur committed May 25, 2022
1 parent b26b305 commit 2755b22
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
33 changes: 29 additions & 4 deletions cfgmgr/teammgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ TeamMgr::TeamMgr(DBConnector *confDb, DBConnector *applDb, DBConnector *statDb,
m_appLagTable(applDb, APP_LAG_TABLE_NAME),
m_statePortTable(statDb, STATE_PORT_TABLE_NAME),
m_stateLagTable(statDb, STATE_LAG_TABLE_NAME),
m_stateMACsecPortTable(statDb, STATE_MACSEC_PORT_TABLE_NAME)
m_stateMACsecPortTable(statDb, STATE_MACSEC_PORT_TABLE_NAME),
m_stateFeatureTable(statDb, "FEATURE")
{
SWSS_LOG_ENTER();

Expand Down Expand Up @@ -99,6 +100,27 @@ bool TeamMgr::isLagStateOk(const string &alias)
return true;
}

bool TeamMgr::isMACsecFeatureEnabled()
{
SWSS_LOG_ENTER();

vector<FieldValueTuple> temp;
if (!m_stateFeatureTable.get("macsec", temp))
{
return false;
}

auto opt = swss::fvsGetValue(temp, "state", true);

if (!opt || *opt != "enabled")
{
SWSS_LOG_INFO("MACsec feature isn't enabled");
return false;
}

return true;
}

bool TeamMgr::isMACsecSetted(const std::string &port)
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -348,10 +370,13 @@ void TeamMgr::doLagMemberTask(Consumer &consumer)
continue;
}

if (isMACsecSetted(member) && !isMACsecStateOk(member))
if (isMACsecFeatureEnabled())
{
it++;
continue;
if (isMACsecSetted(member) && !isMACsecStateOk(member))
{
it++;
continue;
}
}

if (addLagMember(lag, member) == task_need_retry)
Expand Down
12 changes: 11 additions & 1 deletion tests/test_macsec.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,8 @@ def test_macsec_attribute_change(self, dvs: conftest.DockerVirtualSwitch, testlo
def test_macsec_with_portchannel(self, dvs: conftest.DockerVirtualSwitch, testlog):

# Set MACsec enabled on Ethernet0
ConfigTable(dvs, "PORT")["Ethernet0"] = {"macsec": "test"}
ConfigTable(dvs, "PORT")["Ethernet0"] = {"macsec" : "test"}
StateDBTable(dvs, "FEATURE")["macsec"] = {"state": "enabled"}

# Setup Port-channel
ConfigTable(dvs, "PORTCHANNEL")["PortChannel001"] = {"admin": "up", "mtu": "9100", "oper_status": "up"}
Expand Down Expand Up @@ -831,6 +832,15 @@ def test_macsec_with_portchannel(self, dvs: conftest.DockerVirtualSwitch, testlo
macsec_port_identifier,
0)

# remove port channel member
del ConfigTable(dvs, "PORTCHANNEL_INTERFACE")["PortChannel001"]
del ConfigTable(dvs, "PORTCHANNEL_INTERFACE")["PortChannel001|40.0.0.0/31"]
del ConfigTable(dvs, "PORTCHANNEL_MEMBER")["PortChannel001|Ethernet0"]

# remove port channel
del ConfigTable(dvs, "PORTCHANNEL")["PortChannel001"]


# Add Dummy always-pass test at end as workaroud
# for issue when Flaky fail on final test it invokes module tear-down
# before retrying
Expand Down

0 comments on commit 2755b22

Please sign in to comment.