Skip to content

Commit

Permalink
[meta] Add sanity check for acl mask field (#1910)
Browse files Browse the repository at this point in the history
This check was missing from original commit
  • Loading branch information
kcudnik authored Oct 6, 2023
1 parent a94bbbe commit bd1b722
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
9 changes: 7 additions & 2 deletions meta/parse.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,9 @@ sub ProcessType

if ($type =~ /^sai_acl_field_data_mask_t (bool|sai_\w+_t)$/)
{
# TODO this is temporary solution, since mask should have it's own attribute type
# and not reuseing existing ones from aclfield, this provides confusion

my $prefix = "SAI_ATTR_VALUE_TYPE_ACL_FIELD_DATA";

return "${prefix}_BOOL" if $1 eq "bool";
Expand Down Expand Up @@ -2124,9 +2127,9 @@ sub ProcessIsAclAction

sub ProcessIsAclMask
{
my $attr = shift;
my ($attr, $type)= @_;

return "true" if $attr =~ /^SAI_ACL_TABLE_ATTR_FIELD_DATA_MASK_\w+$/;
return "true" if $type =~ /^sai_acl_field_data_mask_t /;

return "false";
}
Expand Down Expand Up @@ -2335,6 +2338,7 @@ sub ProcessSingleObjectType
my $getsave = ProcessGetSave($attr, $meta{getsave});
my $isaclfield = ProcessIsAclField($attr);
my $isaclaction = ProcessIsAclAction($attr);
my $isaclmask = ProcessIsAclMask($attr, $meta{type});
my $brief = ProcessBrief($attr, $meta{brief});
my $isprimitive = ProcessIsPrimitive($attr, $meta{type});
my $ntftype = ProcessNotificationType($attr, $meta{type});
Expand Down Expand Up @@ -2388,6 +2392,7 @@ sub ProcessSingleObjectType
WriteSource ".isvlan = $isvlan,";
WriteSource ".isaclfield = $isaclfield,";
WriteSource ".isaclaction = $isaclaction,";
WriteSource ".isaclmask = $isaclmask,";
WriteSource ".ismandatoryoncreate = $ismandatoryoncreate,";
WriteSource ".iscreateonly = $iscreateonly,";
WriteSource ".iscreateandset = $iscreateandset,";
Expand Down
25 changes: 25 additions & 0 deletions meta/saisanitycheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -2403,6 +2403,30 @@ void check_attr_acl_field_or_action(
}
}

void check_attr_acl_mask(
_In_ const sai_attr_metadata_t* md)
{
META_LOG_ENTER();

/*
* Field acl mask reuses existing attribute acl field mask key, then we
* need to have some conditions. Since acl field have enable mask and data
* fields, then this mask alone is not compatible.
*/

if (md->isaclmask)
{
META_ASSERT_FALSE(md->isaclfield, "aclmask can't be mark as alcfield");
META_ASSERT_FALSE(md->isaclaction, "aclmask can't be marked as aclaction");

META_ASSERT_TRUE(md->objecttype == SAI_OBJECT_TYPE_ACL_TABLE, "object type for acl mask must be acl table");

META_ASSERT_TRUE((md->attrvaluetype >= SAI_ATTR_VALUE_TYPE_ACL_FIELD_DATA_BOOL &&
md->attrvaluetype <= SAI_ATTR_VALUE_TYPE_ACL_FIELD_DATA_UINT8_LIST),
"aclmask attribute attr id must be in acl field start/end range");
}
}

void check_attr_existing_objects(
_In_ const sai_attr_metadata_t* md)
{
Expand Down Expand Up @@ -3396,6 +3420,7 @@ void check_single_attribute(
check_attr_reverse_graph(md);
check_attr_acl_conditions(md);
check_attr_acl_field_or_action(md);
check_attr_acl_mask(md);
check_attr_existing_objects(md);
check_attr_sai_pointer(md);
check_attr_brief_description(md);
Expand Down

0 comments on commit bd1b722

Please sign in to comment.