Skip to content

Commit

Permalink
Fixing Building Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
shaygol committed Feb 6, 2025
1 parent f7ed582 commit 12a6199
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
13 changes: 8 additions & 5 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2143,8 +2143,10 @@ void AclRulePacket::onUpdate(SubjectType, void *)
// Do nothing
}

AclRulePolicer::AclRulePolicer(AclOrch *aclOrch, string rule, string table, bool createCounter) :
AclRule(aclOrch, rule, table, createCounter)
AclRulePolicer::AclRulePolicer(AclOrch *aclOrch, PolicerOrch *policer, string rule, string table) :
AclRule(aclOrch, rule, table),
m_state(false),
m_pPolicerOrch(policer)
{
}

Expand Down Expand Up @@ -2203,6 +2205,8 @@ bool AclRulePolicer::createRule()

bool AclRulePolicer::removeRule()
{
SWSS_LOG_ENTER();

return deactivate();
}

Expand Down Expand Up @@ -3777,7 +3781,6 @@ void AclOrch::init(vector<TableConnector>& connectors, PortsOrch *portOrch, Mirr
// Attach observers
m_mirrorOrch->attach(this);
gPortsOrch->attach(this);
m_policerOrch->attach(this);
}

void AclOrch::initDefaultTableTypes(const string& platform, const string& sub_platform)
Expand Down Expand Up @@ -4294,8 +4297,6 @@ AclOrch::~AclOrch()
{
m_mirrorOrch->detach(this);

m_policerOrch->detach(this);

if (m_dTelOrch)
{
m_dTelOrch->detach(this);
Expand Down Expand Up @@ -6123,13 +6124,15 @@ bool AclOrch::getAclBindPortId(Port &port, sai_object_id_t &port_id)
void AclOrch::setAclTableStatus(string table_name, AclObjectStatus status)
{
vector<FieldValueTuple> fvVector;
SWSS_LOG_NOTICE("changing table '%s' status to '%s'", table_name.c_str(), aclObjectStatusLookup[status].c_str());
fvVector.emplace_back("status", aclObjectStatusLookup[status]);
m_aclTableStateTable.set(table_name, fvVector);
}

// Remove the status record of given ACL table from STATE_DB
void AclOrch::removeAclTableStatus(string table_name)
{
SWSS_LOG_NOTICE("removing ACL table '%s' status", table_name.c_str());
m_aclTableStateTable.del(table_name);
}

Expand Down
1 change: 1 addition & 0 deletions orchagent/policerorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class PolicerOrch : public Orch

bool increaseRefCount(const string &name);
bool decreaseRefCount(const string &name);
int getRefCount(const string &name);
task_process_status handlePortStormControlTable(swss::KeyOpFieldsValuesTuple tuple);
private:
PortsOrch *m_portsOrch;
Expand Down
17 changes: 11 additions & 6 deletions tests/mock_tests/aclorch_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ extern Srv6Orch *gSrv6Orch;

extern FdbOrch *gFdbOrch;
extern MirrorOrch *gMirrorOrch;
extern PolicerOrch *gPolicerOrch;
extern VRFOrch *gVrfOrch;

extern sai_acl_api_t *sai_acl_api;
Expand Down Expand Up @@ -242,7 +243,11 @@ namespace aclorch_test
MockPolicerOrch(swss::DBConnector *config_db) :
config_db(config_db)
{
m_policerOrch = new PolicerOrch(config_db);
vector<TableConnector> policer_tables = {
TableConnector(config_db, CFG_POLICER_TABLE_NAME),
TableConnector(config_db, CFG_PORT_STORM_CONTROL_TABLE_NAME)
};
m_policerOrch = new PolicerOrch(policer_tables, gPortsOrch);
}

~MockPolicerOrch()
Expand Down Expand Up @@ -557,7 +562,7 @@ namespace aclorch_test

shared_ptr<MockAclOrch> createAclOrch()
{
return make_shared<MockAclOrch>(m_config_db.get(), m_state_db.get(), gSwitchOrch, gPortsOrch, gMirrorOrch,
return make_shared<MockAclOrch>(m_config_db.get(), m_state_db.get(), gSwitchOrch, gPortsOrch, gPolicerOrch, gMirrorOrch,
gNeighOrch, gRouteOrch);
}

Expand Down Expand Up @@ -2022,10 +2027,10 @@ namespace aclorch_test
const map<string, string> policerAttributes = {{"CIR", "1000"}, {"CBS", "200"}};
const string aclTableActions = "PACKET_ACTION,POLICER_ACTION";
const string aclTableMatch = "SRC_IP";
policer_action_attr = "POLICER_ACTION"
const string policer_action_attr = "POLICER_ACTION";

auto policerOrch = MockPolicerOrch(config_db);
auto aclOrch = MockAclOrch(config_db, state_db, gSwitchOrch, gPortsOrch, policerOrch.m_policerOrch, gMirrorOrch, gNeighOrch, gRouteOrch);
auto policerOrch = MockPolicerOrch(m_config_db.get());
auto aclOrch = MockAclOrch(m_config_db.get(), m_state_db.get(), gSwitchOrch, gPortsOrch, policerOrch.m_policerOrch, gMirrorOrch, gNeighOrch, gRouteOrch);

// Create ACL Table Type
aclOrch.doAclTableTypeTask({
Expand All @@ -2042,7 +2047,7 @@ namespace aclorch_test
ASSERT_TRUE(policerOrch.policerExists(policerName));

// Add ACL Rule with Policer Action
auto rule = make_shared<AclRulePolicer>(aclOrch, aclRuleName, aclTableName);
auto rule = make_shared<AclRulePolicer>(aclOrch.m_aclOrch, policerOrch.m_policerOrch, aclRuleName, aclTableName);
ASSERT_TRUE(rule->validateAddAction(policer_action_attr, policerName));
ASSERT_TRUE(aclOrch.m_aclOrch->addAclRule(rule, aclTableName));

Expand Down

0 comments on commit 12a6199

Please sign in to comment.