Hi,

Please find attached a patch that allows ipmitool (and ipmievd) to address 
the various /dev/ipmiN devices created and accessible on multi-node/multi-BMC 
systems.  Ipmitool and ipmievd currently are hard-coded to allow in-band access 
only to the "0" device node (ex. /dev/ipmi0) created by the openipmi device 
driver.
On multi-node systems, the ipmi driver creates a device node for each BMC in 
the system.  The attached patch allows ipmitool and ipmievd to be used to send 
in-band commands to each BMC.

One remaining inconsistency is in the contrib/ipmievd.init.debian file.  The
ipmievd pidfile is defined in ipmievd.init.debian as /var/run/ipmievd.pid 
whereas 
the attached patch changes the default ipmievd pidfile name to 
/var/run/ipmievd.pidN 
since an ipmievd daemon will be able be started for each BMC.  There does not 
appear 
to be anyone using the pidfile definition in ipmievd.init.debian but I wanted 
to make 
note of the inconsistency so it could be addressed or at least filed away for 
the future.

I'm pasting the patch in-line and also attaching a copy of it as a text file 
(in case
Evolution munges the in-line version).  I'm hoping to get this patch reviewed 
(and 
accepted :-} in time to make it into v1.8.9.

Thank you very much for your review.  Any and all comments are appreciated. :-)

Carol Hebert

------------------------------------------------------------------------------

diff -Naur ipmitool-1.8.8.90.orig/doc/ipmievd.8 ipmitool-1.8.8.90/doc/ipmievd.8
--- ipmitool-1.8.8.90.orig/doc/ipmievd.8        2006-04-27 11:05:57.000000000 
-0700
+++ ipmitool-1.8.8.90/doc/ipmievd.8     2007-02-01 14:14:15.000000000 -0800
@@ -2,7 +2,7 @@
 .SH "NAME"
 ipmievd \- IPMI event daemon for sending events to syslog
 .SH "SYNOPSIS"
-ipmievd [\fB\-c\fR|\fB\-h\fR|\fB\-v\fR|\fB\-V\fR]
+ipmievd [\fB\-c\fR|\fB\-h\fR|\fB\-d \fIN\fP\fR|\fB\-v\fR|\fB\-V\fR]
 \fB\-I\fR \fIopen\fP <\fIopen\fR | \fIsel\fR> [<\fIoption\fP>]

 ipmievd [\fB\-c\fR|\fB\-h\fR|\fB\-v\fR|\fB\-V\fR]
@@ -116,6 +116,13 @@
 \fB\-U\fR <\fIusername\fP>
 Remote server username, default is NULL user.
 .TP
+\fB\-d \fIN\fP\fR
+Use device number N to specify the /dev/ipmiN (or
+/dev/ipmi/N or /dev/ipmidev/N) device to use for in-band
+BMC communication.  Used to target a specific BMC on a
+multi-node, multi-BMC system through the ipmi device
+driver interface.  Default is 0.
+.TP
 \fB\-v\fR
 Increase verbose output level.  This option may be specified
 multiple times to increase the level of debug output.  If given
@@ -167,7 +174,8 @@
 .TP
 \fIpidfile\fP=<\fBfilename\fR>
 Save process ID to this file when in daemon mode.  Defaults to
-/var/run/ipmievd.pid.
+/var/run/ipmievd.pid\fIN\fP (where \fIN\fP is the ipmi device
+number -- defaults to 0).
 .RE

 .TP
@@ -189,7 +197,8 @@
 .TP
 \fIpidfile\fP=<\fBfilename\fR>
 Save process ID to this file when in daemon mode.  Defaults to
-/var/run/ipmievd.pid.
+/var/run/ipmievd.pid\fIN\fP (where \fIN\fP is the ipmi device
+number -- defaults to 0).
 .TP
 \fItimeout\fP=<\fBseconds\fR>
 Time between checks for SEL polling method.  Default is 10 seconds.
