diff --git a/meta/Meta.cpp b/meta/Meta.cpp index 2e7dfdeacf0a..8cc5afd669af 100644 --- a/meta/Meta.cpp +++ b/meta/Meta.cpp @@ -1786,8 +1786,11 @@ sai_status_t Meta::objectTypeGetAvailability( PARAMETER_CHECK_OID_OBJECT_TYPE(switchId, SAI_OBJECT_TYPE_SWITCH); PARAMETER_CHECK_OID_EXISTS(switchId, SAI_OBJECT_TYPE_SWITCH); PARAMETER_CHECK_OBJECT_TYPE_VALID(objectType); - PARAMETER_CHECK_POSITIVE(attrCount); - PARAMETER_CHECK_IF_NOT_NULL(attrList); + // When checking availability of a resource solely based on OBJECT_TYPE, attrCount is 0 + if (attrCount) + { + PARAMETER_CHECK_IF_NOT_NULL(attrList); + } PARAMETER_CHECK_IF_NOT_NULL(count); auto info = sai_metadata_get_object_type_info(objectType); diff --git a/tests/aspell.en.pws b/tests/aspell.en.pws index 89a7bed3efab..d63b101264a9 100644 --- a/tests/aspell.en.pws +++ b/tests/aspell.en.pws @@ -48,6 +48,7 @@ cout cpp cpu CreateObject +CRM currentObj currentObject currentView diff --git a/vslib/src/VirtualSwitchSaiInterface.cpp b/vslib/src/VirtualSwitchSaiInterface.cpp index 8b70171c8237..d4808df671a3 100644 --- a/vslib/src/VirtualSwitchSaiInterface.cpp +++ b/vslib/src/VirtualSwitchSaiInterface.cpp @@ -3,6 +3,8 @@ #include "../../lib/inc/PerformanceIntervalTimer.h" #include "swss/logger.h" +#include "swss/exec.h" +#include "swss/converter.h" #include "meta/sai_serialize.h" #include "meta/SaiAttributeList.h" @@ -817,6 +819,26 @@ sai_status_t VirtualSwitchSaiInterface::objectTypeGetAvailability( *count = 3; return SAI_STATUS_SUCCESS; } + // MPLS Inseg and MPLS NH CRM use sai_object_type_get_availability() API. + else if ((objectType == SAI_OBJECT_TYPE_INSEG_ENTRY) || + ((objectType == SAI_OBJECT_TYPE_NEXT_HOP) && + (attrCount == 1) && attrList && + (attrList[0].id == SAI_NEXT_HOP_ATTR_TYPE) && + (attrList[0].value.s32 == SAI_NEXT_HOP_TYPE_MPLS))) + { + std::string cmd_str("sysctl net.mpls.platform_labels"); + std::string ret_str; + *count = 1000; + if (!swss::exec(cmd_str, ret_str)) + { + std::string match("net.mpls.platform_labels = "); + if (ret_str.find(match) != std::string::npos) + { + *count = std::stoul(ret_str.substr(match.length()).c_str()); + } + } + return SAI_STATUS_SUCCESS; + } return SAI_STATUS_NOT_SUPPORTED; }