OpenIPMI plugin uses 0x20 as local IPMB address when no -m or -t parameter is specified. Some HW (e.g. Dell 1855) uses different local address, which is available using ioctl(IPMICTL_GET_MY_ADDRESS_CMD) - so let's try to read it and fall back to 0x20 if it's not available.
It helps reading sensors - local IPMB address on the Dell 1855 is 0xc2. This address is also owner of the sensors. But ipmitool thinks the local address is 0x20 -> it tries to bridge sensor readings from 0x20 to 0xc2 -> error. With this patch, ipmitool tries to read IPMB address from /dev/ipmi and knows that both local address and sensor owner is 0xc2 -> no bridging. Signed-off-by: Jan Safranek <jsafr...@redhat.com> --- lib/ipmi_main.c | 2 +- src/plugins/open/open.c | 30 +++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/ipmi_main.c b/lib/ipmi_main.c index 3efd950..33bcc01 100644 --- a/lib/ipmi_main.c +++ b/lib/ipmi_main.c @@ -784,7 +784,7 @@ ipmi_main(int argc, char ** argv, } else{ lprintf(LOG_INFO, - "No PICMG Extenstion discovered, keeping IPMB address 0x20"); + "No PICMG Extenstion discovered, keeping default IPMB address."); } } diff --git a/src/plugins/open/open.c b/src/plugins/open/open.c index e40476c..a3c8a0d 100644 --- a/src/plugins/open/open.c +++ b/src/plugins/open/open.c @@ -101,7 +101,6 @@ ipmi_openipmi_open(struct ipmi_intf * intf) intf->opened = 1; - /* This is never set to 0, the default is IPMI_BMC_SLAVE_ADDR */ if (intf->my_addr != 0) { unsigned int a = intf->my_addr; if (ioctl(intf->fd, IPMICTL_SET_MY_ADDRESS_CMD, &a) < 0) { @@ -111,6 +110,31 @@ ipmi_openipmi_open(struct ipmi_intf * intf) lprintf(LOG_DEBUG, "Set IPMB address to 0x%x", intf->my_addr ); + } else { + /* + * No local address provided on command line, read it from + * the device. + */ + unsigned int local_addr = 0; + if (ioctl(intf->fd, IPMICTL_GET_MY_ADDRESS_CMD, &local_addr) + >= 0) { + lprintf(LOG_INFO, "Discovered local IPMB address " + "0x%x", local_addr); + intf->my_addr = local_addr; + } else { + lprintf(LOG_INFO, "Cannot read local IPMB address, " + "using IPMI_BMC_SLAVE_ADDR"); + intf->my_addr = IPMI_BMC_SLAVE_ADDR; + } + } + if (intf->target_addr == 0) { + intf->target_addr = intf->my_addr; + /* + * This address might get overwritten in ipmi_main, so no INFO + * log. + */ + lprintf(LOG_DEBUG, "Using target IPMB address 0x%x", + intf->target_addr); } return intf->fd; @@ -377,6 +401,6 @@ struct ipmi_intf ipmi_open_intf = { open: ipmi_openipmi_open, close: ipmi_openipmi_close, sendrecv: ipmi_openipmi_send_cmd, - my_addr: IPMI_BMC_SLAVE_ADDR, - target_addr: IPMI_BMC_SLAVE_ADDR, + my_addr: 0, + target_addr: 0, }; ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ Ipmitool-devel mailing list Ipmitool-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ipmitool-devel