Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/swss-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,11 @@ Stores rules associated with a specific ACL table on the switch.
mirror_action = 1*255VCHAR ; refer to the mirror session (by default it will be ingress mirror action)
mirror_ingress_action = 1*255VCHAR ; refer to the mirror session
mirror_egress_action = 1*255VCHAR ; refer to the mirror session
packet_color_action = "green"/"yellow"/"red"
; sets the packet color on matching packets; maps to
; SAI_ACL_ENTRY_ATTR_ACTION_SET_PACKET_COLOR (case-insensitive).
; Supported only where the platform SAI advertises the action for the
; table's ACL stage (ingress and/or egress)

ether_type = h16 ; Ethernet type field

Expand Down
51 changes: 49 additions & 2 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ static acl_rule_attr_lookup_t aclL3ActionLookup =
{ ACTION_PACKET_ACTION, SAI_ACL_ENTRY_ATTR_ACTION_PACKET_ACTION },
{ ACTION_REDIRECT_ACTION, SAI_ACL_ENTRY_ATTR_ACTION_REDIRECT },
{ ACTION_DO_NOT_NAT_ACTION, SAI_ACL_ENTRY_ATTR_ACTION_NO_NAT },
{ ACTION_DISABLE_TRIM, SAI_ACL_ENTRY_ATTR_ACTION_PACKET_TRIM_DISABLE }
{ ACTION_DISABLE_TRIM, SAI_ACL_ENTRY_ATTR_ACTION_PACKET_TRIM_DISABLE },
{ ACTION_PACKET_COLOR_ACTION, SAI_ACL_ENTRY_ATTR_ACTION_SET_PACKET_COLOR }
};

static acl_rule_attr_lookup_t aclInnerActionLookup =
Expand Down Expand Up @@ -148,6 +149,13 @@ static acl_packet_action_lookup_t aclPacketActionLookup =
{ PACKET_ACTION_COPY, SAI_PACKET_ACTION_COPY },
};

static acl_packet_color_lookup_t aclPacketColorLookup =
{
{ PACKET_COLOR_GREEN, SAI_PACKET_COLOR_GREEN },
{ PACKET_COLOR_YELLOW, SAI_PACKET_COLOR_YELLOW },
{ PACKET_COLOR_RED, SAI_PACKET_COLOR_RED },
};

static acl_rule_attr_lookup_t aclMetadataDscpActionLookup =
{
{ ACTION_META_DATA, SAI_ACL_ENTRY_ATTR_ACTION_SET_ACL_META_DATA},
Expand Down Expand Up @@ -2217,6 +2225,17 @@ bool AclRulePacket::validateAddAction(string attr_name, string _attr_value)
}
actionData.parameter.oid = param_id;
}
else if (attr_name == ACTION_PACKET_COLOR_ACTION)
{
const auto it = aclPacketColorLookup.find(attr_value);
if (it == aclPacketColorLookup.cend())
{
SWSS_LOG_ERROR("Invalid packet color %s for action %s",
attr_value.c_str(), attr_name.c_str());
return false;
}
actionData.parameter.s32 = it->second;
}
else
{
return false;
Expand Down Expand Up @@ -2322,7 +2341,32 @@ bool AclRulePacket::validate()
{
SWSS_LOG_ENTER();

if ((m_rangeConfig.empty() && m_matches.empty()) || m_actions.size() != 1)
if (m_rangeConfig.empty() && m_matches.empty())
{
return false;
}

// A packet rule must carry at least one action.
if (m_actions.empty())
{
return false;
}

// SET_PACKET_COLOR is a composable QoS marking: it sets the drop-precedence
// color of a matched packet (consumed downstream by a color-aware policer or
// WRED) and may accompany a single forwarding/terminating action such as
// PACKET_ACTION, plus a counter. Only the non-color actions are capped at
// one; SAI applies SET_PACKET_COLOR as an independent CREATE_AND_SET action.
size_t nonColorActions = 0;
for (const auto &action : m_actions)
{
if (action.first != SAI_ACL_ENTRY_ATTR_ACTION_SET_PACKET_COLOR)
{
nonColorActions++;
}
}

if (nonColorActions > 1)
{
return false;
}
Expand Down Expand Up @@ -4202,6 +4246,9 @@ void AclOrch::queryAclActionCapability()
queryAclActionAttrEnumValues(ACTION_PACKET_ACTION,
aclL3ActionLookup,
aclPacketActionLookup);
queryAclActionAttrEnumValues(ACTION_PACKET_COLOR_ACTION,
aclL3ActionLookup,
aclPacketColorLookup);
queryAclActionAttrEnumValues(ACTION_DTEL_FLOW_OP,
aclDTelActionLookup,
aclDTelFlowOpTypeLookup);
Expand Down
6 changes: 6 additions & 0 deletions orchagent/aclorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
#define ACTION_META_DATA "META_DATA_ACTION"
#define ACTION_DSCP "DSCP_ACTION"
#define ACTION_INNER_SRC_MAC_REWRITE_ACTION "INNER_SRC_MAC_REWRITE_ACTION"
#define ACTION_PACKET_COLOR_ACTION "PACKET_COLOR_ACTION"

#define PACKET_ACTION_FORWARD "FORWARD"
#define PACKET_ACTION_DROP "DROP"
Expand All @@ -92,6 +93,10 @@
#define PACKET_ACTION_DO_NOT_NAT "DO_NOT_NAT"
#define PACKET_ACTION_DISABLE_TRIM "DISABLE_TRIM"

#define PACKET_COLOR_GREEN "GREEN"
#define PACKET_COLOR_YELLOW "YELLOW"
#define PACKET_COLOR_RED "RED"

#define DTEL_FLOW_OP_NOP "NOP"
#define DTEL_FLOW_OP_POSTCARD "POSTCARD"
#define DTEL_FLOW_OP_INT "INT"
Expand Down Expand Up @@ -154,6 +159,7 @@ typedef map<string, sai_acl_bind_point_type_t> acl_bind_point_type_lookup_t;
typedef map<string, sai_acl_ip_type_t> acl_ip_type_lookup_t;
typedef map<string, sai_acl_dtel_flow_op_t> acl_dtel_flow_op_type_lookup_t;
typedef map<string, sai_packet_action_t> acl_packet_action_lookup_t;
typedef map<string, sai_packet_color_t> acl_packet_color_lookup_t;
typedef tuple<sai_acl_range_type_t, int, int> acl_range_properties_t;
typedef map<acl_stage_type_t, AclActionCapabilities> acl_capabilities_t;
typedef map<sai_acl_action_type_t, set<int32_t>> acl_action_enum_values_capabilities_t;
Expand Down
Loading
Loading