@@ -562,8 +562,39 @@ std::string L3MulticastManager::verifyMulticastRouterInterfaceState(
562562std::string L3MulticastManager::verifyMulticastReplicationState (
563563 const std::string& key,
564564 const std::vector<swss::FieldValueTuple>& tuple) {
565- return " L3MulticastManager::verifyMulticastReplicationState is not "
566- " implemented" ;
565+ auto app_db_entry_or = deserializeMulticastReplicationEntry (key, tuple);
566+ if (!app_db_entry_or.ok ()) {
567+ ReturnCode status = app_db_entry_or.status ();
568+ std::stringstream msg;
569+ msg << " Unable to deserialize key " << QuotedVar (key) << " : "
570+ << status.message ();
571+ return msg.str ();
572+ }
573+ auto & app_db_entry = *app_db_entry_or;
574+
575+ const std::string replication_entry_key =
576+ KeyGenerator::generateMulticastReplicationKey (
577+ app_db_entry.multicast_group_id , app_db_entry.multicast_replica_port ,
578+ app_db_entry.multicast_replica_instance );
579+ auto * replication_entry_ptr =
580+ getMulticastReplicationEntry (replication_entry_key);
581+ if (replication_entry_ptr == nullptr ) {
582+ std::stringstream msg;
583+ msg << " No entry found with key " << QuotedVar (key);
584+ return msg.str ();
585+ }
586+
587+ std::string cache_result =
588+ verifyMulticastReplicationStateCache (app_db_entry, replication_entry_ptr);
589+ std::string asic_db_result =
590+ verifyMulticastReplicationStateAsicDb (replication_entry_ptr);
591+ if (cache_result.empty ()) {
592+ return asic_db_result;
593+ }
594+ if (asic_db_result.empty ()) {
595+ return cache_result;
596+ }
597+ return cache_result + " ; " + asic_db_result;
567598}
568599
569600ReturnCode L3MulticastManager::validateMulticastRouterInterfaceEntry (
@@ -1710,14 +1741,128 @@ std::string L3MulticastManager::verifyMulticastRouterInterfaceStateAsicDb(
17101741std::string L3MulticastManager::verifyMulticastReplicationStateCache (
17111742 const P4MulticastReplicationEntry& app_db_entry,
17121743 const P4MulticastReplicationEntry* multicast_replication_entry) {
1713- return " L3MulticastManager::verifyMulticastReplicationStateCache is not "
1714- " implemented" ;
1744+ const std::string replication_entry_key =
1745+ KeyGenerator::generateMulticastReplicationKey (
1746+ app_db_entry.multicast_group_id , app_db_entry.multicast_replica_port ,
1747+ app_db_entry.multicast_replica_instance );
1748+
1749+ ReturnCode status =
1750+ validateMulticastReplicationEntry (app_db_entry, SET_COMMAND);
1751+ if (!status.ok ()) {
1752+ std::stringstream msg;
1753+ msg << " Validation failed for multicast replication DB entry with key "
1754+ << QuotedVar (replication_entry_key) << " : " << status.message ();
1755+ return msg.str ();
1756+ }
1757+ if (multicast_replication_entry->multicast_replication_key !=
1758+ app_db_entry.multicast_replication_key ) {
1759+ std::stringstream msg;
1760+ msg << " Multicast replication entry key "
1761+ << QuotedVar (app_db_entry.multicast_replication_key )
1762+ << " does not match internal cache "
1763+ << QuotedVar (multicast_replication_entry->multicast_replication_key )
1764+ << " in l3 multicast manager for replication entry." ;
1765+ return msg.str ();
1766+ }
1767+ if (multicast_replication_entry->multicast_group_id !=
1768+ app_db_entry.multicast_group_id ) {
1769+ std::stringstream msg;
1770+ msg << " Multicast group ID " << QuotedVar (app_db_entry.multicast_group_id )
1771+ << " does not match internal cache "
1772+ << QuotedVar (multicast_replication_entry->multicast_group_id )
1773+ << " in l3 multicast manager for replication entry." ;
1774+ return msg.str ();
1775+ }
1776+ if (multicast_replication_entry->multicast_replica_port !=
1777+ app_db_entry.multicast_replica_port ) {
1778+ std::stringstream msg;
1779+ msg << " Output port name " << QuotedVar (app_db_entry.multicast_replica_port )
1780+ << " does not match internal cache "
1781+ << QuotedVar (multicast_replication_entry->multicast_replica_port )
1782+ << " in l3 multicast manager for replication entry." ;
1783+ return msg.str ();
1784+ }
1785+ if (multicast_replication_entry->multicast_replica_instance !=
1786+ app_db_entry.multicast_replica_instance ) {
1787+ std::stringstream msg;
1788+ msg << " Egress instance "
1789+ << QuotedVar (app_db_entry.multicast_replica_instance )
1790+ << " does not match internal cache "
1791+ << QuotedVar (multicast_replication_entry->multicast_replica_instance )
1792+ << " in l3 multicast manager for replication entry." ;
1793+ return msg.str ();
1794+ }
1795+ if (multicast_replication_entry->multicast_metadata !=
1796+ app_db_entry.multicast_metadata ) {
1797+ std::stringstream msg;
1798+ msg << " Multicast metadata " << QuotedVar (app_db_entry.multicast_metadata )
1799+ << " does not match internal cache "
1800+ << QuotedVar (multicast_replication_entry->multicast_metadata )
1801+ << " in l3 multicast manager for replication entry." ;
1802+ return msg.str ();
1803+ }
1804+ std::string group_msg = m_p4OidMapper->verifyOIDMapping (
1805+ SAI_OBJECT_TYPE_IPMC_GROUP,
1806+ multicast_replication_entry->multicast_group_id ,
1807+ multicast_replication_entry->multicast_group_oid );
1808+ if (!group_msg.empty ()) {
1809+ return group_msg;
1810+ }
1811+ return m_p4OidMapper->verifyOIDMapping (
1812+ SAI_OBJECT_TYPE_IPMC_GROUP_MEMBER,
1813+ multicast_replication_entry->multicast_replication_key ,
1814+ multicast_replication_entry->multicast_group_member_oid );
17151815}
17161816
17171817std::string L3MulticastManager::verifyMulticastReplicationStateAsicDb (
17181818 const P4MulticastReplicationEntry* multicast_replication_entry) {
1719- return " L3MulticastManager::verifyMulticastReplicationStateAsicDb is not "
1720- " implemented" ;
1819+ // Confirm have RIF.
1820+ sai_object_id_t rif_oid = getRifOid (multicast_replication_entry);
1821+ if (rif_oid == SAI_NULL_OBJECT_ID) {
1822+ std::stringstream msg;
1823+ msg << " Unable to find RIF associated with multicast entry "
1824+ << QuotedVar (multicast_replication_entry->multicast_replication_key );
1825+ return msg.str ();
1826+ }
1827+
1828+ // Confirm group settings.
1829+ std::vector<sai_attribute_t > group_attrs; // no required attributes
1830+ std::vector<swss::FieldValueTuple> exp =
1831+ saimeta::SaiAttributeList::serialize_attr_list (
1832+ SAI_OBJECT_TYPE_IPMC_GROUP_MEMBER, (uint32_t )group_attrs.size (),
1833+ group_attrs.data (), /* countOnly=*/ false );
1834+
1835+ swss::DBConnector db (" ASIC_DB" , 0 );
1836+ swss::Table table (&db, " ASIC_STATE" );
1837+ std::string key =
1838+ sai_serialize_object_type (SAI_OBJECT_TYPE_IPMC_GROUP) + " :" +
1839+ sai_serialize_object_id (multicast_replication_entry->multicast_group_oid );
1840+ std::vector<swss::FieldValueTuple> values;
1841+ if (!table.get (key, values)) {
1842+ return std::string (" ASIC DB key not found " ) + key;
1843+ }
1844+ std::string group_msg =
1845+ verifyAttrs (values, exp, std::vector<swss::FieldValueTuple>{},
1846+ /* allow_unknown=*/ false );
1847+ if (!group_msg.empty ()) {
1848+ return group_msg;
1849+ }
1850+
1851+ // Confirm group member settings.
1852+ auto member_attrs = prepareMulticastGroupMemberSaiAttrs (
1853+ *multicast_replication_entry, rif_oid);
1854+ exp = saimeta::SaiAttributeList::serialize_attr_list (
1855+ SAI_OBJECT_TYPE_IPMC_GROUP_MEMBER, (uint32_t )member_attrs.size (),
1856+ member_attrs.data (), /* countOnly=*/ false );
1857+ key = sai_serialize_object_type (SAI_OBJECT_TYPE_IPMC_GROUP_MEMBER) + " :" +
1858+ sai_serialize_object_id (
1859+ multicast_replication_entry->multicast_group_member_oid );
1860+ values.clear ();
1861+ if (!table.get (key, values)) {
1862+ return std::string (" ASIC DB key not found " ) + key;
1863+ }
1864+ return verifyAttrs (values, exp, std::vector<swss::FieldValueTuple>{},
1865+ /* allow_unknown=*/ false );
17211866}
17221867
17231868P4MulticastRouterInterfaceEntry*
0 commit comments