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

[aclorch] Remove L4 port range support limitation on egress ACL table and add new SWSS virtual test. #741

Merged
merged 8 commits into from
Jan 29, 2019
36 changes: 23 additions & 13 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ AclRuleCounters AclRule::getCounters()
return AclRuleCounters(counter_attr[0].value.u64, counter_attr[1].value.u64);
}

shared_ptr<AclRule> AclRule::makeShared(acl_table_type_t type, AclOrch *acl, MirrorOrch *mirror, DTelOrch *dtel, const string& rule, const string& table, const KeyOpFieldsValuesTuple& data)
shared_ptr<AclRule> AclRule::makeShared(acl_table_type_t type, acl_stage_type_t stage, AclOrch *acl, MirrorOrch *mirror, DTelOrch *dtel, const string& rule, const string& table, const KeyOpFieldsValuesTuple& data)
{
string action;
bool action_found = false;
Expand Down Expand Up @@ -585,7 +585,7 @@ shared_ptr<AclRule> AclRule::makeShared(acl_table_type_t type, AclOrch *acl, Mir
/* Mirror rules can exist in both tables*/
if (action == ACTION_MIRROR_ACTION)
{
return make_shared<AclRuleMirror>(acl, mirror, rule, table, type);
return make_shared<AclRuleMirror>(acl, stage, mirror, rule, table, type);
}
/* L3 rules can exist only in L3 table */
else if (type == ACL_TABLE_L3)
Expand Down Expand Up @@ -901,9 +901,10 @@ bool AclRuleL3V6::validateAddMatch(string attr_name, string attr_value)
}


AclRuleMirror::AclRuleMirror(AclOrch *aclOrch, MirrorOrch *mirror, string rule, string table, acl_table_type_t type) :
AclRuleMirror::AclRuleMirror(AclOrch *aclOrch, acl_stage_type_t stage, MirrorOrch *mirror, string rule, string table, acl_table_type_t type) :
AclRule(aclOrch, rule, table, type),
m_state(false),
m_tableStage(stage),
m_pMirrorOrch(mirror)
{
}
Expand Down Expand Up @@ -986,7 +987,19 @@ bool AclRuleMirror::create()
value.aclaction.parameter.objlist.count = 1;

m_actions.clear();
m_actions[SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS] = value;
if (m_tableStage == ACL_STAGE_INGRESS)
{
m_actions[SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_INGRESS] = value;
}
else if (m_tableStage == ACL_STAGE_EGRESS)
{
m_actions[SAI_ACL_ENTRY_ATTR_ACTION_MIRROR_EGRESS] = value;
}
else
{
SWSS_LOG_ERROR("Unknown ACL table stage: %d", m_tableStage);
return false;
}

if (!AclRule::create())
{
Expand Down Expand Up @@ -1151,14 +1164,11 @@ bool AclTable::create()
attr.value.booldata = true;
table_attrs.push_back(attr);

if (stage == ACL_STAGE_INGRESS)
{
int32_t range_types_list[] = { SAI_ACL_RANGE_TYPE_L4_DST_PORT_RANGE, SAI_ACL_RANGE_TYPE_L4_SRC_PORT_RANGE };
attr.id = SAI_ACL_TABLE_ATTR_FIELD_ACL_RANGE_TYPE;
attr.value.s32list.count = (uint32_t)(sizeof(range_types_list) / sizeof(range_types_list[0]));
attr.value.s32list.list = range_types_list;
table_attrs.push_back(attr);
}
int32_t range_types_list[] = { SAI_ACL_RANGE_TYPE_L4_DST_PORT_RANGE, SAI_ACL_RANGE_TYPE_L4_SRC_PORT_RANGE };
attr.id = SAI_ACL_TABLE_ATTR_FIELD_ACL_RANGE_TYPE;
attr.value.s32list.count = (uint32_t)(sizeof(range_types_list) / sizeof(range_types_list[0]));
attr.value.s32list.list = range_types_list;
table_attrs.push_back(attr);

attr.id = SAI_ACL_TABLE_ATTR_ACL_STAGE;
attr.value.s32 = stage == ACL_STAGE_INGRESS ? SAI_ACL_STAGE_INGRESS : SAI_ACL_STAGE_EGRESS;
Expand Down Expand Up @@ -2141,7 +2151,7 @@ void AclOrch::doAclRuleTask(Consumer &consumer)
continue;
}

newRule = AclRule::makeShared(m_AclTables[table_oid].type, this, m_mirrorOrch, m_dTelOrch, rule_id, table_id, t);
newRule = AclRule::makeShared(m_AclTables[table_oid].type, m_AclTables[table_oid].stage, this, m_mirrorOrch, m_dTelOrch, rule_id, table_id, t);

for (const auto& itr : kfvFieldsValues(t))
{
Expand Down
5 changes: 3 additions & 2 deletions orchagent/aclorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class AclRule
return m_counterOid;
}

static shared_ptr<AclRule> makeShared(acl_table_type_t type, AclOrch *acl, MirrorOrch *mirror, DTelOrch *dtel, const string& rule, const string& table, const KeyOpFieldsValuesTuple&);
static shared_ptr<AclRule> makeShared(acl_table_type_t type, acl_stage_type_t stage, AclOrch *acl, MirrorOrch *mirror, DTelOrch *dtel, const string& rule, const string& table, const KeyOpFieldsValuesTuple&);
virtual ~AclRule() {}

protected:
Expand Down Expand Up @@ -251,7 +251,7 @@ class AclRulePfcwd: public AclRuleL3
class AclRuleMirror: public AclRule
{
public:
AclRuleMirror(AclOrch *m_pAclOrch, MirrorOrch *m_pMirrorOrch, string rule, string table, acl_table_type_t type);
AclRuleMirror(AclOrch *m_pAclOrch, acl_stage_type_t stage, MirrorOrch *m_pMirrorOrch, string rule, string table, acl_table_type_t type);
bool validateAddAction(string attr_name, string attr_value);
bool validateAddMatch(string attr_name, string attr_value);
bool validate();
Expand All @@ -263,6 +263,7 @@ class AclRuleMirror: public AclRule
protected:
bool m_state;
string m_sessionName;
acl_stage_type_t m_tableStage;
AclRuleCounters counters;
MirrorOrch *m_pMirrorOrch;
};
Expand Down
Loading