File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed
Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -1786,8 +1786,11 @@ sai_status_t Meta::objectTypeGetAvailability(
17861786 PARAMETER_CHECK_OID_OBJECT_TYPE (switchId, SAI_OBJECT_TYPE_SWITCH);
17871787 PARAMETER_CHECK_OID_EXISTS (switchId, SAI_OBJECT_TYPE_SWITCH);
17881788 PARAMETER_CHECK_OBJECT_TYPE_VALID (objectType);
1789- PARAMETER_CHECK_POSITIVE (attrCount);
1790- PARAMETER_CHECK_IF_NOT_NULL (attrList);
1789+ // When checking availability of a resource solely based on OBJECT_TYPE, attrCount is 0
1790+ if (attrCount)
1791+ {
1792+ PARAMETER_CHECK_IF_NOT_NULL (attrList);
1793+ }
17911794 PARAMETER_CHECK_IF_NOT_NULL (count);
17921795
17931796 auto info = sai_metadata_get_object_type_info (objectType);
Original file line number Diff line number Diff line change 4848cpp
4949cpu
5050CreateObject
51+ CRM
5152currentObj
5253currentObject
5354currentView
Original file line number Diff line number Diff line change 33#include " ../../lib/inc/PerformanceIntervalTimer.h"
44
55#include " swss/logger.h"
6+ #include " swss/exec.h"
7+ #include " swss/converter.h"
68
79#include " meta/sai_serialize.h"
810#include " meta/SaiAttributeList.h"
@@ -817,6 +819,26 @@ sai_status_t VirtualSwitchSaiInterface::objectTypeGetAvailability(
817819 *count = 3 ;
818820 return SAI_STATUS_SUCCESS;
819821 }
822+ // MPLS Inseg and MPLS NH CRM use sai_object_type_get_availability() API.
823+ else if ((objectType == SAI_OBJECT_TYPE_INSEG_ENTRY) ||
824+ ((objectType == SAI_OBJECT_TYPE_NEXT_HOP) &&
825+ (attrCount == 1 ) && attrList &&
826+ (attrList[0 ].id == SAI_NEXT_HOP_ATTR_TYPE) &&
827+ (attrList[0 ].value .s32 == SAI_NEXT_HOP_TYPE_MPLS)))
828+ {
829+ std::string cmd_str (" sysctl net.mpls.platform_labels" );
830+ std::string ret_str;
831+ *count = 1000 ;
832+ if (!swss::exec (cmd_str, ret_str))
833+ {
834+ std::string match (" net.mpls.platform_labels = " );
835+ if (ret_str.find (match) != std::string::npos)
836+ {
837+ *count = std::stoul (ret_str.substr (match.length ()).c_str ());
838+ }
839+ }
840+ return SAI_STATUS_SUCCESS;
841+ }
820842
821843 return SAI_STATUS_NOT_SUPPORTED;
822844}
You can’t perform that action at this time.
0 commit comments