All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH phosphor-host-ipmid 0/4] dbus interface fixes
@ 2015-10-27 13:13 OpenBMC Patches
  2015-10-27 13:13 ` [PATCH phosphor-host-ipmid 1/4] Remove executable permissions in source files OpenBMC Patches
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: OpenBMC Patches @ 2015-10-27 13:13 UTC (permalink / raw)
  To: openbmc; +Cc: OpenBMC Patches

With these changes, I can get ipmid talking to our dbus-enabled ipmitool.

https://github.com/openbmc/phosphor-host-ipmid/pull/23

Jeremy Kerr (4):
  Remove executable permissions in source files
  ipmid: Remove assumptions about host IPMI sender objects
  ipmid: Use updated dbus HostIpmi interface
  ipmid: Fix crash on scandir failure

 Makefile     |  0
 apphandler.C |  0
 ipmid-api.h  | 20 ++++++++++----------
 ipmid.C      | 30 ++++++++++++++++--------------
 ipmid.H      |  0
 5 files changed, 26 insertions(+), 24 deletions(-)
 mode change 100755 => 100644 Makefile
 mode change 100755 => 100644 apphandler.C
 mode change 100755 => 100644 ipmid-api.h
 mode change 100755 => 100644 ipmid.H

-- 
2.6.0

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH phosphor-host-ipmid 1/4] Remove executable permissions in source files
  2015-10-27 13:13 [PATCH phosphor-host-ipmid 0/4] dbus interface fixes OpenBMC Patches
@ 2015-10-27 13:13 ` OpenBMC Patches
  2015-10-27 13:13 ` [PATCH phosphor-host-ipmid 2/4] ipmid: Remove assumptions about host IPMI sender objects OpenBMC Patches
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: OpenBMC Patches @ 2015-10-27 13:13 UTC (permalink / raw)
  To: openbmc

From: Jeremy Kerr <jk@ozlabs.org>

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
---
 Makefile     | 0
 apphandler.C | 0
 ipmid-api.h  | 0
 ipmid.H      | 0
 4 files changed, 0 insertions(+), 0 deletions(-)
 mode change 100755 => 100644 Makefile
 mode change 100755 => 100644 apphandler.C
 mode change 100755 => 100644 ipmid-api.h
 mode change 100755 => 100644 ipmid.H

diff --git a/Makefile b/Makefile
old mode 100755
new mode 100644
diff --git a/apphandler.C b/apphandler.C
old mode 100755
new mode 100644
diff --git a/ipmid-api.h b/ipmid-api.h
old mode 100755
new mode 100644
diff --git a/ipmid.H b/ipmid.H
old mode 100755
new mode 100644
-- 
2.6.0

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH phosphor-host-ipmid 2/4] ipmid: Remove assumptions about host IPMI sender objects
  2015-10-27 13:13 [PATCH phosphor-host-ipmid 0/4] dbus interface fixes OpenBMC Patches
  2015-10-27 13:13 ` [PATCH phosphor-host-ipmid 1/4] Remove executable permissions in source files OpenBMC Patches