diff -Naur ipmitool-1.8.8.90.orig/doc/ipmitool.1 
ipmitool-1.8.8.90/doc/ipmitool.1
--- ipmitool-1.8.8.90.orig/doc/ipmitool.1       2006-04-27 11:05:57.000000000 
-0700
+++ ipmitool-1.8.8.90/doc/ipmitool.1    2007-02-01 14:14:15.000000000 -0800
@@ -2,7 +2,7 @@
 .SH "NAME"
 ipmitool \- utility for controlling IPMI\-enabled devices
 .SH "SYNOPSIS"
-ipmitool [\fB\-c\fR|\fB\-h\fR|\fB\-v\fR|\fB\-V\fR]
+ipmitool [\fB\-c\fR|\fB\-h\fR|\fB\-d \fIN\fP\fR|\fB\-v\fR|\fB\-V\fR]
 \fB\-I\fR \fIopen\fP <\fIcommand\fP>

 ipmitool [\fB\-c\fR|\fB\-h\fR|\fB\-v\fR|\fB\-V\fR]
@@ -130,6 +130,13 @@
 .TP
 \fB\-U\fR <\fIusername\fP>
 Remote server username, default is NULL user.
+.TP
+\fB\-d \fIN\fP\fR
+Use device number N to specify the /dev/ipmiN (or
+/dev/ipmi/N or /dev/ipmidev/N) device to use for in-band
+BMC communication.  Used to target a specific BMC on a
+multi-node, multi-BMC system through the ipmi device
+driver interface.  Default is 0.
 .TP
 \fB\-v\fR
 Increase verbose output level.  This option may be specified
diff -Naur ipmitool-1.8.8.90.orig/include/ipmitool/ipmi_intf.h 
ipmitool-1.8.8.90/include/ipmitool/ipmi_intf.h
--- ipmitool-1.8.8.90.orig/include/ipmitool/ipmi_intf.h 2006-09-12 
16:23:28.000000000 -0700
+++ ipmitool-1.8.8.90/include/ipmitool/ipmi_intf.h      2007-02-01 
14:14:15.000000000 -0800
@@ -174,6 +174,8 @@
        uint8_t target_lun;
        uint8_t target_channel;

+       uint8_t devnum;
+
        int (*setup)(struct ipmi_intf * intf);
        int (*open)(struct ipmi_intf * intf);
        void (*close)(struct ipmi_intf * intf);
diff -Naur ipmitool-1.8.8.90.orig/lib/ipmi_main.c 
ipmitool-1.8.8.90/lib/ipmi_main.c
--- ipmitool-1.8.8.90.orig/lib/ipmi_main.c      2006-09-12 16:23:28.000000000 
-0700
+++ ipmitool-1.8.8.90/lib/ipmi_main.c   2007-02-01 14:14:15.000000000 -0800
@@ -71,9 +71,9 @@
 #endif

 #ifdef ENABLE_ALL_OPTIONS
-# define OPTION_STRING "I:hVvcgsEao:H:P:f:U:p:C:L:A:t:m:S:l:b:e:k:O:"
+# define OPTION_STRING "I:hVvcgsEao:H:d:P:f:U:p:C:L:A:t:m:S:l:b:e:k:O:"
 #else
-# define OPTION_STRING "I:hVvcH:f:U:p:S:"
+# define OPTION_STRING "I:hVvcH:f:U:p:d:S:"
 #endif

 extern int verbose;
