Skip to content

Commit

Permalink
Merge branch 'master' into loopback_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
royyi8 committed Mar 29, 2024
2 parents 9a6f44e + c96a2f8 commit d596a97
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 74 deletions.
10 changes: 6 additions & 4 deletions cfgmgr/coppmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ static set<string> g_copp_init_set;

void CoppMgr::parseInitFile(void)
{
std::ifstream ifs(COPP_INIT_FILE);
std::ifstream ifs(m_coppCfgfile);

if (ifs.fail())
{
SWSS_LOG_ERROR("COPP init file %s not found", COPP_INIT_FILE);
SWSS_LOG_ERROR("COPP init file %s not found", m_coppCfgfile.c_str());
return;
}
json j = json::parse(ifs);
Expand Down Expand Up @@ -293,15 +294,16 @@ bool CoppMgr::isDupEntry(const std::string &key, std::vector<FieldValueTuple> &f
return true;
}

CoppMgr::CoppMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector<string> &tableNames) :
CoppMgr::CoppMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector<string> &tableNames, const string copp_init_file) :
Orch(cfgDb, tableNames),
m_cfgCoppTrapTable(cfgDb, CFG_COPP_TRAP_TABLE_NAME),
m_cfgCoppGroupTable(cfgDb, CFG_COPP_GROUP_TABLE_NAME),
m_cfgFeatureTable(cfgDb, CFG_FEATURE_TABLE_NAME),
m_appCoppTable(appDb, APP_COPP_TABLE_NAME),
m_stateCoppTrapTable(stateDb, STATE_COPP_TRAP_TABLE_NAME),
m_stateCoppGroupTable(stateDb, STATE_COPP_GROUP_TABLE_NAME),
m_coppTable(appDb, APP_COPP_TABLE_NAME)
m_coppTable(appDb, APP_COPP_TABLE_NAME),
m_coppCfgfile(copp_init_file)
{
SWSS_LOG_ENTER();
parseInitFile();
Expand Down
3 changes: 2 additions & 1 deletion cfgmgr/coppmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class CoppMgr : public Orch
{
public:
CoppMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb,
const std::vector<std::string> &tableNames);
const std::vector<std::string> &tableNames, const std::string copp_init_file = COPP_INIT_FILE);

using Orch::doTask;
private:
Expand All @@ -75,6 +75,7 @@ class CoppMgr : public Orch
CoppCfg m_coppGroupInitCfg;
CoppCfg m_coppTrapInitCfg;
CoppCfg m_featuresCfgTable;
std::string m_coppCfgfile;


void doTask(Consumer &consumer);
Expand Down
2 changes: 0 additions & 2 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3223,7 +3223,6 @@ void AclOrch::initDefaultTableTypes()
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT))
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT))
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_TCP_FLAGS))
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_IN_PORTS))
.build()
);

Expand All @@ -3241,7 +3240,6 @@ void AclOrch::initDefaultTableTypes()
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT))
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT))
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_TCP_FLAGS))
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_IN_PORTS))
.build()
);

Expand Down
3 changes: 2 additions & 1 deletion tests/mock_tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ tests_SOURCES = aclorch_ut.cpp \
$(top_srcdir)/orchagent/dash/dashvnetorch.cpp \
$(top_srcdir)/cfgmgr/buffermgrdyn.cpp \
$(top_srcdir)/warmrestart/warmRestartAssist.cpp \
$(top_srcdir)/orchagent/dash/pbutils.cpp
$(top_srcdir)/orchagent/dash/pbutils.cpp \
$(top_srcdir)/cfgmgr/coppmgr.cpp

tests_SOURCES += $(FLEX_CTR_DIR)/flex_counter_manager.cpp $(FLEX_CTR_DIR)/flex_counter_stat_manager.cpp $(FLEX_CTR_DIR)/flow_counter_handler.cpp $(FLEX_CTR_DIR)/flowcounterrouteorch.cpp
tests_SOURCES += $(DEBUG_CTR_DIR)/debug_counter.cpp $(DEBUG_CTR_DIR)/drop_counter.cpp
Expand Down
26 changes: 2 additions & 24 deletions tests/mock_tests/copp_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,14 @@
#include "warm_restart.h"
#include "ut_helper.h"
#include "coppmgr.h"
#include "coppmgr.cpp"
#include <fstream>
#include <streambuf>

using namespace std;
using namespace swss;

