From 253e8ebc2e4721dc2164726bb229103af6e70b2d Mon Sep 17 00:00:00 2001 From: Baorong Liu <96146196+baorliu@users.noreply.github.com> Date: Thu, 9 Jan 2025 18:29:26 -0800 Subject: [PATCH] fix SAI_ATTR_CONDITION_TYPE_AND for MANDATORY_ON_CREATE condition Signed-off-by: Baorong Liu <96146196+baorliu@users.noreply.github.com> --- meta/Meta.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/meta/Meta.cpp b/meta/Meta.cpp index a9851d201..b66604bfa 100644 --- a/meta/Meta.cpp +++ b/meta/Meta.cpp @@ -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; for (size_t index = 0; md.conditions[index] != NULL; index++) { @@ -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 { @@ -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())