@@ -216,6 +216,7 @@
        lprintf(LOG_NOTICE, "       -V             Show version information");
        lprintf(LOG_NOTICE, "       -v             Verbose (can use multiple 
times)");
        lprintf(LOG_NOTICE, "       -c             Display output in comma 
separated format");
+       lprintf(LOG_NOTICE, "       -d N           Specify a /dev/ipmiN device 
to use (default=0)");
        lprintf(LOG_NOTICE, "       -I intf        Interface to use");
        lprintf(LOG_NOTICE, "       -H hostname    Remote host name for LAN 
interface");
        lprintf(LOG_NOTICE, "       -p port        Remote RMCP port 
[default=623]");
@@ -283,6 +284,7 @@
        char * kgkey    = NULL;
        char * seloem   = NULL;
        int port = 0;
+       int devnum = 0;
        int cipher_suite_id = 3; /* See table 22-19 of the IPMIv2 spec */
        int argflag, i, found;
        int rc = -1;
@@ -325,6 +327,9 @@
                        rc = 0;
                        goto out_free;
                        break;
+               case 'd':
+                       devnum = atoi(optarg);
+                       break;
                case 'p':
                        port = atoi(optarg);
                        break;
@@ -582,6 +587,8 @@
        /* setup destination channel if given */
        intf->target_channel = target_channel ;

+       intf->devnum = devnum;
+
        /* setup IPMB local and target address if given */
        intf->my_addr = my_addr ? : IPMI_BMC_SLAVE_ADDR;
        if (target_addr > 0) {
diff -Naur ipmitool-1.8.8.90.orig/src/ipmievd.c ipmitool-1.8.8.90/src/ipmievd.c
--- ipmitool-1.8.8.90.orig/src/ipmievd.c        2006-09-14 09:20:59.000000000 
-0700
+++ ipmitool-1.8.8.90/src/ipmievd.c     2007-02-01 15:06:14.000000000 -0800
@@ -624,7 +624,8 @@
        struct sigaction act;

        memset(pidfile, 0, 64);
-       strncpy(pidfile, DEFAULT_PIDFILE, strlen(DEFAULT_PIDFILE));
+       sprintf(pidfile, "%s%d", DEFAULT_PIDFILE, eintf->intf->devnum);
+       lprintf(LOG_NOTICE, "ipmievd: using pidfile %s", pidfile);

        for (i = 0; i < argc; i++) {
                if (strncasecmp(argv[i], "help", 4) == 0) {
diff -Naur ipmitool-1.8.8.90.orig/src/plugins/open/open.c 
ipmitool-1.8.8.90/src/plugins/open/open.c
--- ipmitool-1.8.8.90.orig/src/plugins/open/open.c      2006-09-14 
09:20:59.000000000 -0700
+++ ipmitool-1.8.8.90/src/plugins/open/open.c   2007-02-01 14:14:15.000000000 
-0800
@@ -63,10 +63,6 @@

 extern int verbose;

-#define IPMI_OPENIPMI_DEV      "/dev/ipmi0"
-#define IPMI_OPENIPMI_DEVFS    "/dev/ipmi/0"
-#define IPMI_OPENIPMI_DEVFS2   "/dev/ipmidev/0"
-
 static int
 ipmi_openipmi_open(struct ipmi_intf * intf)
 {
@@ -76,17 +72,28 @@
        struct ipmi_rs *rsp;
        char msg_data;
 #endif
+       char ipmi_dev[16];
+       char ipmi_devfs[16];
+       char ipmi_devfs2[16];
+       int devnum = 0;
+
+       devnum = intf->devnum;
+
+       sprintf(ipmi_dev, "/dev/ipmi%d", devnum);
+       sprintf(ipmi_devfs, "/dev/ipmi/%d", devnum);
+       sprintf(ipmi_devfs2, "/dev/ipmidev/%d", devnum);
+       lprintf(LOG_DEBUG, "Using ipmi device %d", devnum);

-       intf->fd = open(IPMI_OPENIPMI_DEV, O_RDWR);
+       intf->fd = open(ipmi_dev, O_RDWR);

        if (intf->fd < 0) {
-               intf->fd = open(IPMI_OPENIPMI_DEVFS, O_RDWR);
+               intf->fd = open(ipmi_devfs, O_RDWR);
                if (intf->fd < 0) {
-                       intf->fd = open(IPMI_OPENIPMI_DEVFS2, O_RDWR);
+                       intf->fd = open(ipmi_devfs2, O_RDWR);
                }
                if (intf->fd < 0) {
                        lperror(LOG_ERR, "Could not open device at %s or %s or 
%s",
-                       IPMI_OPENIPMI_DEV, IPMI_OPENIPMI_DEVFS , 
IPMI_OPENIPMI_DEVFS2);
+                       ipmi_dev, ipmi_devfs , ipmi_devfs2);
                        return -1;
                }
        }

diff -Naur ipmitool-1.8.8.90.orig/doc/ipmievd.8 ipmitool-1.8.8.90/doc/ipmievd.8
--- ipmitool-1.8.8.90.orig/doc/ipmievd.8	2006-04-27 11:05:57.000000000 -0700
+++ ipmitool-1.8.8.90/doc/ipmievd.8	2007-02-01 14:14:15.000000000 -0800
@@ -2,7 +2,7 @@
 .SH "NAME"
 ipmievd \- IPMI event daemon for sending events to syslog
 .SH "SYNOPSIS"
-ipmievd [\fB\-c\fR|\fB\-h\fR|\fB\-v\fR|\fB\-V\fR]
+ipmievd [\fB\-c\fR|\fB\-h\fR|\fB\-d \fIN\fP\fR|\fB\-v\fR|\fB\-V\fR]
 \fB\-I\fR \fIopen\fP <\fIopen\fR | \fIsel\fR> [<\fIoption\fP>]
 
 ipmievd [\fB\-c\fR|\fB\-h\fR|\fB\-v\fR|\fB\-V\fR]
@@ -116,6 +116,13 @@
 \fB\-U\fR <\fIusername\fP>
 Remote server username, default is NULL user.
 .TP 
+\fB\-d \fIN\fP\fR
+Use device number N to specify the /dev/ipmiN (or 
+/dev/ipmi/N or /dev/ipmidev/N) device to use for in-band 
+BMC communication.  Used to target a specific BMC on a 
+multi-node, multi-BMC system through the ipmi device 
+driver interface.  Default is 0.
+.TP 
 \fB\-v\fR
 Increase verbose output level.  This option may be specified
 multiple times to increase the level of debug output.  If given
@@ -167,7 +174,8 @@
 .TP
 \fIpidfile\fP=<\fBfilename\fR>
 Save process ID to this file when in daemon mode.  Defaults to
-/var/run/ipmievd.pid.
+/var/run/ipmievd.pid\fIN\fP (where \fIN\fP is the ipmi device
+number -- defaults to 0).
 .RE
 
 .TP 
@@ -189,7 +197,8 @@
 .TP
 \fIpidfile\fP=<\fBfilename\fR>
 Save process ID to this file when in daemon mode.  Defaults to
-/var/run/ipmievd.pid.
+/var/run/ipmievd.pid\fIN\fP (where \fIN\fP is the ipmi device
+number -- defaults to 0).
 .TP 
 \fItimeout\fP=<\fBseconds\fR>
 Time between checks for SEL polling method.  Default is 10 seconds.
diff -Naur ipmitool-1.8.8.90.orig/doc/ipmitool.1 ipmitool-1.8.8.90/doc/ipmitool.1
--- ipmitool-1.8.8.90.orig/doc/ipmitool.1	2006-04-27 11:05:57.000000000 -0700
+++ ipmitool-1.8.8.90/doc/ipmitool.1	2007-02-01 14:14:15.000000000 -0800
@@ -2,7 +2,7 @@
 .SH "NAME"
 ipmitool \- utility for controlling IPMI\-enabled devices
 .SH "SYNOPSIS"
-ipmitool [\fB\-c\fR|\fB\-h\fR|\fB\-v\fR|\fB\-V\fR]
+ipmitool [\fB\-c\fR|\fB\-h\fR|\fB\-d \fIN\fP\fR|\fB\-v\fR|\fB\-V\fR]
 \fB\-I\fR \fIopen\fP <\fIcommand\fP>
 
 ipmitool [\fB\-c\fR|\fB\-h\fR|\fB\-v\fR|\fB\-V\fR]
@@ -130,6 +130,13 @@
 .TP 
 \fB\-U\fR <\fIusername\fP>
 Remote server username, default is NULL user.
+.TP
+\fB\-d \fIN\fP\fR
+Use device number N to specify the /dev/ipmiN (or 
+/dev/ipmi/N or /dev/ipmidev/N) device to use for in-band 
+BMC communication.  Used to target a specific BMC on a 
+multi-node, multi-BMC system through the ipmi device 
+driver interface.  Default is 0.
 .TP 
 \fB\-v\fR
 Increase verbose output level.  This option may be specified
diff -Naur ipmitool-1.8.8.90.orig/include/ipmitool/ipmi_intf.h ipmitool-1.8.8.90/include/ipmitool/ipmi_intf.h
--- ipmitool-1.8.8.90.orig/include/ipmitool/ipmi_intf.h	2006-09-12 16:23:28.000000000 -0700
+++ ipmitool-1.8.8.90/include/ipmitool/ipmi_intf.h	2007-02-01 14:14:15.000000000 -0800
@@ -174,6 +174,8 @@
 	uint8_t target_lun;
 	uint8_t target_channel;
 
+	uint8_t devnum;
+
 	int (*setup)(struct ipmi_intf * intf);
 	int (*open)(struct ipmi_intf * intf);
 	void (*close)(struct ipmi_intf * intf);
diff -Naur ipmitool-1.8.8.90.orig/lib/ipmi_main.c ipmitool-1.8.8.90/lib/ipmi_main.c
--- ipmitool-1.8.8.90.orig/lib/ipmi_main.c	2006-09-12 16:23:28.000000000 -0700
+++ ipmitool-1.8.8.90/lib/ipmi_main.c	2007-02-01 14:14:15.000000000 -0800
@@ -71,9 +71,9 @@
 #endif
 
 #ifdef ENABLE_ALL_OPTIONS
-# define OPTION_STRING	"I:hVvcgsEao:H:P:f:U:p:C:L:A:t:m:S:l:b:e:k:O:"
+# define OPTION_STRING	"I:hVvcgsEao:H:d:P:f:U:p:C:L:A:t:m:S:l:b:e:k:O:"
 #else
-# define OPTION_STRING	"I:hVvcH:f:U:p:S:"
+# define OPTION_STRING	"I:hVvcH:f:U:p:d:S:"
 #endif
 
 extern int verbose;
@@ -216,6 +216,7 @@
 	lprintf(LOG_NOTICE, "       -V             Show version information");
 	lprintf(LOG_NOTICE, "       -v             Verbose (can use multiple times)");
 	lprintf(LOG_NOTICE, "       -c             Display output in comma separated format");
+	lprintf(LOG_NOTICE, "       -d N           Specify a /dev/ipmiN device to use (default=0)");
 	lprintf(LOG_NOTICE, "       -I intf        Interface to use");
 	lprintf(LOG_NOTICE, "       -H hostname    Remote host name for LAN interface");
 	lprintf(LOG_NOTICE, "       -p port        Remote RMCP port [default=623]");
@@ -283,6 +284,7 @@
 	char * kgkey    = NULL;
 	char * seloem   = NULL;
 	int port = 0;
+	int devnum = 0;
 	int cipher_suite_id = 3; /* See table 22-19 of the IPMIv2 spec */
 	int argflag, i, found;
 	int rc = -1;
@@ -325,6 +327,9 @@
 			rc = 0;
 			goto out_free;
 			break;
+		case 'd':
+			devnum = atoi(optarg);
+			break;
 		case 'p':
 			port = atoi(optarg);
 			break;
@@ -582,6 +587,8 @@
 	/* setup destination channel if given */
 	intf->target_channel = target_channel ;
 
+	intf->devnum = devnum;
+
 	/* setup IPMB local and target address if given */
 	intf->my_addr = my_addr ? : IPMI_BMC_SLAVE_ADDR;
 	if (target_addr > 0) {
diff -Naur ipmitool-1.8.8.90.orig/src/ipmievd.c ipmitool-1.8.8.90/src/ipmievd.c
--- ipmitool-1.8.8.90.orig/src/ipmievd.c	2006-09-14 09:20:59.000000000 -0700
+++ ipmitool-1.8.8.90/src/ipmievd.c	2007-02-01 15:06:14.000000000 -0800
@@ -624,7 +624,8 @@
 	struct sigaction act;
 
 	memset(pidfile, 0, 64);
-	strncpy(pidfile, DEFAULT_PIDFILE, strlen(DEFAULT_PIDFILE));
+	sprintf(pidfile, "%s%d", DEFAULT_PIDFILE, eintf->intf->devnum);
+	lprintf(LOG_NOTICE, "ipmievd: using pidfile %s", pidfile);
 
 	for (i = 0; i < argc; i++) {
 		if (strncasecmp(argv[i], "help", 4) == 0) {
diff -Naur ipmitool-1.8.8.90.orig/src/plugins/open/open.c ipmitool-1.8.8.90/src/plugins/open/open.c
--- ipmitool-1.8.8.90.orig/src/plugins/open/open.c	2006-09-14 09:20:59.000000000 -0700
+++ ipmitool-1.8.8.90/src/plugins/open/open.c	2007-02-01 14:14:15.000000000 -0800
@@ -63,10 +63,6 @@
 
 extern int verbose;
 
-#define IPMI_OPENIPMI_DEV	"/dev/ipmi0"
-#define IPMI_OPENIPMI_DEVFS	"/dev/ipmi/0"
-#define IPMI_OPENIPMI_DEVFS2	"/dev/ipmidev/0"
-
 static int
 ipmi_openipmi_open(struct ipmi_intf * intf)
 {
@@ -76,17 +72,28 @@
 	struct ipmi_rs *rsp;
 	char msg_data;
 #endif
+	char ipmi_dev[16];
+	char ipmi_devfs[16];
+	char ipmi_devfs2[16];
+	int devnum = 0;
+
+	devnum = intf->devnum;
+
+	sprintf(ipmi_dev, "/dev/ipmi%d", devnum);
+	sprintf(ipmi_devfs, "/dev/ipmi/%d", devnum);
+	sprintf(ipmi_devfs2, "/dev/ipmidev/%d", devnum);
+	lprintf(LOG_DEBUG, "Using ipmi device %d", devnum);
 
-	intf->fd = open(IPMI_OPENIPMI_DEV, O_RDWR);
+	intf->fd = open(ipmi_dev, O_RDWR);
 
 	if (intf->fd < 0) {
-		intf->fd = open(IPMI_OPENIPMI_DEVFS, O_RDWR);
+		intf->fd = open(ipmi_devfs, O_RDWR);
 		if (intf->fd < 0) {
-			intf->fd = open(IPMI_OPENIPMI_DEVFS2, O_RDWR);
+			intf->fd = open(ipmi_devfs2, O_RDWR);
 		}
 		if (intf->fd < 0) {
 			lperror(LOG_ERR, "Could not open device at %s or %s or %s",
-			IPMI_OPENIPMI_DEV, IPMI_OPENIPMI_DEVFS , IPMI_OPENIPMI_DEVFS2);
+			ipmi_dev, ipmi_devfs , ipmi_devfs2);
 			return -1;
 		}
 	}
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Ipmitool-devel mailing list
Ipmitool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel

Reply via email to