Skip to content

Commit e12ee28

Browse files
kcudniklguohan
authored andcommitted
Restrict sai_pointer_t to be used only on switch object (#454)
1 parent b3dd5ad commit e12ee28

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

meta/saisanitycheck.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,6 +2033,27 @@ void check_attr_existing_objects(
20332033
/* TODO there is default .1Q Bridge present */
20342034
}
20352035

2036+
void check_attr_sai_pointer(
2037+
_In_ const sai_attr_metadata_t* md)
2038+
{
2039+
META_LOG_ENTER();
2040+
2041+
/*
2042+
* Purpose of this test is to check whether sai_pointer_t
2043+
* is only used on SAI_OBJECT_TYPE_SWITCH.
2044+
*/
2045+
2046+
if (md->objecttype == SAI_OBJECT_TYPE_SWITCH)
2047+
{
2048+
return;
2049+
}
2050+
2051+
if (md->attrvaluetype == SAI_ATTR_VALUE_TYPE_POINTER)
2052+
{
2053+
META_ASSERT_FAIL(md, "attribute value pointer is only allowed on SAI_OBJECT_TYPE_SWITCH");
2054+
}
2055+
}
2056+
20362057
void check_single_attribute(
20372058
_In_ const sai_attr_metadata_t* md)
20382059
{
@@ -2066,6 +2087,7 @@ void check_single_attribute(
20662087
check_attr_acl_conditions(md);
20672088
check_attr_acl_field_or_action(md);
20682089
check_attr_existing_objects(md);
2090+
check_attr_sai_pointer(md);
20692091

20702092
define_attr(md);
20712093
}

0 commit comments

Comments
 (0)