Skip to content

Commit

Permalink
sonic-sairedis updates for MPLS
Browse files Browse the repository at this point in the history
  • Loading branch information
qbdwlr committed Jun 7, 2021
1 parent 0e2105a commit 6916d19
Show file tree
Hide file tree
Showing 2 changed files with 26 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
21 changes: 21 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,25 @@ 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) && 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 6916d19

Please sign in to comment.