@@ -2062,14 +2062,11 @@ bool hasEqualObjectList(
2062
2062
* @return True if attributes are equal, false otherwise.
2063
2063
*/
2064
2064
bool hasEqualQosMapList (
2065
- _In_ const std::shared_ptr< const SaiAttr> ¤t ,
2066
- _In_ const std::shared_ptr< const SaiAttr> &temporary )
2065
+ _In_ const sai_qos_map_list_t & c ,
2066
+ _In_ const sai_qos_map_list_t & t )
2067
2067
{
2068
2068
SWSS_LOG_ENTER ();
2069
2069
2070
- auto c = current->getSaiAttr ()->value .qosmap ;
2071
- auto t = temporary->getSaiAttr ()->value .qosmap ;
2072
-
2073
2070
if (c.count != t.count )
2074
2071
return false ;
2075
2072
@@ -2102,6 +2099,18 @@ bool hasEqualQosMapList(
2102
2099
return true ;
2103
2100
}
2104
2101
2102
+ bool hasEqualQosMapList (
2103
+ _In_ const std::shared_ptr<const SaiAttr> ¤t,
2104
+ _In_ const std::shared_ptr<const SaiAttr> &temporary)
2105
+ {
2106
+ SWSS_LOG_ENTER ();
2107
+
2108
+ auto c = current->getSaiAttr ()->value .qosmap ;
2109
+ auto t = temporary->getSaiAttr ()->value .qosmap ;
2110
+
2111
+ return hasEqualQosMapList (c, t);
2112
+ }
2113
+
2105
2114
/* *
2106
2115
* @brief Check if current and temporary object has
2107
2116
* the same attribute and attribute has the same value on both.
@@ -5992,6 +6001,9 @@ void processObjectForViewTransition(
5992
6001
*/
5993
6002
}
5994
6003
6004
+ // No need to store VID since at this point we don't have RID yet, it will be
6005
+ // created on execute asic and RID will be saved to maps in both views.
6006
+
5995
6007
createNewObjectFromTemporaryObject (currentView, temporaryView, temporaryObj);
5996
6008
5997
6009
return ;
@@ -6026,6 +6038,10 @@ void processObjectForViewTransition(
6026
6038
sai_object_id_t vid = temporaryObj->getVid ();
6027
6039
6028
6040
currentView.insertNewVidReference (vid);
6041
+
6042
+ // save temporary vid to rid after match
6043
+ // can't be here since vim to rid map will not match
6044
+ // currentView.vidToRid[vid] = currentView.vidToRid.at(currentBestMatch->getVid());
6029
6045
}
6030
6046
6031
6047
performObjectSetTransition (currentView, temporaryView, currentBestMatch, temporaryObj, true );
@@ -6573,6 +6589,162 @@ void logViewObjectCount(
6573
6589
}
6574
6590
}
6575
6591
6592
+ void checkAsicVsDatabaseConsistency (
6593
+ _In_ const AsicView cur,
6594
+ _In_ const AsicView &tmp)
6595
+ {
6596
+ SWSS_LOG_ENTER ();
6597
+
6598
+ bool hasErrors = false ;
6599
+
6600
+ {
6601
+ SWSS_LOG_TIMER (" consistency check" );
6602
+
6603
+ SWSS_LOG_WARN (" performing consistency check" );
6604
+
6605
+ for (const auto &pair: tmp.soAll )
6606
+ {
6607
+ const auto &obj = pair.second ;
6608
+
6609
+ const auto &attrs = obj->getAllAttributes ();
6610
+
6611
+ // get object meta key for get (object id or *entry)
6612
+
6613
+ sai_object_meta_key_t meta_key = obj->meta_key ;
6614
+
6615
+ // translate all VID's to RIDs in non object is's
6616
+
6617
+ translate_vid_to_rid_non_object_id (meta_key);
6618
+
6619
+ auto info = sai_metadata_get_object_type_info (obj->getObjectType ());
6620
+
6621
+ sai_attribute_t attr;
6622
+
6623
+ memset (&attr, 0 , sizeof (attr));
6624
+
6625
+ if (attrs.size () == 0 )
6626
+ {
6627
+ // get first attribute and do a get query to see if object exist's
6628
+
6629
+ auto meta = info->attrmetadata [0 ];
6630
+
6631
+ sai_status_t status = info->get (&meta_key, 1 , &attr);
6632
+
6633
+ switch (status)
6634
+ {
6635
+ case SAI_STATUS_SUCCESS:
6636
+ case SAI_STATUS_BUFFER_OVERFLOW:
6637
+ continue ;
6638
+
6639
+ case SAI_STATUS_NOT_IMPLEMENTED:
6640
+ case SAI_STATUS_NOT_SUPPORTED:
6641
+
6642
+ SWSS_LOG_WARN (" GET api for %s is not implemented on %s" ,
6643
+ meta->attridname ,
6644
+ obj->str_object_id .c_str ());
6645
+ continue ;
6646
+ }
6647
+
6648
+ SWSS_LOG_ERROR (" failed to get %s on %s: %s" ,
6649
+ meta->attridname ,
6650
+ obj->str_object_id .c_str (),
6651
+ sai_serialize_status (status).c_str ());
6652
+
6653
+ hasErrors = true ;
6654
+
6655
+ continue ;
6656
+ }
6657
+
6658
+ for (const auto &ap: attrs)
6659
+ {
6660
+ const auto &saiAttr = ap.second ;
6661
+
6662
+ auto meta = saiAttr->getAttrMetadata ();
6663
+
6664
+ // deserialize existing attribute so deserialize will allocate
6665
+ // memory for all list's
6666
+
6667
+ attr.id = meta->attrid ;
6668
+
6669
+ sai_deserialize_attr_value (saiAttr->getStrAttrValue (), *meta, attr, false );
6670
+
6671
+ // translate all VIDs from DB to RIDs for compare
6672
+
6673
+ translate_vid_to_rid_list (obj->getObjectType (), 1 , &attr);
6674
+
6675
+ // get attr value with RIDs
6676
+
6677
+ const std::string& dbValue = sai_serialize_attr_value (*meta, attr);
6678
+
6679
+ sai_status_t status = info->get (&meta_key, 1 , &attr);
6680
+
6681
+ if (meta->attrid == SAI_QOS_MAP_ATTR_MAP_TO_VALUE_LIST && meta->objecttype == SAI_OBJECT_TYPE_QOS_MAP && status == SAI_STATUS_SUCCESS)
6682
+ {
6683
+ // order does not matter on this list
6684
+
6685
+ if (hasEqualQosMapList (attr.value .qosmap , saiAttr->getSaiAttr ()->value .qosmap ))
6686
+ {
6687
+ sai_deserialize_free_attribute_value (meta->attrvaluetype , attr);
6688
+ continue ;
6689
+ }
6690
+ }
6691
+
6692
+ // free possible allocated lists
6693
+
6694
+ if (status != SAI_STATUS_SUCCESS)
6695
+ {
6696
+ SWSS_LOG_ERROR (" failed to get %s on %s %s" ,
6697
+ meta->attridname ,
6698
+ obj->str_object_id .c_str (),
6699
+ sai_serialize_status (status).c_str ());
6700
+
6701
+ hasErrors = true ;
6702
+
6703
+ sai_deserialize_free_attribute_value (meta->attrvaluetype , attr);
6704
+ continue ;
6705
+ }
6706
+
6707
+ const std::string &asicValue = sai_serialize_attr_value (*meta, attr);
6708
+
6709
+ sai_deserialize_free_attribute_value (meta->attrvaluetype , attr);
6710
+
6711
+ // pointers will not be equal since those will be from
6712
+ // different process memory maps so just check if both pointers
6713
+ // are NULL or both are SET
6714
+
6715
+ if (meta->attrvaluetype == SAI_ATTR_VALUE_TYPE_POINTER)
6716
+ {
6717
+ if (attr.value .ptr == NULL && saiAttr->getSaiAttr ()->value .ptr == NULL )
6718
+ continue ;
6719
+
6720
+ if (attr.value .ptr != NULL && saiAttr->getSaiAttr ()->value .ptr != NULL )
6721
+ continue ;
6722
+ }
6723
+
6724
+ if (asicValue == dbValue)
6725
+ continue ;
6726
+
6727
+ SWSS_LOG_ERROR (" value missmatch: %s on %s: ASIC: %s DB: %s, inconsistent state!" ,
6728
+ meta->attridname ,
6729
+ obj->str_object_id .c_str (),
6730
+ asicValue.c_str (),
6731
+ dbValue.c_str ());
6732
+
6733
+ hasErrors = true ;
6734
+ }
6735
+ }
6736
+
6737
+ swss::Logger::getInstance ().setMinPrio (swss::Logger::SWSS_INFO);
6738
+ }
6739
+
6740
+ swss::Logger::getInstance ().setMinPrio (swss::Logger::SWSS_NOTICE);
6741
+
6742
+ if (hasErrors && enableUnittests ())
6743
+ {
6744
+ SWSS_LOG_THROW (" ASIC content is differnt than DB content!" );
6745
+ }
6746
+ }
6747
+
6576
6748
sai_status_t syncdApplyView ()
6577
6749
{
6578
6750
SWSS_LOG_ENTER ();
@@ -6792,6 +6964,11 @@ sai_status_t syncdApplyView()
6792
6964
6793
6965
updateRedisDatabase (current, temp);
6794
6966
6967
+ if (g_enableConsistencyCheck)
6968
+ {
6969
+ checkAsicVsDatabaseConsistency (current, temp);
6970
+ }
6971
+
6795
6972
return SAI_STATUS_SUCCESS;
6796
6973
}
6797
6974
@@ -6845,6 +7022,8 @@ sai_object_id_t asic_translate_vid_to_rid(
6845
7022
6846
7023
sai_object_id_t rid = currentIt->second ;
6847
7024
7025
+ SWSS_LOG_INFO (" translated VID 0x%lx to RID 0x%lx" , vid, rid);
7026
+
6848
7027
return rid;
6849
7028
}
6850
7029
@@ -7099,6 +7278,14 @@ void asic_translate_vid_to_rid_non_object_id(
7099
7278
7100
7279
auto info = sai_metadata_get_object_type_info (meta_key.objecttype );
7101
7280
7281
+ if (info->isobjectid )
7282
+ {
7283
+ meta_key.objectkey .key .object_id =
7284
+ asic_translate_vid_to_rid (current, temporary, meta_key.objectkey .key .object_id );
7285
+
7286
+ return ;
7287
+ }
7288
+
7102
7289
for (size_t idx = 0 ; idx < info->structmemberscount ; ++idx)
7103
7290
{
7104
7291
const sai_struct_member_info_t *m = info->structmembers [idx];
0 commit comments