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

Fix for the correct export gSwitchId for SAI thrift #3

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions syncd/syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,10 @@ sai_status_t handle_generic(
if (object_type == SAI_OBJECT_TYPE_SWITCH)
{
on_switch_create(switch_id);
#ifdef SAITHRIFT
gSwitchId = real_object_id;
SWSS_LOG_NOTICE("Initialize gSwitchId with ID = 0x%lx", gSwitchId);
#endif
}
}

Expand Down Expand Up @@ -1762,6 +1766,7 @@ void on_switch_create_in_init_view(

#ifdef SAITHRIFT
gSwitchId = switch_rid;
SWSS_LOG_NOTICE("Initialize gSwitchId with ID = 0x%lx", gSwitchId);
#endif

/*
Expand Down
12 changes: 12 additions & 0 deletions syncd/syncd_hard_reinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ static sai_object_id_t g_switch_vid = SAI_NULL_OBJECT_ID;

static std::shared_ptr<SaiSwitch> g_sw;

#ifdef SAITHRIFT
/*
* SAI switch global needed for RPC server
*/
extern sai_object_id_t gSwitchId;
#endif

void processAttributesForOids(
_In_ sai_object_type_t objectType,
_In_ uint32_t attr_count,
Expand Down Expand Up @@ -418,6 +425,11 @@ void processSwitches()

sai_status_t status = sai_metadata_sai_switch_api->create_switch(&switch_rid, attr_count, attr_list);

#ifdef SAITHRIFT
gSwitchId = switch_rid;
SWSS_LOG_NOTICE("Initialize gSwitchId with ID = 0x%lx", gSwitchId);
#endif

if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_THROW("failed to create switch RID: %s",
Expand Down