@@ -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 (
@@ -1703,14 +1734,128 @@ std::string L3MulticastManager::verifyMulticastRouterInterfaceStateAsicDb(
17031734std::string L3MulticastManager::verifyMulticastReplicationStateCache (
17041735 const P4MulticastReplicationEntry& app_db_entry,
17051736 const P4MulticastReplicationEntry* multicast_replication_entry) {
1706- return " L3MulticastManager::verifyMulticastReplicationStateCache is not "
1707- " implemented" ;
1737+ const std::string replication_entry_key =
1738+ KeyGenerator::generateMulticastReplicationKey (
1739+ app_db_entry.multicast_group_id , app_db_entry.multicast_replica_port ,
1740+ app_db_entry.multicast_replica_instance );
1741+
1742+ ReturnCode status =
1743+ validateMulticastReplicationEntry (app_db_entry, SET_COMMAND);
1744+ if (!status.ok ()) {
1745+ std::stringstream msg;
1746+ msg << " Validation failed for multicast replication DB entry with key "
1747+ << QuotedVar (replication_entry_key) << " : " << status.message ();
1748+ return msg.str ();
1749+ }
1750+ if (multicast_replication_entry->multicast_replication_key !=
1751+ app_db_entry.multicast_replication_key ) {
1752+ std::stringstream msg;
1753+ msg << " Multicast replication entry key "
1754+ << QuotedVar (app_db_entry.multicast_replication_key )
1755+ << " does not match internal cache "
1756+ << QuotedVar (multicast_replication_entry->multicast_replication_key )
1757+ << " in l3 multicast manager for replication entry." ;
1758+ return msg.str ();
1759+ }
1760+ if (multicast_replication_entry->multicast_group_id !=
1761+ app_db_entry.multicast_group_id ) {
1762+ std::stringstream msg;
1763+ msg << " Multicast group ID " << QuotedVar (app_db_entry.multicast_group_id )
1764+ << " does not match internal cache "
1765+ << QuotedVar (multicast_replication_entry->multicast_group_id )
1766+ << " in l3 multicast manager for replication entry." ;
1767+ return msg.str ();
1768+ }
1769+ if (multicast_replication_entry->multicast_replica_port !=
1770+ app_db_entry.multicast_replica_port ) {
1771+ std::stringstream msg;
1772+ msg << " Output port name " << QuotedVar (app_db_entry.multicast_replica_port )
1773+ << " does not match internal cache "
1774+ << QuotedVar (multicast_replication_entry->multicast_replica_port )
1775+ << " in l3 multicast manager for replication entry." ;
1776+ return msg.str ();
1777+ }
1778+ if (multicast_replication_entry->multicast_replica_instance !=
1779+ app_db_entry.multicast_replica_instance ) {
1780+ std::stringstream msg;
1781+ msg << " Egress instance "
1782+ << QuotedVar (app_db_entry.multicast_replica_instance )
1783+ << " does not match internal cache "
1784+ << QuotedVar (multicast_replication_entry->multicast_replica_instance )
1785+ << " in l3 multicast manager for replication entry." ;
1786+ return msg.str ();
1787+ }
1788+ if (multicast_replication_entry->multicast_metadata !=
1789+ app_db_entry.multicast_metadata ) {
1790+ std::stringstream msg;
1791+ msg << " Multicast metadata " << QuotedVar (app_db_entry.multicast_metadata )
1792+ << " does not match internal cache "
1793+ << QuotedVar (multicast_replication_entry->multicast_metadata )
1794+ << " in l3 multicast manager for replication entry." ;
1795+ return msg.str ();
1796+ }
1797+ std::string group_msg = m_p4OidMapper->verifyOIDMapping (
1798+ SAI_OBJECT_TYPE_IPMC_GROUP,
1799+ multicast_replication_entry->multicast_group_id ,
1800+ multicast_replication_entry->multicast_group_oid );
1801+ if (!group_msg.empty ()) {
1802+ return group_msg;
1803+ }
1804+ return m_p4OidMapper->verifyOIDMapping (
1805+ SAI_OBJECT_TYPE_IPMC_GROUP_MEMBER,
1806+ multicast_replication_entry->multicast_replication_key ,
1807+ multicast_replication_entry->multicast_group_member_oid );
17081808}
17091809
17101810std::string L3MulticastManager::verifyMulticastReplicationStateAsicDb (
17111811 const P4MulticastReplicationEntry* multicast_replication_entry) {
1712- return " L3MulticastManager::verifyMulticastReplicationStateAsicDb is not "
1713- " implemented" ;
1812+ // Confirm have RIF.
1813+ sai_object_id_t rif_oid = getRifOid (multicast_replication_entry);
1814+ if (rif_oid == SAI_NULL_OBJECT_ID) {
1815+ std::stringstream msg;
1816+ msg << " Unable to find RIF associated with multicast entry "
1817+ << QuotedVar (multicast_replication_entry->multicast_replication_key );
1818+ return msg.str ();
1819+ }
1820+
1821+ // Confirm group settings.
1822+ std::vector<sai_attribute_t > group_attrs; // no required attributes
1823+ std::vector<swss::FieldValueTuple> exp =
1824+ saimeta::SaiAttributeList::serialize_attr_list (
1825+ SAI_OBJECT_TYPE_IPMC_GROUP_MEMBER, (uint32_t )group_attrs.size (),
1826+ group_attrs.data (), /* countOnly=*/ false );
1827+
1828+ swss::DBConnector db (" ASIC_DB" , 0 );
1829+ swss::Table table (&db, " ASIC_STATE" );
1830+ std::string key =
1831+ sai_serialize_object_type (SAI_OBJECT_TYPE_IPMC_GROUP) + " :" +
1832+ sai_serialize_object_id (multicast_replication_entry->multicast_group_oid );
1833+ std::vector<swss::FieldValueTuple> values;
1834+ if (!table.get (key, values)) {
1835+ return std::string (" ASIC DB key not found " ) + key;
1836+ }
1837+ std::string group_msg =
1838+ verifyAttrs (values, exp, std::vector<swss::FieldValueTuple>{},
1839+ /* allow_unknown=*/ false );
1840+ if (!group_msg.empty ()) {
1841+ return group_msg;
1842+ }
1843+
1844+ // Confirm group member settings.
1845+ auto member_attrs = prepareMulticastGroupMemberSaiAttrs (
1846+ *multicast_replication_entry, rif_oid);
1847+ exp = saimeta::SaiAttributeList::serialize_attr_list (
1848+ SAI_OBJECT_TYPE_IPMC_GROUP_MEMBER, (uint32_t )member_attrs.size (),
1849+ member_attrs.data (), /* countOnly=*/ false );
1850+ key = sai_serialize_object_type (SAI_OBJECT_TYPE_IPMC_GROUP_MEMBER) + " :" +
1851+ sai_serialize_object_id (
1852+ multicast_replication_entry->multicast_group_member_oid );
1853+ values.clear ();
1854+ if (!table.get (key, values)) {
1855+ return std::string (" ASIC DB key not found " ) + key;
1856+ }
1857+ return verifyAttrs (values, exp, std::vector<swss::FieldValueTuple>{},
1858+ /* allow_unknown=*/ false );
17141859}
17151860
17161861P4MulticastRouterInterfaceEntry*
0 commit comments