diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/channel.cpp | 87 | ||||
-rw-r--r-- | app/channel.hpp | 58 | ||||
-rw-r--r-- | app/watchdog.cpp | 208 | ||||
-rw-r--r-- | app/watchdog.hpp | 61 | ||||
-rw-r--r-- | app/watchdog_service.cpp | 37 | ||||
-rw-r--r-- | app/watchdog_service.hpp | 15 |
6 files changed, 254 insertions, 212 deletions
diff --git a/app/channel.cpp b/app/channel.cpp index 6ea25c4..51e953d 100644 --- a/app/channel.cpp +++ b/app/channel.cpp @@ -1,6 +1,5 @@ #include "channel.hpp" -#include "transporthandler.hpp" #include "user_channel/channel_layer.hpp" #include <arpa/inet.h> @@ -97,26 +96,44 @@ std::pair<std::vector<uint8_t>, std::vector<uint8_t>> getCipherRecords() } // namespace cipher -ipmi_ret_t getChannelCipherSuites(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - ipmi_request_t request, - ipmi_response_t response, - ipmi_data_len_t data_len, - ipmi_context_t context) +/** @brief this command is used to look up what authentication, integrity, + * confidentiality algorithms are supported. + * + * @ param ctx - context pointer + * @ param channelNumber - channel number + * @ param payloadType - payload type + * @ param listIndex - list index + * @ param algoSelectBit - list algorithms + * + * @returns ipmi completion code plus response data + * - rspChannel - channel number for authentication algorithm. + * - rspRecords - cipher suite records. + **/ +ipmi::RspType<uint8_t, // Channel Number + std::vector<uint8_t> // Cipher Records + > + getChannelCipherSuites(ipmi::Context::ptr ctx, uint4_t channelNumber, + uint4_t reserved1, uint8_t payloadType, + uint6_t listIndex, uint1_t reserved2, + uint1_t algoSelectBit) { static std::vector<uint8_t> cipherRecords; static std::vector<uint8_t> supportedAlgorithms; static auto recordInit = false; - auto requestData = - reinterpret_cast<const GetChannelCipherRequest*>(request); + uint8_t rspChannel = ipmi::convertCurrentChannelNum( + static_cast<uint8_t>(channelNumber), ctx->channel); - if (*data_len < sizeof(GetChannelCipherRequest)) + if (!ipmi::isValidChannel(rspChannel) || reserved1 != 0 || reserved2 != 0) { - *data_len = 0; - return IPMI_CC_REQ_DATA_LEN_INVALID; + return ipmi::responseInvalidFieldRequest(); + } + if (!ipmi::isValidPayloadType(static_cast<ipmi::PayloadType>(payloadType))) + { + log<level::DEBUG>("Get channel cipher suites - Invalid payload type"); + constexpr uint8_t ccPayloadTypeNotSupported = 0x80; + return ipmi::response(ccPayloadTypeNotSupported); } - - *data_len = 0; if (!recordInit) { @@ -128,41 +145,37 @@ ipmi_ret_t getChannelCipherSuites(ipmi_netfn_t netfn, ipmi_cmd_t cmd, } catch (const std::exception& e) { - return IPMI_CC_UNSPECIFIED_ERROR; + return ipmi::responseUnspecifiedError(); } } - const auto& records = (cipher::listCipherSuite == - (requestData->listIndex & cipher::listTypeMask)) - ? cipherRecords - : supportedAlgorithms; + const std::vector<uint8_t>& records = + algoSelectBit ? cipherRecords : supportedAlgorithms; + static constexpr auto respSize = 16; + + // Session support is available in active LAN channels. + if ((ipmi::getChannelSessionSupport(rspChannel) == + ipmi::EChannelSessSupported::none) || + !(ipmi::doesDeviceExist(rspChannel))) + { + log<level::DEBUG>("Get channel cipher suites - Device does not exist"); + return ipmi::responseInvalidFieldRequest(); + } // List index(00h-3Fh), 0h selects the first set of 16, 1h selects the next // set of 16 and so on. - auto index = - static_cast<size_t>(requestData->listIndex & cipher::listIndexMask); // Calculate the number of record data bytes to be returned. - auto start = std::min(index * cipher::respSize, records.size()); - auto end = - std::min((index * cipher::respSize) + cipher::respSize, records.size()); + auto start = + std::min(static_cast<size_t>(listIndex) * respSize, records.size()); + auto end = std::min((static_cast<size_t>(listIndex) * respSize) + respSize, + records.size()); auto size = end - start; - auto responseData = reinterpret_cast<GetChannelCipherRespHeader*>(response); - responseData->channelNumber = cipher::defaultChannelNumber; - - if (!size) - { - *data_len = sizeof(GetChannelCipherRespHeader); - } - else - { - std::copy_n(records.data() + start, size, - static_cast<uint8_t*>(response) + 1); - *data_len = size + sizeof(GetChannelCipherRespHeader); - } + std::vector<uint8_t> rspRecords; + std::copy_n(records.data() + start, size, std::back_inserter(rspRecords)); - return IPMI_CC_OK; + return ipmi::responseSuccess(rspChannel, rspRecords); } template <typename... ArgTypes> diff --git a/app/channel.hpp b/app/channel.hpp index 7004ddd..8e5accb 100644 --- a/app/channel.hpp +++ b/app/channel.hpp @@ -1,6 +1,6 @@ #include "nlohmann/json.hpp" -#include <ipmid/api.h> +#include <ipmid/api.hpp> /** @brief The set channel access IPMI command. * @@ -53,31 +53,31 @@ ipmi_ret_t ipmi_app_channel_info(ipmi_netfn_t netfn, ipmi_cmd_t cmd, ipmi_data_len_t data_len, ipmi_context_t context); -/** @brief Implementation of get channel cipher suites command +/** @brief this command is used to look up what authentication, integrity, + * confidentiality algorithms are supported. * - * @param[in] netfn - Net Function - * @param[in] cmd - Command - * @param[in] request - Request pointer - * @param[in,out] response - Response pointer - * @param[in,out] data_len - Data Length - * @param[in] context - Context + * @ param ctx - context pointer + * @ param channelNumber - channel number + * @ param payloadType - payload type + * @ param listIndex - list index + * @ param algoSelectBit - list algorithms * - * @return IPMI_CC_OK on success, non-zero otherwise. - */ -ipmi_ret_t getChannelCipherSuites(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - ipmi_request_t request, - ipmi_response_t response, - ipmi_data_len_t data_len, - ipmi_context_t context); + * @returns ipmi completion code plus response data + * - rspChannel - channel number for authentication algorithm. + * - rspRecords - cipher suite records. + **/ +ipmi::RspType<uint8_t, // Channel Number + std::vector<uint8_t> // Cipher Records + > + getChannelCipherSuites(ipmi::Context::ptr ctx, uint4_t channelNumber, + uint4_t reserved1, uint8_t payloadType, + uint6_t listIndex, uint1_t reserved2, + uint1_t algoSelectBit); namespace cipher { -static constexpr auto defaultChannelNumber = 1; -static constexpr auto listTypeMask = 0x80; static constexpr auto listCipherSuite = 0x80; -static constexpr auto listIndexMask = 0x3F; -static constexpr auto respSize = 16; using Json = nlohmann::json; static constexpr auto configFile = "/usr/share/ipmi-providers/cipher_list.json"; @@ -92,23 +92,3 @@ static constexpr auto conf = "confidentiality"; static constexpr auto confTag = 0x80; } // namespace cipher - -/** @struct GetChannelCipherRequest - * - * IPMI payload for Get Channel Cipher Suites command request - */ -struct GetChannelCipherRequest -{ - uint8_t channelNumber; //!< Channel Number - uint8_t payloadType; //!< Payload type number - uint8_t listIndex; //!< List Index -} __attribute__((packed)); - -/** @struct GetChannelCipherRespHeader - * - * IPMI payload for Get Channel Cipher Suites command response header - */ -struct GetChannelCipherRespHeader -{ - uint8_t channelNumber; //!< Channel Number -} __attribute__((packed)); diff --git a/app/watchdog.cpp b/app/watchdog.cpp index b1eea1c..03c373e 100644 --- a/app/watchdog.cpp +++ b/app/watchdog.cpp @@ -4,6 +4,7 @@ #include <endian.h> +#include <bitset> #include <cstdint> #include <ipmid/api.hpp> #include <phosphor-logging/elog-errors.hpp> @@ -68,13 +69,11 @@ ipmi::RspType<> ipmiAppResetWatchdogTimer() { const std::string e_str = std::string("wd_reset: ") + e.what(); log<level::ERR>(e_str.c_str()); - reportError(); return ipmi::responseUnspecifiedError(); } catch (...) { log<level::ERR>("wd_reset: Unknown Error"); - reportError(); return ipmi::responseUnspecifiedError(); } } @@ -82,7 +81,12 @@ ipmi::RspType<> ipmiAppResetWatchdogTimer() static constexpr uint8_t wd_dont_stop = 0x1 << 6; static constexpr uint8_t wd_timeout_action_mask = 0x3; -static constexpr uint8_t wdTimerUseMask = 0x7; +static constexpr uint8_t wdTimerUseResTimer1 = 0x0; +static constexpr uint8_t wdTimerUseResTimer2 = 0x6; +static constexpr uint8_t wdTimerUseResTimer3 = 0x7; + +static constexpr uint8_t wdTimeoutActionMax = 3; +static constexpr uint8_t wdTimeoutInterruptTimer = 0x04; enum class IpmiAction : uint8_t { @@ -168,85 +172,106 @@ WatchdogService::TimerUse ipmiTimerUseToWdTimerUse(IpmiTimerUse ipmiTimerUse) } } -struct wd_set_req -{ - uint8_t timer_use; - uint8_t timer_action; - uint8_t pretimeout; // (seconds) - uint8_t expire_flags; - uint16_t initial_countdown; // Little Endian (deciseconds) -} __attribute__((packed)); -static_assert(sizeof(wd_set_req) == 6, "wd_set_req has invalid size."); -static_assert(sizeof(wd_set_req) <= MAX_IPMI_BUFFER, - "wd_get_res can't fit in request buffer."); - -ipmi_ret_t ipmi_app_watchdog_set(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - ipmi_request_t request, - ipmi_response_t response, - ipmi_data_len_t data_len, - ipmi_context_t context) +static bool timerNotLogFlags = false; +static std::bitset<8> timerUseExpirationFlags = 0; +static uint3_t timerPreTimeoutInterrupt = 0; +static constexpr uint8_t wdExpirationFlagReservedBit0 = 0x0; +static constexpr uint8_t wdExpirationFlagReservedBit6 = 0x6; +static constexpr uint8_t wdExpirationFlagReservedBit7 = 0x7; + +/**@brief The Set Watchdog Timer ipmi command. + * + * @param + * - timerUse + * - dontStopTimer + * - dontLog + * - timerAction + * - pretimeout + * - expireFlags + * - initialCountdown + * + * @return completion code on success. + **/ +ipmi::RspType<> + ipmiSetWatchdogTimer(uint3_t timerUse, uint3_t reserved, bool dontStopTimer, + bool dontLog, uint3_t timeoutAction, uint1_t reserved1, + uint3_t preTimeoutInterrupt, uint1_t reserved2, + uint8_t preTimeoutInterval, + std::bitset<8> expFlagValue, uint16_t initialCountdown) { - // Extract the request data - if (*data_len < sizeof(wd_set_req)) + if ((timerUse == wdTimerUseResTimer1) || + (timerUse == wdTimerUseResTimer2) || + (timerUse == wdTimerUseResTimer3) || + (timeoutAction > wdTimeoutActionMax) || + (preTimeoutInterrupt == wdTimeoutInterruptTimer) || + (reserved | reserved1 | reserved2 | + expFlagValue.test(wdExpirationFlagReservedBit0) | + expFlagValue.test(wdExpirationFlagReservedBit6) | + expFlagValue.test(wdExpirationFlagReservedBit7))) { - *data_len = 0; - return IPMI_CC_REQ_DATA_LEN_INVALID; + return ipmi::responseInvalidFieldRequest(); } - wd_set_req req; - memcpy(&req, request, sizeof(req)); - req.initial_countdown = le16toh(req.initial_countdown); - *data_len = 0; + + if (preTimeoutInterval > (initialCountdown / 10)) + { + return ipmi::responseInvalidFieldRequest(); + } + + timerNotLogFlags = dontLog; + timerPreTimeoutInterrupt = preTimeoutInterrupt; try { WatchdogService wd_service; // Stop the timer if the don't stop bit is not set - if (!(req.timer_use & wd_dont_stop)) + if (!(dontStopTimer)) { wd_service.setEnabled(false); } // Set the action based on the request - const auto ipmi_action = - static_cast<IpmiAction>(req.timer_action & wd_timeout_action_mask); + const auto ipmi_action = static_cast<IpmiAction>( + static_cast<uint8_t>(timeoutAction) & wd_timeout_action_mask); wd_service.setExpireAction(ipmiActionToWdAction(ipmi_action)); const auto ipmiTimerUse = - static_cast<IpmiTimerUse>(req.timer_use & wdTimerUseMask); + static_cast<IpmiTimerUse>(static_cast<uint8_t>(timerUse)); wd_service.setTimerUse(ipmiTimerUseToWdTimerUse(ipmiTimerUse)); + wd_service.setExpiredTimerUse(WatchdogService::TimerUse::Reserved); + + timerUseExpirationFlags &= ~expFlagValue; + // Set the new interval and the time remaining deci -> mill seconds - const uint64_t interval = req.initial_countdown * 100; + const uint64_t interval = initialCountdown * 100; wd_service.setInterval(interval); - wd_service.setTimeRemaining(interval); + wd_service.resetTimeRemaining(false); // Mark as initialized so that future resets behave correctly wd_service.setInitialized(true); lastCallSuccessful = true; - return IPMI_CC_OK; + return ipmi::responseSuccess(); } catch (const std::domain_error&) { - return IPMI_CC_INVALID_FIELD_REQUEST; + return ipmi::responseInvalidFieldRequest(); } catch (const InternalFailure& e) { reportError(); - return IPMI_CC_UNSPECIFIED_ERROR; + return ipmi::responseUnspecifiedError(); } catch (const std::exception& e) { const std::string e_str = std::string("wd_set: ") + e.what(); log<level::ERR>(e_str.c_str()); - reportError(); - return IPMI_CC_UNSPECIFIED_ERROR; + return ipmi::responseUnspecifiedError(); } catch (...) { log<level::ERR>("wd_set: Unknown Error"); - reportError(); - return IPMI_CC_UNSPECIFIED_ERROR; + return ipmi::responseUnspecifiedError(); } } @@ -320,30 +345,37 @@ IpmiTimerUse wdTimerUseToIpmiTimerUse(WatchdogService::TimerUse wdTimerUse) } } -struct wd_get_res -{ - uint8_t timer_use; - uint8_t timer_action; - uint8_t pretimeout; - uint8_t expire_flags; - uint16_t initial_countdown; // Little Endian (deciseconds) - uint16_t present_countdown; // Little Endian (deciseconds) -} __attribute__((packed)); -static_assert(sizeof(wd_get_res) == 8, "wd_get_res has invalid size."); -static_assert(sizeof(wd_get_res) <= MAX_IPMI_BUFFER, - "wd_get_res can't fit in response buffer."); - -static constexpr uint8_t wd_dont_log = 0x1 << 7; static constexpr uint8_t wd_running = 0x1 << 6; -ipmi_ret_t ipmi_app_watchdog_get(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - ipmi_request_t request, - ipmi_response_t response, - ipmi_data_len_t data_len, - ipmi_context_t context) +/**@brief The getWatchdogTimer ipmi command. + * + * @return Completion code plus timer details. + * - timerUse + * - timerAction + * - pretimeout + * - expireFlags + * - initialCountdown + * - presentCountdown + **/ +ipmi::RspType<uint3_t, // timerUse - timer use + uint3_t, // timerUse - reserved + bool, // timerUse - timer is started + bool, // timerUse - don't log + + uint3_t, // timerAction - timeout action + uint1_t, // timerAction - reserved + uint3_t, // timerAction - pre-timeout interrupt + uint1_t, // timerAction - reserved + + uint8_t, // pretimeout + std::bitset<8>, // expireFlags + uint16_t, // initial Countdown - Little Endian (deciseconds) + uint16_t // present Countdown - Little Endian (deciseconds) + > + ipmiGetWatchdogTimer() { - // Assume we will fail and send no data outside the return code - *data_len = 0; + uint16_t presentCountdown = 0; + uint8_t pretimeout = 0; try { @@ -351,50 +383,58 @@ ipmi_ret_t ipmi_app_watchdog_get(ipmi_netfn_t netfn, ipmi_cmd_t cmd, WatchdogService::Properties wd_prop = wd_service.getProperties(); // Build and return the response - wd_get_res res; - res.timer_use = wd_dont_log; - res.timer_action = - static_cast<uint8_t>(wdActionToIpmiAction(wd_prop.expireAction)); - // Interval and timeRemaining need converted from milli -> deci seconds - res.initial_countdown = htole16(wd_prop.interval / 100); + uint16_t initialCountdown = htole16(wd_prop.interval / 100); + + if (wd_prop.expiredTimerUse != WatchdogService::TimerUse::Reserved) + { + timerUseExpirationFlags.set(static_cast<uint8_t>( + wdTimerUseToIpmiTimerUse(wd_prop.expiredTimerUse))); + } + if (wd_prop.enabled) { - res.timer_use |= wd_running; - res.present_countdown = htole16(wd_prop.timeRemaining / 100); + presentCountdown = htole16(wd_prop.timeRemaining / 100); } else { - res.present_countdown = res.initial_countdown; + if (wd_prop.expiredTimerUse == WatchdogService::TimerUse::Reserved) + { + presentCountdown = initialCountdown; + } + else + { + presentCountdown = 0; + // Automatically clear it whenever a timer expiration occurs. + timerNotLogFlags = false; + } } - res.timer_use |= - static_cast<uint8_t>(wdTimerUseToIpmiTimerUse(wd_prop.timerUse)); - // TODO: Do something about having pretimeout support - res.pretimeout = 0; - res.expire_flags = 0; - memcpy(response, &res, sizeof(res)); - *data_len = sizeof(res); + pretimeout = 0; + lastCallSuccessful = true; - return IPMI_CC_OK; + return ipmi::responseSuccess( + static_cast<uint3_t>(wdTimerUseToIpmiTimerUse(wd_prop.timerUse)), 0, + wd_prop.enabled, timerNotLogFlags, + static_cast<uint3_t>(wdActionToIpmiAction(wd_prop.expireAction)), 0, + timerPreTimeoutInterrupt, 0, pretimeout, timerUseExpirationFlags, + initialCountdown, presentCountdown); } catch (const InternalFailure& e) { reportError(); - return IPMI_CC_UNSPECIFIED_ERROR; + return ipmi::responseUnspecifiedError(); } catch (const std::exception& e) { const std::string e_str = std::string("wd_get: ") + e.what(); log<level::ERR>(e_str.c_str()); - reportError(); - return IPMI_CC_UNSPECIFIED_ERROR; + return ipmi::responseUnspecifiedError(); } catch (...) { log<level::ERR>("wd_get: Unknown Error"); - reportError(); - return IPMI_CC_UNSPECIFIED_ERROR; + return ipmi::responseUnspecifiedError(); } } diff --git a/app/watchdog.hpp b/app/watchdog.hpp index 3f91f4f..fa53ac7 100644 --- a/app/watchdog.hpp +++ b/app/watchdog.hpp @@ -6,35 +6,40 @@ */ ipmi::RspType<> ipmiAppResetWatchdogTimer(); -/** @brief The SET watchdog IPMI command. +/**@brief The setWatchdogTimer ipmi command. * - * @param[in] netfn - * @param[in] cmd - * @param[in] request - * @param[in,out] response - * @param[out] data_len - * @param[in] context + * @param + * - timerUse + * - dontStopTimer + * - dontLog + * - timerAction + * - pretimeout + * - expireFlags + * - initialCountdown * - * @return IPMI_CC_OK on success, an IPMI error code otherwise. - */ -ipmi_ret_t ipmi_app_watchdog_set(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - ipmi_request_t request, - ipmi_response_t response, - ipmi_data_len_t data_len, - ipmi_context_t context); + * @return completion code on success. + **/ +ipmi::RspType<> ipmiSetWatchdogTimer( + uint3_t timerUse, uint3_t reserved, bool dontStopTimer, bool dontLog, + uint3_t timeoutAction, uint1_t reserved1, uint3_t preTimeoutInterrupt, + uint1_t reserved2, uint8_t preTimeoutInterval, std::bitset<8> expFlagValue, + uint16_t initialCountdown); -/** @brief The GET watchdog IPMI command. - * @param[in] netfn - * @param[in] cmd - * @param[in] request - * @param[in,out] response - * @param[out] data_len - * @param[in] context +/**@brief The getWatchdogTimer ipmi command. * - * @return IPMI_CC_OK on success, an IPMI error code otherwise. - */ -ipmi_ret_t ipmi_app_watchdog_get(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - ipmi_request_t request, - ipmi_response_t response, - ipmi_data_len_t data_len, - ipmi_context_t context); + * @return + * - timerUse + * - timerActions + * - pretimeout + * - timeruseFlags + * - initialCountdown + * - presentCountdown + **/ +ipmi::RspType<uint3_t, uint3_t, bool, bool, // timerUse + uint3_t, uint1_t, uint3_t, uint1_t, // timerAction + uint8_t, // pretimeout + std::bitset<8>, // expireFlags + uint16_t, // initial Countdown - Little Endian (deciseconds) + uint16_t // present Countdown - Little Endian (deciseconds) + > + ipmiGetWatchdogTimer(); diff --git a/app/watchdog_service.cpp b/app/watchdog_service.cpp index 284964d..3534e89 100644 --- a/app/watchdog_service.cpp +++ b/app/watchdog_service.cpp @@ -16,8 +16,6 @@ using phosphor::logging::elog; using phosphor::logging::entry; using phosphor::logging::level; using phosphor::logging::log; -using sdbusplus::message::variant_ns::get; -using sdbusplus::message::variant_ns::variant; using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; using sdbusplus::xyz::openbmc_project::State::server::convertForMessage; using sdbusplus::xyz::openbmc_project::State::server::Watchdog; @@ -72,18 +70,22 @@ WatchdogService::Properties WatchdogService::getProperties() } try { - std::map<std::string, variant<bool, uint64_t, std::string>> properties; + std::map<std::string, std::variant<bool, uint64_t, std::string>> + properties; response.read(properties); Properties wd_prop; - wd_prop.initialized = get<bool>(properties.at("Initialized")); - wd_prop.enabled = get<bool>(properties.at("Enabled")); + wd_prop.initialized = std::get<bool>(properties.at("Initialized")); + wd_prop.enabled = std::get<bool>(properties.at("Enabled")); wd_prop.expireAction = Watchdog::convertActionFromString( - get<std::string>(properties.at("ExpireAction"))); + std::get<std::string>(properties.at("ExpireAction"))); wd_prop.timerUse = Watchdog::convertTimerUseFromString( - get<std::string>(properties.at("CurrentTimerUse"))); + std::get<std::string>(properties.at("CurrentTimerUse"))); + wd_prop.expiredTimerUse = Watchdog::convertTimerUseFromString( + std::get<std::string>(properties.at("ExpiredTimerUse"))); - wd_prop.interval = get<uint64_t>(properties.at("Interval")); - wd_prop.timeRemaining = get<uint64_t>(properties.at("TimeRemaining")); + wd_prop.interval = std::get<uint64_t>(properties.at("Interval")); + wd_prop.timeRemaining = + std::get<uint64_t>(properties.at("TimeRemaining")); return wd_prop; } catch (const std::exception& e) @@ -121,9 +123,9 @@ T WatchdogService::getProperty(const std::string& key) } try { - variant<T> value; + std::variant<T> value; response.read(value); - return get<T>(value); + return std::get<T>(value); } catch (const std::exception& e) { @@ -145,7 +147,7 @@ void WatchdogService::setProperty(const std::string& key, const T& val) { bool wasValid = wd_service.isValid(bus); auto request = wd_service.newMethodCall(bus, prop_intf, "Set"); - request.append(wd_intf, key, variant<T>(val)); + request.append(wd_intf, key, std::variant<T>(val)); auto response = bus.call(request); if (response.is_method_error()) { @@ -153,7 +155,8 @@ void WatchdogService::setProperty(const std::string& key, const T& val) if (wasValid) { // Retry the request once in case the cached service was stale - return setProperty(key, val); + setProperty(key, val); + return; } log<level::ERR>("WatchdogService: Method error setting property", entry("PROPERTY=%s", key.c_str())); @@ -186,12 +189,12 @@ void WatchdogService::setTimerUse(TimerUse timerUse) setProperty("CurrentTimerUse", convertForMessage(timerUse)); } -void WatchdogService::setInterval(uint64_t interval) +void WatchdogService::setExpiredTimerUse(TimerUse timerUse) { - setProperty("Interval", interval); + setProperty("ExpiredTimerUse", convertForMessage(timerUse)); } -void WatchdogService::setTimeRemaining(uint64_t timeRemaining) +void WatchdogService::setInterval(uint64_t interval) { - setProperty("TimeRemaining", timeRemaining); + setProperty("Interval", interval); } diff --git a/app/watchdog_service.hpp b/app/watchdog_service.hpp index 0cf1c74..141bdb7 100644 --- a/app/watchdog_service.hpp +++ b/app/watchdog_service.hpp @@ -35,6 +35,7 @@ class WatchdogService bool enabled; Action expireAction; TimerUse timerUse; + TimerUse expiredTimerUse; uint64_t interval; uint64_t timeRemaining; }; @@ -78,18 +79,18 @@ class WatchdogService */ void setTimerUse(TimerUse timerUse); - /** @brief Sets the value of the interval property on the host watchdog + /** @brief Sets the value of the ExpiredTimerUse property on the host + * watchdog * - * @param[in] interval - The new interval value + * @param[in] timerUse - The new timerUse value */ - void setInterval(uint64_t interval); + void setExpiredTimerUse(TimerUse timerUse); - /** @brief Sets the value of the timeRemaining property on the host - * watchdog + /** @brief Sets the value of the interval property on the host watchdog * - * @param[in] timeRemaining - The new timeRemaining value + * @param[in] interval - The new interval value */ - void setTimeRemaining(uint64_t timeRemaining); + void setInterval(uint64_t interval); private: /** @brief sdbusplus handle */ |