@@ -141,6 +141,26 @@ sai_object_id_t saiGetDefaultTrapGroup()
141
141
return attr.value .oid ;
142
142
}
143
143
144
+ sai_object_id_t saiGetDefaultStpInstance ()
145
+ {
146
+ SWSS_LOG_ENTER ();
147
+
148
+ sai_attribute_t attr;
149
+
150
+ attr.id = SAI_SWITCH_ATTR_DEFAULT_STP_INST_ID;
151
+
152
+ sai_status_t status = sai_switch_api->get_switch_attribute (1 , &attr);
153
+
154
+ if (status != SAI_STATUS_SUCCESS)
155
+ {
156
+ SWSS_LOG_ERROR (" failed to get switch default stp instance %d" , status);
157
+
158
+ exit_and_notify (EXIT_FAILURE);
159
+ }
160
+
161
+ return attr.value .oid ;
162
+ }
163
+
144
164
sai_object_id_t saiGetDefaultVirtualRouter ()
145
165
{
146
166
SWSS_LOG_ENTER ();
@@ -355,6 +375,22 @@ sai_object_id_t redisGetDefaultTrapGroupId()
355
375
return vr_id;
356
376
}
357
377
378
+ sai_object_id_t redisGetDefaultStpInstanceId ()
379
+ {
380
+ SWSS_LOG_ENTER ();
381
+
382
+ auto redisStpId = g_redisClient->hget (HIDDEN, DEFAULT_STP_INSTANCE_ID);
383
+
384
+ if (redisStpId == NULL )
385
+ return SAI_NULL_OBJECT_ID;
386
+
387
+ sai_object_id_t stp_id;
388
+
389
+ sai_deserialize_object_id (*redisStpId, stp_id);
390
+
391
+ return stp_id;
392
+ }
393
+
358
394
sai_object_id_t redisGetCpuId ()
359
395
{
360
396
SWSS_LOG_ENTER ();
@@ -389,6 +425,15 @@ void redisSetDefaultTrapGroup(sai_object_id_t vr_id)
389
425
g_redisClient->hset (HIDDEN, DEFAULT_TRAP_GROUP_ID, strVrId);
390
426
}
391
427
428
+ void redisSetDefaultStpInstance (sai_object_id_t stp_id)
429
+ {
430
+ SWSS_LOG_ENTER ();
431
+
432
+ std::string strStpId = sai_serialize_object_id (stp_id);
433
+
434
+ g_redisClient->hset (HIDDEN, DEFAULT_STP_INSTANCE_ID, strStpId);
435
+ }
436
+
392
437
void redisCreateRidAndVidMapping (sai_object_id_t rid, sai_object_id_t vid)
393
438
{
394
439
SWSS_LOG_ENTER ();
@@ -484,6 +529,34 @@ void helperCheckDefaultTrapGroup()
484
529
}
485
530
}
486
531
532
+ void helperCheckDefaultStpInstance ()
533
+ {
534
+ SWSS_LOG_ENTER ();
535
+
536
+ sai_object_id_t stpId = saiGetDefaultStpInstance ();
537
+
538
+ sai_object_id_t redisStpId = redisGetDefaultStpInstanceId ();
539
+
540
+ if (redisStpId == SAI_NULL_OBJECT_ID)
541
+ {
542
+ redisSetDummyAsicStateForRealObjectId (stpId);
543
+
544
+ SWSS_LOG_INFO (" redis default stp instance id is not defined yet" );
545
+
546
+ redisSetDefaultStpInstance (stpId);
547
+
548
+ redisStpId = stpId;
549
+ }
550
+
551
+ if (stpId != redisStpId)
552
+ {
553
+ // if this happens, we need to remap VIDTORID and RIDTOVID
554
+ SWSS_LOG_ERROR (" FIXME: default stp instance id differs: 0x%lx vs 0x%lx, ids must be remapped" , stpId, redisStpId);
555
+
556
+ exit_and_notify (EXIT_FAILURE);
557
+ }
558
+ }
559
+
487
560
void redisSetCpuId (sai_object_id_t cpuId)
488
561
{
489
562
SWSS_LOG_ENTER ();
@@ -923,6 +996,8 @@ void onSyncdStart(bool warmStart)
923
996
924
997
helperCheckDefaultTrapGroup ();
925
998
999
+ helperCheckDefaultStpInstance ();
1000
+
926
1001
helperCheckVlanId ();
927
1002
928
1003
helperCheckPortIds ();
0 commit comments