Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sonic-sairedis updates for MPLS #824

Merged
merged 1 commit into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
qbdwlr marked this conversation as resolved.
Show resolved Hide resolved
// 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) &&
kcudnik marked this conversation as resolved.
Show resolved Hide resolved
(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