@ 2015-10-27 13:13 ` OpenBMC Patches
  2015-10-27 13:13 ` [PATCH phosphor-host-ipmid 3/4] ipmid: Use updated dbus HostIpmi interface OpenBMC Patches
  2015-10-27 13:13 ` [PATCH phosphor-host-ipmid 4/4] ipmid: Fix crash on scandir failure OpenBMC Patches
  3 siblings, 0 replies; 5+ messages in thread
From: OpenBMC Patches @ 2015-10-27 13:13 UTC (permalink / raw)
  To: openbmc

From: Jeremy Kerr <jk@ozlabs.org>

Currently, the IPMI daemon will only receive messages from a specific
(arbitrary) object path that the debug daemon used.

Instead, we should be listening to any signal that matches our interface
(org.openbmc.HostIpmi.ReceivedMessage). When replying to the message,
we should be using the signal sender info to properly address the
reply method.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
---
 ipmid.C | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/ipmid.C b/ipmid.C
index 6514849..c466984 100644
--- a/ipmid.C
+++ b/ipmid.C
@@ -16,11 +16,9 @@
 
 sd_bus *bus = NULL;
 
-// Channel that is used for OpenBMC Barreleye
-const char * DBUS_NAME = "org.openbmc.HostIpmi";
-const char * OBJ_NAME = "/org/openbmc/HostIpmi/1";
+const char * DBUS_INTF = "org.openbmc.HostIpmi";
 
-const char * FILTER = "type='signal',sender='org.openbmc.HostIpmi',member='ReceivedMessage'";
+const char * FILTER = "type='signal',interface='org.openbmc.HostIpmi',member='ReceivedMessage'";
 
 
 typedef std::pair<ipmi_netfn_t, ipmi_cmd_t> ipmi_fn_cmd_t;
@@ -165,17 +163,17 @@ ipmi_ret_t ipmi_netfn_router(ipmi_netfn_t netfn, ipmi_cmd_t cmd, ipmi_request_t
 
 
 
-static int send_ipmi_message(unsigned char seq, unsigned char netfn, unsigned char cmd, unsigned char *buf, unsigned char len) {
+static int send_ipmi_message(sd_bus_message *req, unsigned char seq, unsigned char netfn, unsigned char cmd, unsigned char *buf, unsigned char len) {
 
     sd_bus_error error = SD_BUS_ERROR_NULL;
     sd_bus_message *reply = NULL, *m=NULL;
-
-
-    const char *path;
+    const char *dest, *path;
     int r, pty;
 
+    dest = sd_bus_message_get_sender(req);
+    path = sd_bus_message_get_path(req);
 
-    r = sd_bus_message_new_method_call(bus,&m,DBUS_NAME,OBJ_NAME,DBUS_NAME,"sendMessage");
+    r = sd_bus_message_new_method_call(bus,&m,dest,path,DBUS_INTF,"sendMessage");
     if (r < 0) {
         fprintf(stderr, "Failed to add the method object: %s\n", strerror(-r));
         return -1;
@@ -275,7 +273,7 @@ static int handle_ipmi_command(sd_bus_message *m, void *user_data, sd_bus_error
     hexdump((void*)response, resplen);
 
     // Send the response buffer from the ipmi command
-    r = send_ipmi_message(sequence, netfn, cmd, response, resplen);
+    r = send_ipmi_message(m, sequence, netfn, cmd, response, resplen);
     if (r < 0) {
         fprintf(stderr, "Failed to send the response message\n");
         return -1;
-- 
2.6.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH phosphor-host-ipmid 3/4] ipmid: Use updated dbus HostIpmi interface
  2015-10-27 13:13 [PATCH phosphor-host-ipmid 0/4] dbus interface fixes OpenBMC Patches
  2015-10-27 13:13 ` [PATCH phosphor-host-ipmid 1/4] Remove executable permissions in source files OpenBMC Patches
  2015-10-27 13:13 ` [PATCH phosphor-host-ipmid 2/4] ipmid: Remove assumptions about host IPMI sender objects OpenBMC Patches
@ 2015-10-27 13:13 ` OpenBMC Patches
  2015-10-27 13:13 ` [PATCH phosphor-host-ipmid 4/4] ipmid: Fix crash on scandir failure OpenBMC Patches
  3 siblings, 0 replies; 5+ messages in thread
From: OpenBMC Patches @ 2015-10-27 13:13 UTC (permalink / raw)
  To: openbmc

From: Jeremy Kerr <jk@ozlabs.org>

With the updated HostIpmi dbus interface, netfns are not packed with
LUNs, and the CC is separate from the data.  This means we no longer
have to define NETFN_* as arbitrarily shifted, and we have the added
bonus of replying to messages where lun != 0.

We may want to separate the CC returned from the handlers in future too.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
---
 ipmid-api.h | 20 ++++++++++----------
 ipmid.C     | 13 +++++++------
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/ipmid-api.h b/ipmid-api.h
index f028e7f..6cdf126 100644
--- a/ipmid-api.h
+++ b/ipmid-api.h
@@ -62,16 +62,16 @@ extern "C" void ipmi_register_callback(ipmi_netfn_t, ipmi_cmd_t,
 // Note: these are also shifted left to make room for the LUN.
 enum ipmi_net_fns
 {
-    NETFUN_CHASSIS  =   (0x00 << 2),
-    NETFUN_BRIDGE   =   (0x02 << 2),
-    NETFUN_SENSOR   =   (0x04 << 2),
-    NETFUN_APP      =   (0x06 << 2),
-    NETFUN_FIRMWARE =   (0x08 << 2),
-    NETFUN_STORAGE  =   (0x0a << 2),
-    NETFUN_TRANPORT =   (0x0c << 2),
-    NETFUN_GRPEXT   =   (0x2c << 2),
-    NETFUN_NONE     =   (0x30 << 2),
-    NETFUN_OEM      =   (0x32 << 2)
+    NETFUN_CHASSIS  =   0x00,
+    NETFUN_BRIDGE   =   0x02,
+    NETFUN_SENSOR   =   0x04,
+    NETFUN_APP      =   0x06,
+    NETFUN_FIRMWARE =   0x08,
+    NETFUN_STORAGE  =   0x0a,
+    NETFUN_TRANPORT =   0x0c,
+    NETFUN_GRPEXT   =   0x2c,
+    NETFUN_NONE     =   0x30,
+    NETFUN_OEM      =   0x32
 };
 
 // IPMI commands for net functions. Since this is to be used both by the ipmi
diff --git a/ipmid.C b/ipmid.C
index c466984..5528641 100644
--- a/ipmid.C
+++ b/ipmid.C
@@ -163,7 +163,7 @@ ipmi_ret_t ipmi_netfn_router(ipmi_netfn_t netfn, ipmi_cmd_t cmd, ipmi_request_t
 
 
 
-static int send_ipmi_message(sd_bus_message *req, unsigned char seq, unsigned char netfn, unsigned char cmd, unsigned char *buf, unsigned char len) {
+static int send_ipmi_message(sd_bus_message *req, unsigned char seq, unsigned char netfn, unsigned char lun, unsigned char cmd, unsigned char cc, unsigned char *buf, unsigned char len) {
 
     sd_bus_error error = SD_BUS_ERROR_NULL;
     sd_bus_message *reply = NULL, *m=NULL;
@@ -181,11 +181,11 @@ static int send_ipmi_message(sd_bus_message *req, unsigned char seq, unsigned ch
 
 
     // Responses in IPMI require a bit set.  So there ya go...
-    netfn |= 0x04;
+    netfn |= 0x01;
 
 
     // Add the bytes needed for the methods to be called
-    r = sd_bus_message_append(m, "yyy", seq, netfn, cmd);
+    r = sd_bus_message_append(m, "yyyyy", seq, netfn, lun, cmd, cc);
     if (r < 0) {
         fprintf(stderr, "Failed add the netfn and others : %s\n", strerror(-r));
         return -1;
@@ -231,7 +231,7 @@ static int handle_ipmi_command(sd_bus_message *m, void *user_data, sd_bus_error
                          *ret_error) {
     int r = 0;
     const char *msg = NULL;
-    char sequence, netfn, cmd;
+    unsigned char sequence, netfn, lun, cmd;
     const void *request;
     size_t sz;
     size_t resplen =MAX_IPMI_BUFFER;
@@ -241,7 +241,7 @@ static int handle_ipmi_command(sd_bus_message *m, void *user_data, sd_bus_error
 
     memset(response, 0, MAX_IPMI_BUFFER);
 
-    r = sd_bus_message_read(m, "yyy",  &sequence, &netfn, &cmd);
+    r = sd_bus_message_read(m, "yyyy",  &sequence, &netfn, &lun, &cmd);
     if (r < 0) {
         fprintf(stderr, "Failed to parse signal message: %s\n", strerror(-r));
         return -1;
@@ -273,7 +273,8 @@ static int handle_ipmi_command(sd_bus_message *m, void *user_data, sd_bus_error
     hexdump((void*)response, resplen);
 
     // Send the response buffer from the ipmi command
-    r = send_ipmi_message(m, sequence, netfn, cmd, response, resplen);
+    r = send_ipmi_message(m, sequence, netfn, lun, cmd, response[0],
+		    ((unsigned char *)response) + 1, resplen - 1);
     if (r < 0) {
         fprintf(stderr, "Failed to send the response message\n");
         return -1;
-- 
2.6.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH phosphor-host-ipmid 4/4] ipmid: Fix crash on scandir failure
  2015-10-27 13:13 [PATCH phosphor-host-ipmid 0/4] dbus interface fixes OpenBMC Patches
                   ` (2 preceding siblings ...)
  2015-10-27 13:13 ` [PATCH phosphor-host-ipmid 3/4] ipmid: Use updated dbus HostIpmi interface OpenBMC Patches
@ 2015-10-27 13:13 ` OpenBMC Patches
  3 siblings, 0 replies; 5+ messages in thread
