Skip to content

Commit

Permalink
[MPLS] Minor tweaks to VS for MPLS support for CRM polling of MPLS In…
Browse files Browse the repository at this point in the history
…-segments and NHs.
  • Loading branch information
qbdwlr authored Jun 16, 2021
1 parent d819f97 commit e385212
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
7 changes: 5 additions & 2 deletions meta/Meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions tests/aspell.en.pws
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ cout
cpp
cpu
CreateObject
CRM
currentObj
currentObject
currentView
Expand Down
22 changes: 22 additions & 0 deletions vslib/src/VirtualSwitchSaiInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit e385212

Please sign in to comment.