Skip to content

Commit e385212

Browse files
authored
[MPLS] Minor tweaks to VS for MPLS support for CRM polling of MPLS In-segments and NHs.
1 parent d819f97 commit e385212

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

meta/Meta.cpp

+5-2
Original file line numberDiff line numberDiff 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);

tests/aspell.en.pws

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ cout
4848
cpp
4949
cpu
5050
CreateObject
51+
CRM
5152
currentObj
5253
currentObject
5354
currentView

vslib/src/VirtualSwitchSaiInterface.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
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
}

0 commit comments

Comments
 (0)