Skip to content

Commit e8cb879

Browse files
authored
Make object list deterministic when iterating (#438)
* Use pre match logic to match ACL TABLE * Change log level to info * Make object list deterministic when iterating
1 parent 5486f97 commit e8cb879

File tree

3 files changed

+810
-5
lines changed

3 files changed

+810
-5
lines changed

syncd/syncd_applyview.cpp

+62-5
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,8 @@ class SaiObj
483483
};
484484

485485
typedef std::unordered_map<sai_object_id_t, sai_object_id_t> ObjectIdMap;
486-
typedef std::unordered_map<std::string, std::shared_ptr<SaiObj>> StrObjectIdToSaiObjectHash;
487-
typedef std::unordered_map<sai_object_id_t, std::shared_ptr<SaiObj>> ObjectIdToSaiObjectHash;
486+
typedef std::map<std::string, std::shared_ptr<SaiObj>> StrObjectIdToSaiObjectHash;
487+
typedef std::map<sai_object_id_t, std::shared_ptr<SaiObj>> ObjectIdToSaiObjectHash;
488488

489489
/**
490490
* @brief Class represents ASIC view
@@ -2916,7 +2916,7 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForAclTable(
29162916
{
29172917
if (c.obj->getVid() == curAclTableId->getOid())
29182918
{
2919-
SWSS_LOG_INFO("found ALC table candidate %s using port %s",
2919+
SWSS_LOG_INFO("found ACL table candidate %s using port %s",
29202920
c.obj->str_object_id.c_str(),
29212921
tmpPort->str_object_id.c_str());
29222922

@@ -2927,6 +2927,53 @@ std::shared_ptr<SaiObj> findCurrentBestMatchForAclTable(
29272927
}
29282928
}
29292929

2930+
// try using pre match in this case
2931+
2932+
const auto tmpMembers = temporaryView.getNotProcessedObjectsByObjectType(SAI_OBJECT_TYPE_ACL_TABLE_GROUP_MEMBER);
2933+
2934+
for (auto tmpAclTableGroupMember: tmpMembers)
2935+
{
2936+
auto tmpAclTableIdAttr = tmpAclTableGroupMember->getSaiAttr(SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_ID);
2937+
2938+
if (tmpAclTableIdAttr->getOid() != temporaryObj->getVid())
2939+
continue;
2940+
2941+
auto tmpAclTableGroupIdAttr = tmpAclTableGroupMember->getSaiAttr(SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_GROUP_ID);
2942+
2943+
auto tmpAclTableGroup = temporaryView.oOids.at(tmpAclTableGroupIdAttr->getOid());
2944+
2945+
auto it = temporaryView.preMatchMap.find(tmpAclTableGroup->getVid());
2946+
2947+
if (it == temporaryView.preMatchMap.end())
2948+
continue;
2949+
2950+
auto curAclTableGroupMembers = currentView.getNotProcessedObjectsByObjectType(SAI_OBJECT_TYPE_ACL_TABLE_GROUP_MEMBER);
2951+
2952+
for (auto curAclTableGroupMember: curAclTableGroupMembers)
2953+
{
2954+
auto curAclTableGroupIdAttr = curAclTableGroupMember->getSaiAttr(SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_GROUP_ID);
2955+
2956+
if (curAclTableGroupIdAttr->getOid() != it->second)
2957+
continue;
2958+
2959+
// we got acl table group member current that uses same acl table group as temporary
2960+
2961+
auto curAclTableIdAttr = curAclTableGroupMember->getSaiAttr(SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_ID);
2962+
2963+
for (auto c: candidateObjects)
2964+
{
2965+
if (c.obj->getVid() == curAclTableIdAttr->getOid())
2966+
{
2967+
SWSS_LOG_INFO("found ACL table candidate %s using pre match ACL TABLE GROUP %s",
2968+
c.obj->str_object_id.c_str(),
2969+
tmpAclTableGroup->str_object_id.c_str());
2970+
2971+
return c.obj;
2972+
}
2973+
}
2974+
}
2975+
}
2976+
29302977
SWSS_LOG_NOTICE("failed to find best candidate for ACL_TABLE using port");
29312978

29322979
return nullptr;
@@ -6166,7 +6213,7 @@ void processObjectForViewTransition(
61666213
return;
61676214
}
61686215

6169-
SWSS_LOG_DEBUG("processing: %s:%s", temporaryObj->str_object_type.c_str(), temporaryObj->str_object_id.c_str());
6216+
SWSS_LOG_INFO("processing: %s:%s", temporaryObj->str_object_type.c_str(), temporaryObj->str_object_id.c_str());
61706217

61716218
procesObjectAttributesForViewTransition(currentView, temporaryView, temporaryObj);
61726219

@@ -7233,7 +7280,17 @@ void createPreMatchMap(
72337280
createPreMatchMapForObject(cur, tmp, cObj, tObj, processed);
72347281
}
72357282

7236-
SWSS_LOG_NOTICE("preMatch map size: %zu", tmp.preMatchMap.size());
7283+
size_t count = 0;
7284+
7285+
for (auto& ok: tmp.soOids)
7286+
{
7287+
if (ok.second->getObjectStatus() != SAI_OBJECT_STATUS_MATCHED)
7288+
count++;
7289+
}
7290+
7291+
SWSS_LOG_NOTICE("preMatch map size: %zu, tmp oid obj: %zu",
7292+
tmp.preMatchMap.size(),
7293+
count);
72377294
}
72387295

72397296
sai_status_t syncdApplyView()

tests/brcm.pl

+10
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,18 @@ sub test_empty_lag_buffer_acl
410410
for (1..8) { play "empty_lag_buffer_acl.rec", 0; }
411411
}
412412

413+
sub test_acl_mask
414+
{
415+
fresh_start;
416+
417+
play "acl_mask.rec";
418+
419+
for (1..8) { play "acl_mask.rec", 0; }
420+
}
421+
413422
# RUN TESTS
414423

424+
test_acl_mask;
415425
test_empty_lag_buffer_acl;
416426
test_brcm_config_acl;
417427
test_brcm_warm_wred_queue;

0 commit comments

Comments
 (0)