From: OpenBMC Patches @ 2015-10-27 13:13 UTC (permalink / raw)
  To: openbmc

From: Jeremy Kerr <jk@ozlabs.org>

Curently, if I have no ipmi_lib_path, ipmid crashes:

  $ ./ipmid
  Registering handler:[/usr/lib/host-ipmid/H��\x18dH�\x04%(]
  ERROR opening [/usr/lib/host-ipmid/H��\x18dH�\x04%(]: /usr/lib/host-ipmid/H��\x18dH�\x04%(: cannot open shared object file: No such file or directory
  *** Error in `./ipmid': munmap_chunk(): invalid pointer: 0x0000000000401eb6 ***
  Aborted (core dumped)

We need to check for the error case of a scandir().

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
---
 ipmid.C | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ipmid.C b/ipmid.C
index 5528641..11dcb61 100644
--- a/ipmid.C
+++ b/ipmid.C
@@ -341,6 +341,9 @@ void ipmi_register_callback_handlers(const char* ipmi_lib_path)
         handler_fqdn += "/";
 
         num_handlers = scandir(ipmi_lib_path, &handler_list, handler_select, alphasort);
+	if (num_handlers < 0)
+		return;
+
         while(num_handlers--)
         {
             handler_fqdn = ipmi_lib_path;
-- 
2.6.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-27 13:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-27 13:13 [PATCH phosphor-host-ipmid 0/4] dbus interface fixes OpenBMC Patches
2015-10-27 13:13 ` [PATCH phosphor-host-ipmid 1/4] Remove executable permissions in source files OpenBMC Patches
2015-10-27 13:13 ` [PATCH phosphor-host-ipmid 2/4] ipmid: Remove assumptions about host IPMI sender objects OpenBMC Patches
2015-10-27 13:13 ` [PATCH phosphor-host-ipmid 3/4] ipmid: Use updated dbus HostIpmi interface OpenBMC Patches
2015-10-27 13:13 ` [PATCH phosphor-host-ipmid 4/4] ipmid: Fix crash on scandir failure OpenBMC Patches

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.