diff options
author | Jason M. Bills <jason.m.bills@linux.intel.com> | 2019-06-17 15:46:37 -0700 |
---|---|---|
committer | Vernon Mauery <vernon.mauery@linux.intel.com> | 2019-06-24 23:18:10 +0000 |
commit | bc996a358719e24d2ab1108167cfc9f019d3fec9 (patch) | |
tree | 2ee3c92b0a610b06332864522f29c836a656ba46 /chassishandler.cpp | |
parent | 2c7db1d3594b388c0b857560e7217bbc154f84bf (diff) | |
download | phosphor-host-ipmid-bc996a358719e24d2ab1108167cfc9f019d3fec9.tar.gz phosphor-host-ipmid-bc996a358719e24d2ab1108167cfc9f019d3fec9.zip |
Fix power restore policy input parameter check
This changes the power restore policy command to return invalid
parameter for any unsupported policy option (greater than 0x03).
Tested:
ipmitool raw 0 6 0
07
ipmitool chassis status
Power Restore Policy : always-off
ipmitool raw 0 6 1
07
ipmitool chassis status
Power Restore Policy : previous
ipmitool raw 0 6 2
07
ipmitool chassis status
Power Restore Policy : always-on
ipmitool raw 0 6 3
07
ipmitool chassis status
Power Restore Policy : always-on
ipmitool raw 0 6 4
Unable to send RAW command (channel=0x0 netfn=0x0 lun=0x0 cmd=0x6 rsp=0xcc): Invalid data field in request
Change-Id: Ie78e00753f6dfd8b7bccce38c239a8103b6cc3fd
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
Diffstat (limited to 'chassishandler.cpp')
-rw-r--r-- | chassishandler.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/chassishandler.cpp b/chassishandler.cpp index 1738ccc..0f2d10c 100644 --- a/chassishandler.cpp +++ b/chassishandler.cpp @@ -781,8 +781,6 @@ const std::map<DbusValue, IpmiValue> dbusToIpmi = { static constexpr uint8_t noChange = 0x03; static constexpr uint8_t allSupport = 0x01 | 0x02 | 0x04; -static constexpr uint8_t policyBitMask = 0x07; -static constexpr uint8_t setPolicyReqLen = 1; /* helper function for Get Chassis Status Command */ @@ -1703,26 +1701,27 @@ ipmi::RspType<uint8_t, // Minutes per count } } -ipmi::RspType<uint8_t> +ipmi::RspType<uint3_t, // policy support + uint5_t // reserved + > ipmiChassisSetPowerRestorePolicy(boost::asio::yield_context yield, - uint8_t policy) + uint3_t policy, uint5_t reserved) { - constexpr uint8_t ccParamNotSupported = 0x80; power_policy::DbusValue value = power_policy::RestorePolicy::Policy::AlwaysOff; - if (policy & ~power_policy::policyBitMask) + if (reserved || (policy > power_policy::noChange)) { phosphor::logging::log<level::ERR>( "Reserved request parameter", entry("REQ=0x%x", static_cast<int>(policy))); - return ipmi::response(ccParamNotSupported); + return ipmi::responseInvalidFieldRequest(); } if (policy == power_policy::noChange) { // just return the supported policy - return ipmi::responseSuccess(power_policy::allSupport); + return ipmi::responseSuccess(power_policy::allSupport, reserved); } for (auto const& it : power_policy::dbusToIpmi) @@ -1765,7 +1764,7 @@ ipmi::RspType<uint8_t> return ipmi::responseUnspecifiedError(); } - return ipmi::responseSuccess(power_policy::allSupport); + return ipmi::responseSuccess(power_policy::allSupport, reserved); } void register_netfn_chassis_functions() |