@@ -2641,8 +2641,8 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForAclTableGroup(
2641
2641
if (c.obj ->getVid () == atgVid)
2642
2642
{
2643
2643
SWSS_LOG_INFO (" found ALC table group candidate %s using port %s" ,
2644
- port ->str_object_id .c_str (),
2645
- c. obj ->str_object_id .c_str ());
2644
+ c. obj ->str_object_id .c_str (),
2645
+ port ->str_object_id .c_str ());
2646
2646
2647
2647
return c.obj ;
2648
2648
}
@@ -2736,6 +2736,101 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForAclTableGroup(
2736
2736
return nullptr ;
2737
2737
}
2738
2738
2739
+ std::shared_ptr<SaiObj> findCurrentBestMatchForAclTable (
2740
+ _In_ const AsicView ¤tView,
2741
+ _In_ const AsicView &temporaryView,
2742
+ _In_ const std::shared_ptr<const SaiObj> &temporaryObj,
2743
+ _In_ const std::vector<sai_object_compare_info_t > &candidateObjects)
2744
+ {
2745
+ SWSS_LOG_ENTER ();
2746
+
2747
+ /*
2748
+ * For acl table we can go to acl table group member and then to acl table group and port.
2749
+ */
2750
+
2751
+ const auto tmpAclTableGroupMembers = temporaryView.getObjectsByObjectType (SAI_OBJECT_TYPE_ACL_TABLE_GROUP_MEMBER);
2752
+
2753
+ for (auto tmpAclTableGroupMember: tmpAclTableGroupMembers)
2754
+ {
2755
+ auto tmpAclTableId = tmpAclTableGroupMember->getSaiAttr (SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_ID);
2756
+
2757
+ if (tmpAclTableId->getOid () != temporaryObj->getVid ())
2758
+ {
2759
+ // this is not the expected alc table group member
2760
+ continue ;
2761
+ }
2762
+
2763
+ auto tmpAclTableGroupId = tmpAclTableGroupMember->getSaiAttr (SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_GROUP_ID);
2764
+
2765
+ /*
2766
+ * We have acl table group id, search on which port it's set, not let's
2767
+ * find on which port it's set.
2768
+ */
2769
+
2770
+ const auto tmpPorts = temporaryView.getObjectsByObjectType (SAI_OBJECT_TYPE_PORT);
2771
+
2772
+ for (auto tmpPort: tmpPorts)
2773
+ {
2774
+ if (!tmpPort->hasAttr (SAI_PORT_ATTR_INGRESS_ACL))
2775
+ continue ;
2776
+
2777
+ auto tmpInACL = tmpPort->getSaiAttr (SAI_PORT_ATTR_INGRESS_ACL);
2778
+
2779
+ if (tmpInACL->getOid () != tmpAclTableGroupId->getOid ())
2780
+ continue ;
2781
+
2782
+ auto curPort = currentView.oOids .at (tmpPort->getVid ());
2783
+
2784
+ if (!curPort->hasAttr (SAI_PORT_ATTR_INGRESS_ACL))
2785
+ continue ;
2786
+
2787
+ auto curInACL = curPort->getSaiAttr (SAI_PORT_ATTR_INGRESS_ACL);
2788
+
2789
+ /*
2790
+ * We found current InACL, now let's find acl table group members
2791
+ * that use this acl table group.
2792
+ */
2793
+
2794
+ const auto curAclTableGroupMembers = currentView.getObjectsByObjectType (SAI_OBJECT_TYPE_ACL_TABLE_GROUP_MEMBER);
2795
+
2796
+ for (auto curAclTableGroupMember: curAclTableGroupMembers)
2797
+ {
2798
+ auto curAclTableGroupId = curAclTableGroupMember->getSaiAttr (SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_GROUP_ID);
2799
+
2800
+ if (curAclTableGroupId->getOid () != curInACL->getOid ())
2801
+ {
2802
+ // this member uses different acl table group
2803
+ continue ;
2804
+ }
2805
+
2806
+ auto curAclTableId = curAclTableGroupMember->getSaiAttr (SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_ID);
2807
+
2808
+ /*
2809
+ * We found possible current acl table ID, let's see if it's on
2810
+ * candidate list. Note, it could be possible that many
2811
+ * different paths will lead multiple possible candidates.
2812
+ */
2813
+
2814
+ for (auto c: candidateObjects)
2815
+ {
2816
+ if (c.obj ->getVid () == curAclTableId->getOid ())
2817
+ {
2818
+ SWSS_LOG_INFO (" found ALC table candidate %s using port %s" ,
2819
+ c.obj ->str_object_id .c_str (),
2820
+ tmpPort->str_object_id .c_str ());
2821
+
2822
+ return c.obj ;
2823
+ }
2824
+ }
2825
+ }
2826
+ }
2827
+ }
2828
+
2829
+ SWSS_LOG_NOTICE (" failed to find best candidate for ACL table using port" );
2830
+
2831
+ return nullptr ;
2832
+ }
2833
+
2739
2834
std::shared_ptr<SaiObj> findCurrentBestMatchForRouterInterface (
2740
2835
_In_ const AsicView ¤tView,
2741
2836
_In_ const AsicView &temporaryView,
@@ -3154,6 +3249,10 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObjectUsingHeuristic(
3154
3249
candidate = findCurrentBestMatchForHostifTrapGroup (currentView, temporaryView, temporaryObj, candidateObjects);
3155
3250
break ;
3156
3251
3252
+ case SAI_OBJECT_TYPE_ACL_TABLE:
3253
+ candidate = findCurrentBestMatchForAclTable (currentView, temporaryView, temporaryObj, candidateObjects);
3254
+ break ;
3255
+
3157
3256
default :
3158
3257
break ;
3159
3258
}
@@ -3203,6 +3302,10 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObjectUsingHeuristic(
3203
3302
return selectRandomCandidate (candidateObjects);
3204
3303
}
3205
3304
3305
+ std::shared_ptr<SaiAttr> getSaiAttrFromDefaultValue (
3306
+ _In_ const AsicView ¤tView,
3307
+ _In_ const sai_attr_metadata_t &meta);
3308
+
3206
3309
std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObject (
3207
3310
_In_ const AsicView ¤tView,
3208
3311
_In_ const AsicView &temporaryView,
@@ -3314,6 +3417,13 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObject(
3314
3417
3315
3418
bool has_different_create_only_attr = false ;
3316
3419
3420
+ /*
3421
+ * NOTE: we only iterate by attributes that are present in temporary
3422
+ * view. It may happen that current view has some additional attributes
3423
+ * set that are create only and value can't be updated then, so in that
3424
+ * case such object must be disqualified from being candidate.
3425
+ */
3426
+
3317
3427
for (const auto &attr: attrs)
3318
3428
{
3319
3429
sai_attr_id_t attrId = attr.first ;
@@ -3378,6 +3488,85 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForGenericObject(
3378
3488
3379
3489
break ;
3380
3490
}
3491
+
3492
+ if (SAI_HAS_FLAG_CREATE_ONLY (meta->flags ) && !currentObj->hasAttr (attrId))
3493
+ {
3494
+ /*
3495
+ * This attribute exists only on temporary view and it's
3496
+ * create only. If it has default value, check if it's the
3497
+ * same as current.
3498
+ */
3499
+
3500
+ auto curDefault = getSaiAttrFromDefaultValue (currentView, *meta);
3501
+
3502
+ if (curDefault != nullptr )
3503
+ {
3504
+ if (curDefault->getStrAttrValue () != attr.second ->getStrAttrValue ())
3505
+ {
3506
+ has_different_create_only_attr = true ;
3507
+
3508
+ SWSS_LOG_INFO (" obj has not equal create only attributes %s (default): %s" ,
3509
+ temporaryObj->str_object_id .c_str (),
3510
+ meta->attridname );
3511
+ break ;
3512
+ }
3513
+ else
3514
+ {
3515
+ SWSS_LOG_INFO (" obj has equal create only value %s (default): %s" ,
3516
+ temporaryObj->str_object_id .c_str (),
3517
+ meta->attridname );
3518
+ }
3519
+ }
3520
+ }
3521
+ }
3522
+ }
3523
+
3524
+ /*
3525
+ * Before we add this object as candidate, see if there are some create
3526
+ * only attributes which are not present in temporary object but
3527
+ * present in current, and if there is default value that is the same.
3528
+ */
3529
+
3530
+ const auto curAttrs = currentObj->getAllAttributes ();
3531
+
3532
+ for (auto curAttr: curAttrs)
3533
+ {
3534
+ if (attrs.find (curAttr.first ) != attrs.end ())
3535
+ {
3536
+ // attr exists in both objects.
3537
+ continue ;
3538
+ }
3539
+
3540
+ const sai_attr_metadata_t * meta = curAttr.second ->getAttrMetadata ();
3541
+
3542
+ if (SAI_HAS_FLAG_CREATE_ONLY (meta->flags ) && !temporaryObj->hasAttr (curAttr.first ))
3543
+ {
3544
+ /*
3545
+ * This attribute exists only on current view and it's
3546
+ * create only. If it has default value, check if it's the
3547
+ * same as current.
3548
+ */
3549
+
3550
+ auto tmpDefault = getSaiAttrFromDefaultValue (temporaryView, *meta);
3551
+
3552
+ if (tmpDefault != nullptr )
3553
+ {
3554
+ if (tmpDefault->getStrAttrValue () != curAttr.second ->getStrAttrValue ())
3555
+ {
3556
+ has_different_create_only_attr = true ;
3557
+
3558
+ SWSS_LOG_INFO (" obj has not equal create only attributes %s (default): %s" ,
3559
+ currentObj->str_object_id .c_str (),
3560
+ meta->attridname );
3561
+ break ;
3562
+ }
3563
+ else
3564
+ {
3565
+ SWSS_LOG_INFO (" obj has equal create only value %s (default): %s" ,
3566
+ temporaryObj->str_object_id .c_str (),
3567
+ meta->attridname );
3568
+ }
3569
+ }
3381
3570
}
3382
3571
}
3383
3572
@@ -4019,10 +4208,6 @@ void procesObjectAttributesForViewTransition(
4019
4208
}
4020
4209
}
4021
4210
4022
- std::shared_ptr<SaiAttr> getSaiAttrFromDefaultValue (
4023
- _In_ const AsicView ¤tView,
4024
- _In_ const sai_attr_metadata_t &meta);
4025
-
4026
4211
void bringNonRemovableObjectToDefaultState (
4027
4212
_In_ AsicView ¤tView,
4028
4213
_In_ const std::shared_ptr<SaiObj> ¤tObj)
@@ -4885,6 +5070,14 @@ std::shared_ptr<SaiAttr> getSaiAttrFromDefaultValue(
4885
5070
4886
5071
return nullptr ;
4887
5072
5073
+ case SAI_DEFAULT_VALUE_TYPE_NONE:
5074
+
5075
+ /*
5076
+ * No default value present.
5077
+ */
5078
+
5079
+ return nullptr ;
5080
+
4888
5081
default :
4889
5082
4890
5083
SWSS_LOG_ERROR (" default value type %d is not supported yet for %s, FIXME" ,
@@ -5479,6 +5672,8 @@ void processObjectForViewTransition(
5479
5672
return ;
5480
5673
}
5481
5674
5675
+ SWSS_LOG_DEBUG (" processing: %s:%s" , temporaryObj->str_object_type .c_str (), temporaryObj->str_object_id .c_str ());
5676
+
5482
5677
procesObjectAttributesForViewTransition (currentView, temporaryView, temporaryObj);
5483
5678
5484
5679
/*
0 commit comments