Skip to content

Commit 07b9e00

Browse files
AndriiSlguohan
AndriiS
authored andcommitted
[Bug sonic-net#1405] Export correct gSwitchId for SAI thrift (sonic-net#300)
1 parent d2601d9 commit 07b9e00

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

syncd/syncd.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,10 @@ sai_status_t handle_generic(
12341234
if (object_type == SAI_OBJECT_TYPE_SWITCH)
12351235
{
12361236
on_switch_create(switch_id);
1237+
#ifdef SAITHRIFT
1238+
gSwitchId = real_object_id;
1239+
SWSS_LOG_NOTICE("Initialize gSwitchId with ID = 0x%lx", gSwitchId);
1240+
#endif
12371241
}
12381242
}
12391243

@@ -1762,6 +1766,7 @@ void on_switch_create_in_init_view(
17621766

17631767
#ifdef SAITHRIFT
17641768
gSwitchId = switch_rid;
1769+
SWSS_LOG_NOTICE("Initialize gSwitchId with ID = 0x%lx", gSwitchId);
17651770
#endif
17661771

17671772
/*

syncd/syncd_hard_reinit.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ static sai_object_id_t g_switch_vid = SAI_NULL_OBJECT_ID;
4747

4848
static std::shared_ptr<SaiSwitch> g_sw;
4949

50+
#ifdef SAITHRIFT
51+
/*
52+
* SAI switch global needed for RPC server
53+
*/
54+
extern sai_object_id_t gSwitchId;
55+
#endif
56+
5057
void processAttributesForOids(
5158
_In_ sai_object_type_t objectType,
5259
_In_ uint32_t attr_count,
@@ -418,6 +425,11 @@ void processSwitches()
418425

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

428+
#ifdef SAITHRIFT
429+
gSwitchId = switch_rid;
430+
SWSS_LOG_NOTICE("Initialize gSwitchId with ID = 0x%lx", gSwitchId);
431+
#endif
432+
421433
if (status != SAI_STATUS_SUCCESS)
422434
{
423435
SWSS_LOG_THROW("failed to create switch RID: %s",

0 commit comments

Comments
 (0)