@@ -2366,6 +2366,144 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForNextHopGroup(
23662366 return nullptr ;
23672367}
23682368
2369+ std::shared_ptr<SaiObj> findCurrentBestMatchForAclTableGroup (
2370+ _In_ const AsicView ¤tView,
2371+ _In_ const AsicView &temporaryView,
2372+ _In_ const std::shared_ptr<const SaiObj> &temporaryObj,
2373+ _In_ const std::vector<sai_object_compare_info_t > &candidateObjects)
2374+ {
2375+ SWSS_LOG_ENTER ();
2376+
2377+ /*
2378+ * Since we know that ports are matched, they have same VID/RID in both
2379+ * temporary and current view.
2380+ */
2381+
2382+ const auto ports = temporaryView.getObjectsByObjectType (SAI_OBJECT_TYPE_PORT);
2383+
2384+ for (auto port: ports)
2385+ {
2386+ if (!port->hasAttr (SAI_PORT_ATTR_INGRESS_ACL))
2387+ continue ;
2388+
2389+ auto inACL = port->getSaiAttr (SAI_PORT_ATTR_INGRESS_ACL);
2390+
2391+ if (inACL->getSaiAttr ()->value .oid != temporaryObj->getVid ())
2392+ continue ;
2393+
2394+ SWSS_LOG_DEBUG (" found port candidate %s for ACL table group" ,
2395+ port->str_object_id .c_str ());
2396+
2397+
2398+ auto curPort = currentView.oOids .at (port->getVid ());
2399+
2400+ if (!curPort->hasAttr (SAI_PORT_ATTR_INGRESS_ACL))
2401+ continue ;
2402+
2403+ inACL = curPort->getSaiAttr (SAI_PORT_ATTR_INGRESS_ACL);
2404+
2405+ sai_object_id_t atgVid = inACL->getSaiAttr ()->value .oid ;
2406+
2407+ for (auto c: candidateObjects)
2408+ {
2409+ if (c.obj ->getVid () == atgVid)
2410+ {
2411+ SWSS_LOG_INFO (" found ALC table group candidate %s using port %s" ,
2412+ port->str_object_id .c_str (),
2413+ c.obj ->str_object_id .c_str ());
2414+
2415+ return c.obj ;
2416+ }
2417+ }
2418+ }
2419+
2420+ /*
2421+ * Port didn't work, try to find match by LAG, but lag will be tricky,
2422+ * since it will be not matched since if this unprocessed acl table group
2423+ * is processed right now, then if it's assigned to lag then by design we
2424+ * go recursivly be attributes to match attributes first.
2425+ */
2426+
2427+ // TODO this could be helper method, since we will need this for router interface
2428+
2429+ const auto tmpLags = temporaryView.getObjectsByObjectType (SAI_OBJECT_TYPE_LAG);
2430+
2431+ for (auto tmpLag: tmpLags)
2432+ {
2433+ if (!tmpLag->hasAttr (SAI_LAG_ATTR_INGRESS_ACL))
2434+ continue ;
2435+
2436+ auto inACL = tmpLag->getSaiAttr (SAI_LAG_ATTR_INGRESS_ACL);
2437+
2438+ if (inACL->getSaiAttr ()->value .oid != temporaryObj->getVid ())
2439+ continue ;
2440+
2441+ /*
2442+ * We found LAG on which this ACL is present, but this object status is
2443+ * not processed so we need to trace back to port using LAG member.
2444+ */
2445+
2446+ SWSS_LOG_INFO (" found LAG candidate: lag status %d" , tmpLag->getObjectStatus ());
2447+
2448+ const auto tmpLagMembers = temporaryView.getNotProcessedObjectsByObjectType (SAI_OBJECT_TYPE_LAG_MEMBER);
2449+
2450+ for (auto tmpLagMember: tmpLagMembers)
2451+ {
2452+ const auto tmpLagMemberLagAttr = tmpLagMember->getSaiAttr (SAI_LAG_MEMBER_ATTR_LAG_ID);
2453+
2454+ if (tmpLagMemberLagAttr->getSaiAttr ()->value .oid != tmpLag->getVid ())
2455+ continue ;
2456+
2457+ const auto tmpLagMemberPortAttr = tmpLagMember->getSaiAttr (SAI_LAG_MEMBER_ATTR_PORT_ID);
2458+
2459+ sai_object_id_t tmpPortVid = tmpLagMemberPortAttr->getSaiAttr ()->value .oid ;
2460+
2461+ SWSS_LOG_INFO (" found tmp LAG member port! %s" , sai_serialize_object_id (tmpPortVid).c_str ());
2462+
2463+ sai_object_id_t portRid = temporaryView.vidToRid .at (tmpPortVid);
2464+
2465+ sai_object_id_t curPortVid = currentView.ridToVid .at (portRid);
2466+
2467+ const auto curLagMembers = currentView.getNotProcessedObjectsByObjectType (SAI_OBJECT_TYPE_LAG_MEMBER);
2468+
2469+ for (auto curLagMember: curLagMembers)
2470+ {
2471+ const auto curLagMemberPortAttr = curLagMember->getSaiAttr (SAI_LAG_MEMBER_ATTR_PORT_ID);
2472+
2473+ if (curLagMemberPortAttr->getSaiAttr ()->value .oid != curPortVid)
2474+ continue ;
2475+
2476+ const auto curLagMemberLagAttr = curLagMember->getSaiAttr (SAI_LAG_MEMBER_ATTR_LAG_ID);
2477+
2478+ sai_object_id_t curLagId = curLagMemberLagAttr->getSaiAttr ()->value .oid ;
2479+
2480+ SWSS_LOG_INFO (" found current LAG member: %s" , curLagMember->str_object_id .c_str ());
2481+
2482+ auto curLag = currentView.oOids .at (curLagId);
2483+
2484+ if (!curLag->hasAttr (SAI_LAG_ATTR_INGRESS_ACL))
2485+ continue ;
2486+
2487+ inACL = curLag->getSaiAttr (SAI_LAG_ATTR_INGRESS_ACL);
2488+
2489+ for (auto c: candidateObjects)
2490+ {
2491+ if (c.obj ->getVid () != inACL->getSaiAttr ()->value .oid )
2492+ continue ;
2493+
2494+ SWSS_LOG_INFO (" found best ACL table group match based on LAG ingress acl: %s" , c.obj ->str_object_id .c_str ());
2495+
2496+ return c.obj ;
2497+ }
2498+ }
2499+ }
2500+ }
2501+
2502+ SWSS_LOG_NOTICE (" failed to find best candidate for ACL table group using port" );
2503+
2504+ return nullptr ;
2505+ }
2506+
23692507std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObjectUsingHeuristic (
23702508 _In_ const AsicView ¤tView,
23712509 _In_ const AsicView &temporaryView,
@@ -2402,6 +2540,18 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObjectUsingHeuristic(
24022540 return candidateNHG;
24032541 }
24042542
2543+ if (temporaryObj->getObjectType () == SAI_OBJECT_TYPE_ACL_TABLE_GROUP)
2544+ {
2545+ /*
2546+ * For acl table group let's try find matching INGRESS_ACL on matched PORT.
2547+ */
2548+
2549+ std::shared_ptr<SaiObj> candidateATG = findCurrentBestMatchForAclTableGroup (currentView, temporaryView, temporaryObj, candidateObjects);
2550+
2551+ if (candidateATG != nullptr )
2552+ return candidateATG;
2553+ }
2554+
24052555 /*
24062556 * Idea is to count all dependencies that uses this object. this may not
24072557 * be a good approach since logic may choose wrong candidate.
0 commit comments