-
Notifications
You must be signed in to change notification settings - Fork 412
Cast temp workaround for N/A counter values on Broadcom platforms from 202412 #1955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -990,24 +990,21 @@ class CounterContext : public BaseCounterContext | |
| auto rid = rids[i]; | ||
| auto vid = vids[i]; | ||
| std::vector<uint64_t> stats(counter_ids.size()); | ||
| if (collectData(rid, counter_ids, effective_stats_mode, false, stats)) { | ||
|
|
||
| auto it_vid = m_objectIdsMap.find(vid); | ||
| if (it_vid != m_objectIdsMap.end()) | ||
| { | ||
| // Remove and re-add if vid already exists | ||
| m_objectIdsMap.erase(it_vid); | ||
| } | ||
|
|
||
| auto counter_data = std::make_shared<CounterIds<StatType>>(rid, counter_ids); | ||
| m_objectIdsMap.emplace(vid, counter_data); | ||
|
|
||
| SWSS_LOG_INFO("Fallback to single call for object 0x%" PRIx64, vid); | ||
| } else { | ||
| SWSS_LOG_WARN("%s RID %s can't provide the statistic", m_name.c_str(), sai_serialize_object_id(rid).c_str()); | ||
| if (!collectData(rid, counter_ids, effective_stats_mode, false, stats)) | ||
| { | ||
| SWSS_LOG_INFO("counter read failed on RID 0x%x on intf 0x%x, adding to objectIdsMap regardless", rid, vid); | ||
| } | ||
| auto it_vid = m_objectIdsMap.find(vid); | ||
| if (it_vid != m_objectIdsMap.end()) | ||
| { | ||
| // Remove and re-add if vid already exists | ||
| m_objectIdsMap.erase(it_vid); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 This now inserts into |
||
| } | ||
| } | ||
|
|
||
| auto counter_data = std::make_shared<CounterIds<StatType>>(rid, counter_ids); | ||
| m_objectIdsMap.emplace(vid, counter_data); | ||
| SWSS_LOG_INFO("Fallback to single call for object 0x%" PRIx64, vid); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
|
|
@@ -1159,10 +1156,10 @@ class CounterContext : public BaseCounterContext | |
| kv.second->getStatsMode() == SAI_STATS_MODE_READ_AND_CLEAR) ? SAI_STATS_MODE_READ_AND_CLEAR : SAI_STATS_MODE_READ; | ||
| } | ||
|
|
||
| std::vector<uint64_t> stats(statIds.size()); | ||
| if (!collectData(rid, statIds, effective_stats_mode, true, stats)) | ||
| std::vector<uint64_t> stats(statIds.size(), 0); | ||
| if (!collectData(rid, statIds, effective_stats_mode, false, stats)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Semantic behavior change worth an explicit comment. The old code did |
||
| { | ||
| continue; | ||
| SWSS_LOG_INFO("counter read failed on RID 0x%x on intf 0x%x, filling with '0' value", rid, vid); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 Same SWSS_LOG_INFO("counter read failed on RID 0x%\" PRIx64 \" on intf 0x%\" PRIx64 \", filling with '0' value", rid, vid); |
||
| } | ||
|
|
||
| std::vector<swss::FieldValueTuple> values; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 Format-specifier bug (UB).
ridandvidaresai_object_id_t=uint64_t, but0x%xis a 32-bitunsigned intspecifier. Passing auint64_tto%xis undefined behavior and will misprint/truncate the OID (you'll get the wrong half of the 64-bit value, and on some ABIs the second arg shifts) — which defeats the log's purpose when someone is debugging which port failed. The file's own convention is right here in the same function: use0x%\" PRIx64(cf. theFallback to single call for object 0x%\" PRIx64lines just above) orsai_serialize_object_id(rid).c_str(). Suggest:(Same fix needed on the sibling line in the main
collectDataloop ~1162.)