diff --git a/syncd/syncd_applyview.cpp b/syncd/syncd_applyview.cpp index 80c6523424c3..ee89cfede288 100644 --- a/syncd/syncd_applyview.cpp +++ b/syncd/syncd_applyview.cpp @@ -2641,8 +2641,8 @@ std::shared_ptr findCurrentBestMatchForAclTableGroup( if (c.obj->getVid() == atgVid) { SWSS_LOG_INFO("found ALC table group candidate %s using port %s", - port->str_object_id.c_str(), - c.obj->str_object_id.c_str()); + c.obj->str_object_id.c_str(), + port->str_object_id.c_str()); return c.obj; } @@ -2736,6 +2736,101 @@ std::shared_ptr findCurrentBestMatchForAclTableGroup( return nullptr; } +std::shared_ptr findCurrentBestMatchForAclTable( + _In_ const AsicView ¤tView, + _In_ const AsicView &temporaryView, + _In_ const std::shared_ptr &temporaryObj, + _In_ const std::vector &candidateObjects) +{ + SWSS_LOG_ENTER(); + + /* + * For acl table we can go to acl table group member and then to acl table group and port. + */ + + const auto tmpAclTableGroupMembers = temporaryView.getObjectsByObjectType(SAI_OBJECT_TYPE_ACL_TABLE_GROUP_MEMBER); + + for (auto tmpAclTableGroupMember: tmpAclTableGroupMembers) + { + auto tmpAclTableId = tmpAclTableGroupMember->getSaiAttr(SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_ID); + + if (tmpAclTableId->getOid() != temporaryObj->getVid()) + { + // this is not the expected alc table group member + continue; + } + + auto tmpAclTableGroupId = tmpAclTableGroupMember->getSaiAttr(SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_GROUP_ID); + + /* + * We have acl table group id, search on which port it's set, not let's + * find on which port it's set. + */ + + const auto tmpPorts = temporaryView.getObjectsByObjectType(SAI_OBJECT_TYPE_PORT); + + for (auto tmpPort: tmpPorts) + { + if (!tmpPort->hasAttr(SAI_PORT_ATTR_INGRESS_ACL)) + continue; + + auto tmpInACL = tmpPort->getSaiAttr(SAI_PORT_ATTR_INGRESS_ACL); + + if (tmpInACL->getOid() != tmpAclTableGroupId->getOid()) + continue; + + auto curPort = currentView.oOids.at(tmpPort->getVid()); + + if (!curPort->hasAttr(SAI_PORT_ATTR_INGRESS_ACL)) + continue; + + auto curInACL = curPort->getSaiAttr(SAI_PORT_ATTR_INGRESS_ACL); + + /* + * We found current InACL, now let's find acl table group members + * that use this acl table group. + */ + + const auto curAclTableGroupMembers = currentView.getObjectsByObjectType(SAI_OBJECT_TYPE_ACL_TABLE_GROUP_MEMBER); + + for (auto curAclTableGroupMember: curAclTableGroupMembers) + { + auto curAclTableGroupId = curAclTableGroupMember->getSaiAttr(SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_GROUP_ID); + + if (curAclTableGroupId->getOid() != curInACL->getOid()) + { + // this member uses different acl table group + continue; + } + + auto curAclTableId = curAclTableGroupMember->getSaiAttr(SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_ID); + + /* + * We found possible current acl table ID, let's see if it's on + * candidate list. Note, it could be possible that many + * different paths will lead multiple possible candidates. + */ + + for (auto c: candidateObjects) + { + if (c.obj->getVid() == curAclTableId->getOid()) + { + SWSS_LOG_INFO("found ALC table candidate %s using port %s", + c.obj->str_object_id.c_str(), + tmpPort->str_object_id.c_str()); + + return c.obj; + } + } + } + } + } + + SWSS_LOG_NOTICE("failed to find best candidate for ACL table using port"); + + return nullptr; +} + std::shared_ptr findCurrentBestMatchForRouterInterface( _In_ const AsicView ¤tView, _In_ const AsicView &temporaryView, @@ -3154,6 +3249,10 @@ std::shared_ptr findCurrentBestMatchForGenericObjectUsingHeuristic( candidate = findCurrentBestMatchForHostifTrapGroup(currentView, temporaryView, temporaryObj, candidateObjects); break; + case SAI_OBJECT_TYPE_ACL_TABLE: + candidate = findCurrentBestMatchForAclTable(currentView, temporaryView, temporaryObj, candidateObjects); + break; + default: break; } @@ -3203,6 +3302,10 @@ std::shared_ptr findCurrentBestMatchForGenericObjectUsingHeuristic( return selectRandomCandidate(candidateObjects); } +std::shared_ptr getSaiAttrFromDefaultValue( + _In_ const AsicView ¤tView, + _In_ const sai_attr_metadata_t &meta); + std::shared_ptr findCurrentBestMatchForGenericObject( _In_ const AsicView ¤tView, _In_ const AsicView &temporaryView, @@ -3314,6 +3417,13 @@ std::shared_ptr findCurrentBestMatchForGenericObject( bool has_different_create_only_attr = false; + /* + * NOTE: we only iterate by attributes that are present in temporary + * view. It may happen that current view has some additional attributes + * set that are create only and value can't be updated then, so in that + * case such object must be disqualified from being candidate. + */ + for (const auto &attr: attrs) { sai_attr_id_t attrId = attr.first; @@ -3378,6 +3488,85 @@ std::shared_ptr findCurrentBestMatchForGenericObject( break; } + + if (SAI_HAS_FLAG_CREATE_ONLY(meta->flags) && !currentObj->hasAttr(attrId)) + { + /* + * This attribute exists only on temporary view and it's + * create only. If it has default value, check if it's the + * same as current. + */ + + auto curDefault = getSaiAttrFromDefaultValue(currentView, *meta); + + if (curDefault != nullptr) + { + if (curDefault->getStrAttrValue() != attr.second->getStrAttrValue()) + { + has_different_create_only_attr = true; + + SWSS_LOG_INFO("obj has not equal create only attributes %s (default): %s", + temporaryObj->str_object_id.c_str(), + meta->attridname); + break; + } + else + { + SWSS_LOG_INFO("obj has equal create only value %s (default): %s", + temporaryObj->str_object_id.c_str(), + meta->attridname); + } + } + } + } + } + + /* + * Before we add this object as candidate, see if there are some create + * only attributes which are not present in temporary object but + * present in current, and if there is default value that is the same. + */ + + const auto curAttrs = currentObj->getAllAttributes(); + + for (auto curAttr: curAttrs) + { + if (attrs.find(curAttr.first) != attrs.end()) + { + // attr exists in both objects. + continue; + } + + const sai_attr_metadata_t* meta = curAttr.second->getAttrMetadata(); + + if (SAI_HAS_FLAG_CREATE_ONLY(meta->flags) && !temporaryObj->hasAttr(curAttr.first)) + { + /* + * This attribute exists only on current view and it's + * create only. If it has default value, check if it's the + * same as current. + */ + + auto tmpDefault = getSaiAttrFromDefaultValue(temporaryView, *meta); + + if (tmpDefault != nullptr) + { + if (tmpDefault->getStrAttrValue() != curAttr.second->getStrAttrValue()) + { + has_different_create_only_attr = true; + + SWSS_LOG_INFO("obj has not equal create only attributes %s (default): %s", + currentObj->str_object_id.c_str(), + meta->attridname); + break; + } + else + { + SWSS_LOG_INFO("obj has equal create only value %s (default): %s", + temporaryObj->str_object_id.c_str(), + meta->attridname); + } + } } } @@ -4019,10 +4208,6 @@ void procesObjectAttributesForViewTransition( } } -std::shared_ptr getSaiAttrFromDefaultValue( - _In_ const AsicView ¤tView, - _In_ const sai_attr_metadata_t &meta); - void bringNonRemovableObjectToDefaultState( _In_ AsicView ¤tView, _In_ const std::shared_ptr ¤tObj) @@ -4885,6 +5070,14 @@ std::shared_ptr getSaiAttrFromDefaultValue( return nullptr; + case SAI_DEFAULT_VALUE_TYPE_NONE: + + /* + * No default value present. + */ + + return nullptr; + default: SWSS_LOG_ERROR("default value type %d is not supported yet for %s, FIXME", @@ -5479,6 +5672,8 @@ void processObjectForViewTransition( return; } + SWSS_LOG_DEBUG("processing: %s:%s", temporaryObj->str_object_type.c_str(), temporaryObj->str_object_id.c_str()); + procesObjectAttributesForViewTransition(currentView, temporaryView, temporaryObj); /* diff --git a/tests/brcm.pl b/tests/brcm.pl index 15da1219a6d1..cd0a183e3c45 100755 --- a/tests/brcm.pl +++ b/tests/brcm.pl @@ -277,8 +277,23 @@ sub test_brcm_qos_map_order play "qos_map_order.rec", 0; } +sub test_brcm_acl_tables +{ + fresh_start; + + # we expect no asic operation on lag's that has no members + + play "acl_tables.rec"; + play "acl_tables.rec", 0; + play "acl_tables.rec", 0; + play "acl_tables.rec", 0; + play "acl_tables.rec", 0; + play "acl_tables.rec", 0; +} + # RUN TESTS +test_brcm_acl_tables; test_brcm_qos_map_order; test_brcm_lag_no_members; test_brcm_rif_loopback; diff --git a/tests/brcm/acl_tables.rec b/tests/brcm/acl_tables.rec new file mode 100644 index 000000000000..7672ecd6bfd4 --- /dev/null +++ b/tests/brcm/acl_tables.rec @@ -0,0 +1,19 @@ +2018-11-05.23:53:46.072382|#|recording on: /var/log/swss/sairedis.rec +2018-11-05.23:53:46.072861|#|logrotate on: /var/log/swss/sairedis.rec +2018-11-05.23:53:46.072964|a|INIT_VIEW +2018-11-05.23:54:14.728951|A|SAI_STATUS_SUCCESS +2018-11-05.23:54:14.730851|c|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_INIT_SWITCH=true|SAI_SWITCH_ATTR_FDB_EVENT_NOTIFY=0x429e60|SAI_SWITCH_ATTR_PORT_STATE_CHANGE_NOTIFY=0x429e70|SAI_SWITCH_ATTR_SWITCH_SHUTDOWN_REQUEST_NOTIFY=0x429e80|SAI_SWITCH_ATTR_SRC_MAC_ADDRESS=00:E0:EC:7B:B9:32 +2018-11-05.23:54:14.743415|g|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_PORT_LIST=32:oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0 +2018-11-05.23:54:14.749126|G|SAI_STATUS_SUCCESS|SAI_SWITCH_ATTR_PORT_LIST=32:oid:0x1000000000002,oid:0x1000000000003,oid:0x1000000000004,oid:0x1000000000005,oid:0x1000000000006,oid:0x1000000000007,oid:0x1000000000008,oid:0x1000000000009,oid:0x100000000000a,oid:0x100000000000b,oid:0x100000000000c,oid:0x100000000000d,oid:0x100000000000e,oid:0x100000000000f,oid:0x1000000000010,oid:0x1000000000011,oid:0x1000000000012,oid:0x1000000000013,oid:0x1000000000014,oid:0x1000000000015,oid:0x1000000000016,oid:0x1000000000017,oid:0x1000000000018,oid:0x1000000000019,oid:0x100000000001a,oid:0x100000000001b,oid:0x100000000001c,oid:0x100000000001d,oid:0x100000000001e,oid:0x100000000001f,oid:0x1000000000020,oid:0x1000000000021 +2018-11-05.23:54:17.365439|c|SAI_OBJECT_TYPE_ACL_TABLE:oid:0x7000000000ab2|SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST=2:SAI_ACL_BIND_POINT_TYPE_PORT,SAI_ACL_BIND_POINT_TYPE_LAG|SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE=true|SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE=true|SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL=true|SAI_ACL_TABLE_ATTR_FIELD_SRC_IP=true|SAI_ACL_TABLE_ATTR_FIELD_DST_IP=true|SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT=true|SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT=true|SAI_ACL_TABLE_ATTR_FIELD_TCP_FLAGS=true|SAI_ACL_TABLE_ATTR_FIELD_ACL_RANGE_TYPE=2:SAI_ACL_RANGE_TYPE_L4_DST_PORT_RANGE,SAI_ACL_RANGE_TYPE_L4_SRC_PORT_RANGE|SAI_ACL_TABLE_ATTR_ACL_STAGE=SAI_ACL_STAGE_INGRESS +2018-11-05.23:54:17.389869|c|SAI_OBJECT_TYPE_ACL_TABLE:oid:0x7000000000ad3|SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST=2:SAI_ACL_BIND_POINT_TYPE_PORT,SAI_ACL_BIND_POINT_TYPE_LAG|SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE=true|SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE=true|SAI_ACL_TABLE_ATTR_FIELD_IP_PROTOCOL=true|SAI_ACL_TABLE_ATTR_FIELD_SRC_IP=true|SAI_ACL_TABLE_ATTR_FIELD_DST_IP=true|SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT=true|SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT=true|SAI_ACL_TABLE_ATTR_FIELD_TCP_FLAGS=true|SAI_ACL_TABLE_ATTR_FIELD_ACL_RANGE_TYPE=2:SAI_ACL_RANGE_TYPE_L4_DST_PORT_RANGE,SAI_ACL_RANGE_TYPE_L4_SRC_PORT_RANGE|SAI_ACL_TABLE_ATTR_ACL_STAGE=SAI_ACL_STAGE_INGRESS|SAI_ACL_TABLE_ATTR_FIELD_DSCP=true +2018-11-05.23:54:17.366170|c|SAI_OBJECT_TYPE_ACL_TABLE_GROUP:oid:0xb000000000ab3|SAI_ACL_TABLE_GROUP_ATTR_ACL_STAGE=SAI_ACL_STAGE_INGRESS|SAI_ACL_TABLE_GROUP_ATTR_ACL_BIND_POINT_TYPE_LIST=1:SAI_ACL_BIND_POINT_TYPE_PORT|SAI_ACL_TABLE_GROUP_ATTR_TYPE=SAI_ACL_TABLE_GROUP_TYPE_PARALLEL +2018-11-05.23:54:17.367466|c|SAI_OBJECT_TYPE_ACL_TABLE_GROUP:oid:0xb000000000ab5|SAI_ACL_TABLE_GROUP_ATTR_ACL_STAGE=SAI_ACL_STAGE_INGRESS|SAI_ACL_TABLE_GROUP_ATTR_ACL_BIND_POINT_TYPE_LIST=1:SAI_ACL_BIND_POINT_TYPE_PORT|SAI_ACL_TABLE_GROUP_ATTR_TYPE=SAI_ACL_TABLE_GROUP_TYPE_PARALLEL +2018-11-05.23:54:17.366718|c|SAI_OBJECT_TYPE_ACL_TABLE_GROUP_MEMBER:oid:0xc000000000ab4|SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_GROUP_ID=oid:0xb000000000ab3|SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_ID=oid:0x7000000000ab2|SAI_ACL_TABLE_GROUP_MEMBER_ATTR_PRIORITY=100 +2018-11-05.23:54:17.367926|c|SAI_OBJECT_TYPE_ACL_TABLE_GROUP_MEMBER:oid:0xc000000000ab6|SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_GROUP_ID=oid:0xb000000000ab5|SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_ID=oid:0x7000000000ab2|SAI_ACL_TABLE_GROUP_MEMBER_ATTR_PRIORITY=100 +2018-11-05.23:54:17.390931|c|SAI_OBJECT_TYPE_ACL_TABLE_GROUP_MEMBER:oid:0xc000000000ad4|SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_GROUP_ID=oid:0xb000000000ab3|SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_ID=oid:0x7000000000ad3|SAI_ACL_TABLE_GROUP_MEMBER_ATTR_PRIORITY=100 +2018-11-05.23:54:17.391548|c|SAI_OBJECT_TYPE_ACL_TABLE_GROUP_MEMBER:oid:0xc000000000ad5|SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_GROUP_ID=oid:0xb000000000ab5|SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_ID=oid:0x7000000000ad3|SAI_ACL_TABLE_GROUP_MEMBER_ATTR_PRIORITY=100 +2018-11-05.23:54:17.366422|s|SAI_OBJECT_TYPE_PORT:oid:0x1000000000002|SAI_PORT_ATTR_INGRESS_ACL=oid:0xb000000000ab3 +2018-11-05.23:54:17.367676|s|SAI_OBJECT_TYPE_PORT:oid:0x1000000000003|SAI_PORT_ATTR_INGRESS_ACL=oid:0xb000000000ab5 +2018-11-05.23:54:23.726116|a|APPLY_VIEW +2018-11-06.00:01:09.702164|A|SAI_STATUS_SUCCESS