Skip to content

Commit

Permalink
[Bug sonic-net#1405] Export correct gSwitchId for SAI thrift (sonic-n…
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriiS authored and lguohan committed Feb 24, 2018
1 parent d2601d9 commit 07b9e00
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
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

0 comments on commit 07b9e00

Please sign in to comment.