parent
b2b741b476
commit
66f605324d
@ -0,0 +1,33 @@
|
||||
From f222df3081d965051be76b85ea52b4aff222edf1 Mon Sep 17 00:00:00 2001
|
||||
From: "William A. Kennington III" <wak@google.com>
|
||||
Date: Fri, 15 Jun 2018 14:47:12 -0700
|
||||
Subject: [PATCH] plugins/open: Fix for interrupted select
|
||||
|
||||
The select syscall can be interrupted for signals like SIGPROF. The IPMI
|
||||
command sent will still be outstanding but the send_command will return
|
||||
an error. When the next command is sent it will get the completion for
|
||||
the previous command and has the tendency to break state of end users.
|
||||
|
||||
Signed-off-by: William A. Kennington III <wak@google.com>
|
||||
---
|
||||
src/plugins/open/open.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/plugins/open/open.c b/src/plugins/open/open.c
|
||||
index 5beeac7..59b736d 100644
|
||||
--- a/src/plugins/open/open.c
|
||||
+++ b/src/plugins/open/open.c
|
||||
@@ -335,7 +335,9 @@ ipmi_openipmi_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
|
||||
FD_SET(intf->fd, &rset);
|
||||
read_timeout.tv_sec = IPMI_OPENIPMI_READ_TIMEOUT;
|
||||
read_timeout.tv_usec = 0;
|
||||
- retval = select(intf->fd+1, &rset, NULL, NULL, &read_timeout);
|
||||
+ do {
|
||||
+ retval = select(intf->fd+1, &rset, NULL, NULL, &read_timeout);
|
||||
+ } while (retval < 0 && errno == EINTR);
|
||||
if (retval < 0) {
|
||||
lperror(LOG_ERR, "I/O Error");
|
||||
if (data != NULL) {
|
||||
--
|
||||
2.40.1
|
||||
|
@ -0,0 +1,98 @@
|
||||
diff -up ipmitool-1.8.18/src/plugins/open/open.c.checking-received ipmitool-1.8.18/src/plugins/open/open.c
|
||||
--- ipmitool-1.8.18/src/plugins/open/open.c.checking-received 2023-07-25 17:14:22.112985375 +0200
|
||||
+++ ipmitool-1.8.18/src/plugins/open/open.c 2023-07-25 17:14:22.115985324 +0200
|
||||
@@ -336,48 +336,61 @@ ipmi_openipmi_send_cmd(struct ipmi_intf
|
||||
read_timeout.tv_sec = IPMI_OPENIPMI_READ_TIMEOUT;
|
||||
read_timeout.tv_usec = 0;
|
||||
do {
|
||||
- retval = select(intf->fd+1, &rset, NULL, NULL, &read_timeout);
|
||||
- } while (retval < 0 && errno == EINTR);
|
||||
- if (retval < 0) {
|
||||
- lperror(LOG_ERR, "I/O Error");
|
||||
- if (data != NULL) {
|
||||
- free(data);
|
||||
+ do {
|
||||
+ retval = select(intf->fd + 1, &rset, NULL, NULL, &read_timeout);
|
||||
+ } while (retval < 0 && errno == EINTR);
|
||||
+ if (retval < 0) {
|
||||
+ lperror(LOG_ERR, "I/O Error");
|
||||
+ if (data != NULL) {
|
||||
+ free(data);
|
||||
data = NULL;
|
||||
- }
|
||||
- return NULL;
|
||||
- } else if (retval == 0) {
|
||||
- lprintf(LOG_ERR, "No data available");
|
||||
- if (data != NULL) {
|
||||
- free(data);
|
||||
- data = NULL;
|
||||
- }
|
||||
- return NULL;
|
||||
- }
|
||||
- if (FD_ISSET(intf->fd, &rset) == 0) {
|
||||
- lprintf(LOG_ERR, "No data available");
|
||||
- if (data != NULL) {
|
||||
- free(data);
|
||||
+ }
|
||||
+ return NULL;
|
||||
+ } else if (retval == 0) {
|
||||
+ lprintf(LOG_ERR, "No data available");
|
||||
+ if (data != NULL) {
|
||||
+ free(data);
|
||||
data = NULL;
|
||||
+ }
|
||||
+ return NULL;
|
||||
}
|
||||
- return NULL;
|
||||
- }
|
||||
-
|
||||
- recv.addr = (unsigned char *) &addr;
|
||||
- recv.addr_len = sizeof(addr);
|
||||
- recv.msg.data = rsp.data;
|
||||
- recv.msg.data_len = sizeof(rsp.data);
|
||||
-
|
||||
- /* get data */
|
||||
- if (ioctl(intf->fd, IPMICTL_RECEIVE_MSG_TRUNC, &recv) < 0) {
|
||||
- lperror(LOG_ERR, "Error receiving message");
|
||||
- if (errno != EMSGSIZE) {
|
||||
+ if (FD_ISSET(intf->fd, &rset) == 0) {
|
||||
+ lprintf(LOG_ERR, "No data available");
|
||||
if (data != NULL) {
|
||||
free(data);
|
||||
data = NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
- }
|
||||
+
|
||||
+ recv.addr = (unsigned char *)&addr;
|
||||
+ recv.addr_len = sizeof(addr);
|
||||
+ recv.msg.data = rsp.data;
|
||||
+ recv.msg.data_len = sizeof(rsp.data);
|
||||
+
|
||||
+ /* get data */
|
||||
+ if (ioctl(intf->fd, IPMICTL_RECEIVE_MSG_TRUNC, &recv) < 0) {
|
||||
+ lperror(LOG_ERR, "Error receiving message");
|
||||
+ if (errno != EMSGSIZE) {
|
||||
+ if (data != NULL) {
|
||||
+ free(data);
|
||||
+ data = NULL;
|
||||
+ }
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* If the message received wasn't expected, try to grab the
|
||||
+ * next message until it's out of messages. -EAGAIN is
|
||||
+ * returned if the list empty, but basically if it returns a
|
||||
+ * message, check if it's alright.
|
||||
+ */
|
||||
+ if (_req.msgid != recv.msgid) {
|
||||
+ lprintf(LOG_NOTICE,
|
||||
+ "Received a response with unexpected ID %ld vs. %ld",
|
||||
+ recv.msgid, _req.msgid);
|
||||
+ }
|
||||
+ } while (_req.msgid != recv.msgid);
|
||||
|
||||
if (verbose > 4) {
|
||||
fprintf(stderr, "Got message:");
|
@ -0,0 +1,36 @@
|
||||
Description: Add IANA ID for NVIDIA hardware
|
||||
Add the NVIDIA IANA ID to the hardcoded list used in ipmitool <= 1.8.18.
|
||||
After upstream commit "9d41136 ID:491 - Fetch vendor IDs from IANA", ipmitool
|
||||
generates a list of vendor IDs dynamically at build time, so we can drop this
|
||||
patch in future releases.
|
||||
Author: dann frazier <dannf@debian.org>
|
||||
Origin: backport
|
||||
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=903616
|
||||
Forwarded: not-needed
|
||||
Last-Update: 2018-07-11
|
||||
---
|
||||
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
|
||||
Index: ipmitool-1.8.18/include/ipmitool/ipmi.h
|
||||
===================================================================
|
||||
--- ipmitool-1.8.18.orig/include/ipmitool/ipmi.h
|
||||
+++ ipmitool-1.8.18/include/ipmitool/ipmi.h
|
||||
@@ -279,6 +279,7 @@ typedef enum IPMI_OEM {
|
||||
/* 4769 for [IBM Corporation] */
|
||||
IPMI_OEM_IBM_4769 = 4769,
|
||||
IPMI_OEM_MAGNUM = 5593,
|
||||
+ IPMI_OEM_NVIDIA = 5703,
|
||||
IPMI_OEM_TYAN = 6653,
|
||||
IPMI_OEM_QUANTA = 7244,
|
||||
IPMI_OEM_NEWISYS = 9237,
|
||||
Index: ipmitool-1.8.18/lib/ipmi_strings.c
|
||||
===================================================================
|
||||
--- ipmitool-1.8.18.orig/lib/ipmi_strings.c
|
||||
+++ ipmitool-1.8.18/lib/ipmi_strings.c
|
||||
@@ -96,6 +96,7 @@ const struct valstr ipmi_oem_info[] = {
|
||||
{ IPMI_OEM_IBM_4769, "IBM Corporation" },
|
||||
{ IPMI_OEM_IBM_20301, "IBM eServer X" },
|
||||
{ IPMI_OEM_ADLINK_24339, "ADLINK Technology Inc." },
|
||||
+ { IPMI_OEM_NVIDIA, "NVIDIA Corporation" },
|
||||
{ 0xffff , NULL },
|
||||
};
|
||||
|
@ -0,0 +1,232 @@
|
||||
From 3e0ecc5edcccc85654784d0888dbeb2f116204e0 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Venture <venture@google.com>
|
||||
Date: Thu, 22 Nov 2018 15:40:24 -0800
|
||||
Subject: [PATCH] move static objects to source file
|
||||
|
||||
Move static objects declared in headers to the source files where
|
||||
they're used.
|
||||
|
||||
Partially resolves ipmitool/ipmitool#13
|
||||
|
||||
Signed-off-by: Patrick Venture <venture@google.com>
|
||||
---
|
||||
include/ipmitool/ipmi_sdr.h | 43 -----------
|
||||
lib/ipmi_sdr.c | 146 ++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 146 insertions(+), 43 deletions(-)
|
||||
|
||||
diff --git a/include/ipmitool/ipmi_sdr.h b/include/ipmitool/ipmi_sdr.h
|
||||
index 9001e59..5e6afd3 100644
|
||||
--- a/include/ipmitool/ipmi_sdr.h
|
||||
+++ b/include/ipmitool/ipmi_sdr.h
|
||||
|
||||
@@ -773,50 +773,7 @@ struct sdr_record_list {
|
||||
#pragma pack(0)
|
||||
#endif
|
||||
|
||||
-
|
||||
-/* unit description codes (IPMI v1.5 section 37.16) */
|
||||
-#define UNIT_MAX 0x90
|
||||
-static const char *unit_desc[] __attribute__ ((unused)) = {
|
||||
-"unspecified",
|
||||
- "degrees C", "degrees F", "degrees K",
|
||||
- "Volts", "Amps", "Watts", "Joules",
|
||||
- "Coulombs", "VA", "Nits",
|
||||
- "lumen", "lux", "Candela",
|
||||
- "kPa", "PSI", "Newton",
|
||||
- "CFM", "RPM", "Hz",
|
||||
- "microsecond", "millisecond", "second", "minute", "hour",
|
||||
- "day", "week", "mil", "inches", "feet", "cu in", "cu feet",
|
||||
- "mm", "cm", "m", "cu cm", "cu m", "liters", "fluid ounce",
|
||||
- "radians", "steradians", "revolutions", "cycles",
|
||||
- "gravities", "ounce", "pound", "ft-lb", "oz-in", "gauss",
|
||||
- "gilberts", "henry", "millihenry", "farad", "microfarad",
|
||||
- "ohms", "siemens", "mole", "becquerel", "PPM", "reserved",
|
||||
- "Decibels", "DbA", "DbC", "gray", "sievert",
|
||||
- "color temp deg K", "bit", "kilobit", "megabit", "gigabit",
|
||||
- "byte", "kilobyte", "megabyte", "gigabyte", "word", "dword",
|
||||
- "qword", "line", "hit", "miss", "retry", "reset",
|
||||
- "overflow", "underrun", "collision", "packets", "messages",
|
||||
- "characters", "error", "correctable error", "uncorrectable error",};
|
||||
-
|
||||
-/* sensor type codes (IPMI v1.5 table 36.3)
|
||||
- / Updated to v2.0 Table 42-3, Sensor Type Codes */
|
||||
#define SENSOR_TYPE_MAX 0x2C
|
||||
-static const char *sensor_type_desc[] __attribute__ ((unused)) = {
|
||||
-"reserved",
|
||||
- "Temperature", "Voltage", "Current", "Fan",
|
||||
- "Physical Security", "Platform Security", "Processor",
|
||||
- "Power Supply", "Power Unit", "Cooling Device", "Other",
|
||||
- "Memory", "Drive Slot / Bay", "POST Memory Resize",
|
||||
- "System Firmwares", "Event Logging Disabled", "Watchdog1",
|
||||
- "System Event", "Critical Interrupt", "Button",
|
||||
- "Module / Board", "Microcontroller", "Add-in Card",
|
||||
- "Chassis", "Chip Set", "Other FRU", "Cable / Interconnect",
|
||||
- "Terminator", "System Boot Initiated", "Boot Error",
|
||||
- "OS Boot", "OS Critical Stop", "Slot / Connector",
|
||||
- "System ACPI Power State", "Watchdog2", "Platform Alert",
|
||||
- "Entity Presence", "Monitor ASIC", "LAN",
|
||||
- "Management Subsys Health", "Battery", "Session Audit",
|
||||
- "Version Change", "FRU State" };
|
||||
|
||||
struct sensor_reading {
|
||||
char s_id[33]; /* name of the sensor */
|
||||
diff --git a/lib/ipmi_sdr.c b/lib/ipmi_sdr.c
|
||||
index d51c174..eb40b36 100644
|
||||
--- a/lib/ipmi_sdr.c
|
||||
+++ b/lib/ipmi_sdr.c
|
||||
@@ -68,6 +68,152 @@ static struct sdr_record_list *sdr_list_head = NULL;
|
||||
static struct sdr_record_list *sdr_list_tail = NULL;
|
||||
static struct ipmi_sdr_iterator *sdr_list_itr = NULL;
|
||||
|
||||
+/* unit description codes (IPMI v1.5 section 37.16) */
|
||||
+#define UNIT_MAX 0x90
|
||||
+static const char *unit_desc[] = {
|
||||
+ "unspecified",
|
||||
+ "degrees C",
|
||||
+ "degrees F",
|
||||
+ "degrees K",
|
||||
+ "Volts",
|
||||
+ "Amps",
|
||||
+ "Watts",
|
||||
+ "Joules",
|
||||
+ "Coulombs",
|
||||
+ "VA",
|
||||
+ "Nits",
|
||||
+ "lumen",
|
||||
+ "lux",
|
||||
+ "Candela",
|
||||
+ "kPa",
|
||||
+ "PSI",
|
||||
+ "Newton",
|
||||
+ "CFM",
|
||||
+ "RPM",
|
||||
+ "Hz",
|
||||
+ "microsecond",
|
||||
+ "millisecond",
|
||||
+ "second",
|
||||
+ "minute",
|
||||
+ "hour",
|
||||
+ "day",
|
||||
+ "week",
|
||||
+ "mil",
|
||||
+ "inches",
|
||||
+ "feet",
|
||||
+ "cu in",
|
||||
+ "cu feet",
|
||||
+ "mm",
|
||||
+ "cm",
|
||||
+ "m",
|
||||
+ "cu cm",
|
||||
+ "cu m",
|
||||
+ "liters",
|
||||
+ "fluid ounce",
|
||||
+ "radians",
|
||||
+ "steradians",
|
||||
+ "revolutions",
|
||||
+ "cycles",
|
||||
+ "gravities",
|
||||
+ "ounce",
|
||||
+ "pound",
|
||||
+ "ft-lb",
|
||||
+ "oz-in",
|
||||
+ "gauss",
|
||||
+ "gilberts",
|
||||
+ "henry",
|
||||
+ "millihenry",
|
||||
+ "farad",
|
||||
+ "microfarad",
|
||||
+ "ohms",
|
||||
+ "siemens",
|
||||
+ "mole",
|
||||
+ "becquerel",
|
||||
+ "PPM",
|
||||
+ "reserved",
|
||||
+ "Decibels",
|
||||
+ "DbA",
|
||||
+ "DbC",
|
||||
+ "gray",
|
||||
+ "sievert",
|
||||
+ "color temp deg K",
|
||||
+ "bit",
|
||||
+ "kilobit",
|
||||
+ "megabit",
|
||||
+ "gigabit",
|
||||
+ "byte",
|
||||
+ "kilobyte",
|
||||
+ "megabyte",
|
||||
+ "gigabyte",
|
||||
+ "word",
|
||||
+ "dword",
|
||||
+ "qword",
|
||||
+ "line",
|
||||
+ "hit",
|
||||
+ "miss",
|
||||
+ "retry",
|
||||
+ "reset",
|
||||
+ "overflow",
|
||||
+ "underrun",
|
||||
+ "collision",
|
||||
+ "packets",
|
||||
+ "messages",
|
||||
+ "characters",
|
||||
+ "error",
|
||||
+ "correctable error",
|
||||
+ "uncorrectable error"
|
||||
+};
|
||||
+
|
||||
+/* sensor type codes (IPMI v1.5 table 36.3)
|
||||
+ / Updated to v2.0 Table 42-3, Sensor Type Codes */
|
||||
+static const char *sensor_type_desc[] = {
|
||||
+ "reserved",
|
||||
+ "Temperature",
|
||||
+ "Voltage",
|
||||
+ "Current",
|
||||
+ "Fan",
|
||||
+ "Physical Security",
|
||||
+ "Platform Security",
|
||||
+ "Processor",
|
||||
+ "Power Supply",
|
||||
+ "Power Unit",
|
||||
+ "Cooling Device",
|
||||
+ "Other",
|
||||
+ "Memory",
|
||||
+ "Drive Slot / Bay",
|
||||
+ "POST Memory Resize",
|
||||
+ "System Firmwares",
|
||||
+ "Event Logging Disabled",
|
||||
+ "Watchdog1",
|
||||
+ "System Event",
|
||||
+ "Critical Interrupt",
|
||||
+ "Button",
|
||||
+ "Module / Board",
|
||||
+ "Microcontroller",
|
||||
+ "Add-in Card",
|
||||
+ "Chassis",
|
||||
+ "Chip Set",
|
||||
+ "Other FRU",
|
||||
+ "Cable / Interconnect",
|
||||
+ "Terminator",
|
||||
+ "System Boot Initiated",
|
||||
+ "Boot Error",
|
||||
+ "OS Boot",
|
||||
+ "OS Critical Stop",
|
||||
+ "Slot / Connector",
|
||||
+ "System ACPI Power State",
|
||||
+ "Watchdog2",
|
||||
+ "Platform Alert",
|
||||
+ "Entity Presence",
|
||||
+ "Monitor ASIC",
|
||||
+ "LAN",
|
||||
+ "Management Subsys Health",
|
||||
+ "Battery",
|
||||
+ "Session Audit",
|
||||
+ "Version Change",
|
||||
+ "FRU State"
|
||||
+};
|
||||
+
|
||||
void printf_sdr_usage();
|
||||
|
||||
/* From src/plugins/ipmi_intf.c: */
|
||||
--
|
||||
2.40.1
|
||||
|
@ -0,0 +1,201 @@
|
||||
From 12e2f5da63fcfdb544f87ec492e5b1bc4f89868c Mon Sep 17 00:00:00 2001
|
||||
From: Alexander Amelkin <alexander@amelkin.msk.ru>
|
||||
Date: Fri, 19 Apr 2019 15:07:25 +0300
|
||||
Subject: [PATCH] sdr: Fix segfault on invalid unit types
|
||||
|
||||
The program would crash if the BMC returned an out of range (>90)
|
||||
unit type for a full sensor record. This commit adds a range check
|
||||
and also add support for IPMI 2.0 additional unit types 91 and 92
|
||||
("fatal error" and "grams").
|
||||
|
||||
Resolves ipmitool/ipmitool#118
|
||||
|
||||
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
|
||||
---
|
||||
include/ipmitool/ipmi_sdr.h | 32 ++++++++++++++---
|
||||
lib/ipmi_sdr.c | 72 +++++++++++++++++++++++++------------
|
||||
2 files changed, 78 insertions(+), 26 deletions(-)
|
||||
|
||||
diff --git a/include/ipmitool/ipmi_sdr.h b/include/ipmitool/ipmi_sdr.h
|
||||
index 5e6afd3..9f783c4 100644
|
||||
--- a/include/ipmitool/ipmi_sdr.h
|
||||
+++ b/include/ipmitool/ipmi_sdr.h
|
||||
@@ -37,6 +37,7 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
+#include <stdbool.h>
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#include <ipmitool/bswap.h>
|
||||
@@ -381,6 +382,29 @@ struct sdr_record_common_sensor {
|
||||
|
||||
struct sdr_record_mask mask;
|
||||
|
||||
+/* IPMI 2.0, Table 43-1, byte 21[7:6] Analog (numeric) Data Format */
|
||||
+#define SDR_UNIT_FMT_UNSIGNED 0 /* unsigned */
|
||||
+#define SDR_UNIT_FMT_1S_COMPL 1 /* 1's complement (signed) */
|
||||
+#define SDR_UNIT_FMT_2S_COMPL 2 /* 2's complement (signed) */
|
||||
+#define SDR_UNIT_FMT_NA 3 /* does not return analog (numeric) reading */
|
||||
+/* IPMI 2.0, Table 43-1, byte 21[5:3] Rate */
|
||||
+#define SDR_UNIT_RATE_NONE 0 /* none */
|
||||
+#define SDR_UNIT_RATE_MICROSEC 1 /* per us */
|
||||
+#define SDR_UNIT_RATE_MILLISEC 2 /* per ms */
|
||||
+#define SDR_UNIT_RATE_SEC 3 /* per s */
|
||||
+#define SDR_UNIT_RATE_MIN 4 /* per min */
|
||||
+#define SDR_UNIT_RATE_HR 5 /* per hour */
|
||||
+#define SDR_UNIT_RATE_DAY 6 /* per day */
|
||||
+#define SDR_UNIT_RATE_RSVD 7 /* reserved */
|
||||
+/* IPMI 2.0, Table 43-1, byte 21[2:1] Modifier Unit */
|
||||
+#define SDR_UNIT_MOD_NONE 0 /* none */
|
||||
+#define SDR_UNIT_MOD_DIV 1 /* Basic Unit / Modifier Unit */
|
||||
+#define SDR_UNIT_MOD_MUL 2 /* Basic Unit * Mofifier Unit */
|
||||
+#define SDR_UNIT_MOD_RSVD 3 /* Reserved */
|
||||
+/* IPMI 2.0, Table 43-1, byte 21[0] Percentage */
|
||||
+#define SDR_UNIT_PCT_NO 0
|
||||
+#define SDR_UNIT_PCT_YES 1
|
||||
+
|
||||
struct {
|
||||
#if WORDS_BIGENDIAN
|
||||
uint8_t analog:2;
|
||||
@@ -394,8 +418,8 @@ struct sdr_record_common_sensor {
|
||||
uint8_t analog:2;
|
||||
#endif
|
||||
struct {
|
||||
- uint8_t base;
|
||||
- uint8_t modifier;
|
||||
+ uint8_t base; /* Base unit type code per IPMI 2.0 Table 43-15 */
|
||||
+ uint8_t modifier; /* Modifier unit type code per Table 43-15 */
|
||||
} ATTRIBUTE_PACKING type;
|
||||
} ATTRIBUTE_PACKING unit;
|
||||
} ATTRIBUTE_PACKING;
|
||||
@@ -833,8 +857,8 @@ void ipmi_sdr_print_sensor_hysteresis(struct sdr_record_common_sensor *sensor,
|
||||
struct sdr_record_full_sensor *full,
|
||||
uint8_t hysteresis_value,
|
||||
const char *hdrstr);
|
||||
-const char *ipmi_sdr_get_unit_string(uint8_t pct, uint8_t type,
|
||||
- uint8_t base, uint8_t modifier);
|
||||
+const char *ipmi_sdr_get_unit_string(bool pct, uint8_t type,
|
||||
+ uint8_t base, uint8_t modifier);
|
||||
struct sensor_reading *
|
||||
ipmi_sdr_read_sensor_value(struct ipmi_intf *intf,
|
||||
struct sdr_record_common_sensor *sensor,
|
||||
diff --git a/lib/ipmi_sdr.c b/lib/ipmi_sdr.c
|
||||
index eb40b36..b43765a 100644
|
||||
--- a/lib/ipmi_sdr.c
|
||||
+++ b/lib/ipmi_sdr.c
|
||||
@@ -68,8 +68,9 @@ static struct sdr_record_list *sdr_list_head = NULL;
|
||||
static struct sdr_record_list *sdr_list_tail = NULL;
|
||||
static struct ipmi_sdr_iterator *sdr_list_itr = NULL;
|
||||
|
||||
-/* unit description codes (IPMI v1.5 section 37.16) */
|
||||
-#define UNIT_MAX 0x90
|
||||
+/* IPMI 2.0 Table 43-15, Sensor Unit Type Codes */
|
||||
+#define UNIT_TYPE_MAX 92 /* This is the ID of "grams" */
|
||||
+#define UNIT_TYPE_LONGEST_NAME 19 /* This is the length of "color temp deg K" */
|
||||
static const char *unit_desc[] = {
|
||||
"unspecified",
|
||||
"degrees C",
|
||||
@@ -161,7 +162,9 @@ static const char *unit_desc[] = {
|
||||
"characters",
|
||||
"error",
|
||||
"correctable error",
|
||||
- "uncorrectable error"
|
||||
+ "uncorrectable error",
|
||||
+ "fatal error",
|
||||
+ "grams"
|
||||
};
|
||||
|
||||
/* sensor type codes (IPMI v1.5 table 36.3)
|
||||
@@ -220,35 +223,60 @@ void printf_sdr_usage();
|
||||
uint16_t
|
||||
ipmi_intf_get_max_response_data_size(struct ipmi_intf * intf);
|
||||
|
||||
-/* ipmi_sdr_get_unit_string - return units for base/modifier
|
||||
+/** ipmi_sdr_get_unit_string - return units for base/modifier
|
||||
*
|
||||
- * @pct: units are a percentage
|
||||
- * @type: unit type
|
||||
- * @base: base
|
||||
- * @modifier: modifier
|
||||
+ * @param[in] pct Indicates that units are a percentage
|
||||
+ * @param[in] relation Modifier unit to base unit relation
|
||||
+ * (SDR_UNIT_MOD_NONE, SDR_UNIT_MOD_MUL,
|
||||
+ * or SDR_UNIT_MOD_DIV)
|
||||
+ * @param[in] base The base unit type id
|
||||
+ * @param[in] modifier The modifier unit type id
|
||||
*
|
||||
- * returns pointer to static string
|
||||
+ * @returns a pointer to static string
|
||||
*/
|
||||
const char *
|
||||
-ipmi_sdr_get_unit_string(uint8_t pct, uint8_t type, uint8_t base, uint8_t modifier)
|
||||
+ipmi_sdr_get_unit_string(bool pct, uint8_t relation,
|
||||
+ uint8_t base, uint8_t modifier)
|
||||
{
|
||||
- static char unitstr[16];
|
||||
+ /*
|
||||
+ * Twice as long as the longest possible unit name, plus
|
||||
+ * four characters for '%' and relation (either ' * ' or '/'),
|
||||
+ * plus the terminating null-byte.
|
||||
+ */
|
||||
+ static char unitstr[2 * UNIT_TYPE_LONGEST_NAME + 4 + 1];
|
||||
+
|
||||
/*
|
||||
* By default, if units are supposed to be percent, we will pre-pend
|
||||
* the percent string to the textual representation of the units.
|
||||
*/
|
||||
- char *pctstr = pct ? "% " : "";
|
||||
- memset(unitstr, 0, sizeof (unitstr));
|
||||
- switch (type) {
|
||||
- case 2:
|
||||
- snprintf(unitstr, sizeof (unitstr), "%s%s * %s",
|
||||
- pctstr, unit_desc[base], unit_desc[modifier]);
|
||||
+ const char *pctstr = pct ? "% " : "";
|
||||
+ const char *basestr;
|
||||
+ const char *modstr;
|
||||
+
|
||||
+ if (base <= UNIT_TYPE_MAX) {
|
||||
+ basestr = unit_desc[base];
|
||||
+ }
|
||||
+ else {
|
||||
+ basestr = "invalid";
|
||||
+ }
|
||||
+
|
||||
+ if (modifier <= UNIT_TYPE_MAX) {
|
||||
+ modstr = unit_desc[modifier];
|
||||
+ }
|
||||
+ else {
|
||||
+ modstr = "invalid";
|
||||
+ }
|
||||
+
|
||||
+ switch (relation) {
|
||||
+ case SDR_UNIT_MOD_MUL:
|
||||
+ snprintf(unitstr, sizeof (unitstr), "%s%s * %s",
|
||||
+ pctstr, basestr, modstr);
|
||||
break;
|
||||
- case 1:
|
||||
+ case SDR_UNIT_MOD_DIV:
|
||||
snprintf(unitstr, sizeof (unitstr), "%s%s/%s",
|
||||
- pctstr, unit_desc[base], unit_desc[modifier]);
|
||||
+ pctstr, basestr, modstr);
|
||||
break;
|
||||
- case 0:
|
||||
+ case SDR_UNIT_MOD_NONE:
|
||||
default:
|
||||
/*
|
||||
* Display the text "percent" only when the Base unit is
|
||||
@@ -257,8 +285,8 @@ ipmi_sdr_get_unit_string(uint8_t pct, uint8_t type, uint8_t base, uint8_t modifi
|
||||
if (base == 0 && pct) {
|
||||
snprintf(unitstr, sizeof(unitstr), "percent");
|
||||
} else {
|
||||
- snprintf(unitstr, sizeof (unitstr), "%s%s",
|
||||
- pctstr, unit_desc[base]);
|
||||
+ snprintf(unitstr, sizeof (unitstr), "%s%s",
|
||||
+ pctstr, basestr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
--
|
||||
2.40.1
|
||||
|
@ -1 +1 @@
|
||||
IPMIEVD_OPTIONS="sel daemon pidfile=/var/run/ipmievd.pid"
|
||||
IPMIEVD_OPTIONS="sel daemon pidfile=/run/ipmievd.pid"
|
||||
|
Loading…
Reference in new issue