void create_init_file()
{
int status = system("sudo mkdir /etc/sonic/");
ASSERT_EQ(status, 0);

status = system("sudo chmod 777 /etc/sonic/");
ASSERT_EQ(status, 0);

status = system("sudo cp copp_cfg.json /etc/sonic/");
ASSERT_EQ(status, 0);
}

void cleanup()
{
int status = system("sudo rm -rf /etc/sonic/");
ASSERT_EQ(status, 0);
}

TEST(CoppMgrTest, CoppTest)
{
create_init_file();

const vector<string> cfg_copp_tables = {
CFG_COPP_TRAP_TABLE_NAME,
CFG_COPP_GROUP_TABLE_NAME,
Expand Down Expand Up @@ -65,12 +45,10 @@ TEST(CoppMgrTest, CoppTest)
{"trap_ids", "ip2me"}
});

CoppMgr coppmgr(&cfgDb, &appDb, &stateDb, cfg_copp_tables);
CoppMgr coppmgr(&cfgDb, &appDb, &stateDb, cfg_copp_tables, "./copp_cfg.json");

string overide_val;
coppTable.hget("queue1_group1", "cbs",overide_val);
EXPECT_EQ( overide_val, "6000");

cleanup();
}

42 changes: 0 additions & 42 deletions tests/test_acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,29 +243,6 @@ def test_AclRuleInPorts(self, dvs_acl, mirror_acl_table):
dvs_acl.verify_acl_rule_status(MIRROR_TABLE_NAME, MIRROR_RULE_NAME, None)
dvs_acl.verify_no_acl_rules()

def test_AclRuleInPortsL3(self, dvs_acl, l3_acl_table):
"""
Verify IN_PORTS matches on ACL rule.
Using L3 table type for IN_PORTS matches.
"""
config_qualifiers = {
"IN_PORTS": "Ethernet8,Ethernet12",
}

expected_sai_qualifiers = {
"SAI_ACL_ENTRY_ATTR_FIELD_IN_PORTS": dvs_acl.get_port_list_comparator(["Ethernet8", "Ethernet12"])
}

dvs_acl.create_acl_rule(L3_TABLE_NAME, L3_RULE_NAME, config_qualifiers)
# Verify status is written into STATE_DB
dvs_acl.verify_acl_rule_status(L3_TABLE_NAME, L3_RULE_NAME, "Active")
dvs_acl.verify_acl_rule(expected_sai_qualifiers)

dvs_acl.remove_acl_rule(L3_TABLE_NAME, L3_RULE_NAME)
# Verify the STATE_DB entry is removed
dvs_acl.verify_acl_rule_status(L3_TABLE_NAME, L3_RULE_NAME, None)
dvs_acl.verify_no_acl_rules()

def test_AclRuleOutPorts(self, dvs_acl, mclag_acl_table):
"""
Verify OUT_PORTS matches on ACL rule.
Expand Down Expand Up @@ -569,25 +546,6 @@ def test_V6AclRuleVlanId(self, dvs_acl, l3v6_acl_table):
dvs_acl.verify_acl_rule_status(L3V6_TABLE_NAME, L3V6_RULE_NAME, None)
dvs_acl.verify_no_acl_rules()

def test_v6AclRuleInPorts(self, dvs_acl, l3v6_acl_table):
config_qualifiers = {
"IN_PORTS": "Ethernet8,Ethernet12",
}

expected_sai_qualifiers = {
"SAI_ACL_ENTRY_ATTR_FIELD_IN_PORTS": dvs_acl.get_port_list_comparator(["Ethernet8", "Ethernet12"])
}

dvs_acl.create_acl_rule(L3V6_TABLE_NAME, L3V6_RULE_NAME, config_qualifiers)
dvs_acl.verify_acl_rule(expected_sai_qualifiers)
# Verify status is written into STATE_DB
dvs_acl.verify_acl_rule_status(L3V6_TABLE_NAME, L3V6_RULE_NAME, "Active")

dvs_acl.remove_acl_rule(L3V6_TABLE_NAME, L3V6_RULE_NAME)
# Verify the STATE_DB entry is removed
dvs_acl.verify_acl_rule_status(L3V6_TABLE_NAME, L3V6_RULE_NAME, None)
dvs_acl.verify_no_acl_rules()

def test_InsertAclRuleBetweenPriorities(self, dvs_acl, l3_acl_table):
rule_priorities = ["10", "20", "30", "40"]

Expand Down

0 comments on commit d596a97

Please sign in to comment.