AcquireLock : ResourceID Endianness Changes
- HMC constructs the resourceID with the First Segment
data in the First Byte of the resourceID from the MSB
position.
- As BMC is a Little Endian machine, and we need to convert
the endian-ness before processing the resourceID.
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: Ieb0b0f8083c4c2cbd2b19477507e67378d5704ba
diff --git a/include/ibm/locks.hpp b/include/ibm/locks.hpp
index 66eb926..79079c4 100644
--- a/include/ibm/locks.hpp
+++ b/include/ibm/locks.hpp
@@ -2,6 +2,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/container/flat_map.hpp>
+#include <boost/endian/conversion.hpp>
#include <filesystem>
#include <fstream>
#include <nlohmann/json.hpp>
@@ -717,9 +718,18 @@
for (uint32_t i = 0; i < p.second; i++)
{
// if the segment data is different , then the locks is on a
- // different resource So no conflict between the lock records
- if (!(checkByte(std::get<3>(refLockRecord1),
- std::get<3>(refLockRecord2), i)))
+ // different resource So no conflict between the lock
+ // records.
+ // BMC is little endian , but the resourceID is formed by
+ // the Managament Console in such a way that, the first byte
+ // from the MSB Position corresponds to the First Segment
+ // data. Therefore we need to convert the in-comming
+ // resourceID into Big Endian before processing further.
+ if (!(checkByte(boost::endian::endian_reverse(
+ std::get<3>(refLockRecord1)),
+ boost::endian::endian_reverse(
+ std::get<3>(refLockRecord2)),
+ i)))
{
return false;
}