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

fix SAI_ATTR_CONDITION_TYPE_AND for MANDATORY_ON_CREATE condition #1497

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
25 changes: 19 additions & 6 deletions meta/Meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3817,6 +3817,7 @@ sai_status_t Meta::meta_generic_validation_create(
// this is conditional attribute, check if it's required

bool any = false;
bool all = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


for (size_t index = 0; md.conditions[index] != NULL; index++)
{
Expand All @@ -3838,13 +3839,25 @@ sai_status_t Meta::meta_generic_validation_create(

if (cmd.attrvaluetype == SAI_ATTR_VALUE_TYPE_BOOL)
{
if (c.condition.booldata == cvalue->booldata)
if (md.conditiontype == SAI_ATTR_CONDITION_TYPE_AND)
{
META_LOG_DEBUG(md, "bool condition was met on attr %d = %d", cmd.attrid, c.condition.booldata);

any = true;
break;
if (c.condition.booldata != cvalue->booldata)
{
META_LOG_DEBUG(md, "bool condition was not met on attr %d = %d", cmd.attrid, c.condition.booldata);
all = false;
break;
}
}
else
{
if (c.condition.booldata == cvalue->booldata)
{
META_LOG_DEBUG(md, "bool condition was met on attr %d = %d", cmd.attrid, c.condition.booldata);
any = true;
break;
}
}

}
else // enum condition
{
Expand Down Expand Up @@ -3875,7 +3888,7 @@ sai_status_t Meta::meta_generic_validation_create(
}
}

if (!any)
if (((md.conditiontype == SAI_ATTR_CONDITION_TYPE_AND) && !all) || ((md.conditiontype != SAI_ATTR_CONDITION_TYPE_AND) && !any))
{
// maybe we can let it go here?
if (attrs.find(md.attrid) != attrs.end())
Expand Down
Loading