Commit 4b8203d7 authored by Andrew Jeffery's avatar Andrew Jeffery

mboxd: Don't require mbox

With the DBus interface to the daemon in place it's possible to
implement any hardware interface in terms of the DBus interface. This is
the strategy used to support the IPMI HIOMAP transport. Further, the use
of MBOX is deprecated due to security concerns. We want to drop the
driver from the kernel, which failed to get traction upstream, so make
support optional.

As a consequence, switch the default transport to DBus.

Change-Id: I9f16ca053ce48943dce59b83ca991ec5494580d8
Signed-off-by: Andrew Jeffery's avatarAndrew Jeffery <andrew@aj.id.au>
parent fac3689e
......@@ -391,6 +391,7 @@ int main(int argc, char **argv)
{
const struct transport_ops *mbox_ops, *dbus_ops;
struct mbox_context *context;
bool have_transport_mbox;
char *name = argv[0];
sigset_t set;
int rc, i;
......@@ -429,8 +430,13 @@ int main(int argc, char **argv)
}
rc = transport_mbox_init(context, &mbox_ops);
if (rc) {
goto cleanup_protocol;
/* TODO: Think about whether we could use a less branch-y strategy */
have_transport_mbox = rc == 0;
if (!have_transport_mbox) {
/* Disable MBOX for poll()ing purposes */
context->fds[MBOX_FD].fd = -1;
MSG_DBG("Failed to initialise MBOX transport: %d\n", rc);
MSG_INFO("MBOX transport unavailable\n");
}
rc = lpc_dev_init(context);
......@@ -456,10 +462,12 @@ int main(int argc, char **argv)
context->bmc_events |= BMC_EVENT_DAEMON_READY;
context->bmc_events |= BMC_EVENT_PROTOCOL_RESET;
/* Alert on all supported transports */
rc = protocol_events_put(context, mbox_ops);
if (rc) {
goto cleanup;
/* Alert on all supported transports, as required */
if (have_transport_mbox) {
rc = protocol_events_put(context, mbox_ops);
if (rc) {
goto cleanup;
}
}
rc = protocol_events_put(context, dbus_ops);
......@@ -476,8 +484,11 @@ int main(int argc, char **argv)
context->bmc_events &= ~BMC_EVENT_DAEMON_READY;
context->bmc_events |= BMC_EVENT_PROTOCOL_RESET;
/* Alert on all supported transports */
protocol_events_put(context, mbox_ops);
/* Alert on all supported transports, as required */
if (have_transport_mbox) {
protocol_events_put(context, mbox_ops);
}
protocol_events_put(context, dbus_ops);
cleanup:
......@@ -487,8 +498,9 @@ cleanup_windows:
cleanup_lpc:
lpc_dev_free(context);
cleanup_mbox:
transport_mbox_free(context);
cleanup_protocol:
if (have_transport_mbox) {
transport_mbox_free(context);
}
protocol_free(context);
cleanup_backend:
backend_free(&context->backend);
......
......@@ -211,11 +211,13 @@ void cleanup(void)
tmpf_destroy(&test.lpc);
}
int __transport_mbox_init(struct mbox_context *context, const char *path);
int __transport_mbox_init(struct mbox_context *context, const char *path,
const struct transport_ops **ops);
int __lpc_dev_init(struct mbox_context *context, const char *path);
struct mbox_context *mbox_create_frontend_context(int n_windows, size_t len)
{
const struct transport_ops *ops;
struct mtd_info_user mtd_info;
int rc;
......@@ -242,7 +244,8 @@ struct mbox_context *mbox_create_frontend_context(int n_windows, size_t len)
* /dev/null and replace it with our own fd for mbox device emulation
* by the test framework.
*/
__transport_mbox_init(&test.context, "/dev/null");
__transport_mbox_init(&test.context, "/dev/null", &ops);
test.context.transport = ops;
rc = close(test.context.fds[MBOX_FD].fd);
assert(rc == 0);
test.context.fds[MBOX_FD].fd = test.mbox.fd;
......
......@@ -526,6 +526,8 @@ int transport_dbus_init(struct mbox_context *context,
return rc;
}
context->transport = &transport_dbus_ops;
if (ops) {
*ops = &transport_dbus_ops;
}
......
......@@ -646,16 +646,15 @@ int transport_mbox_dispatch(struct mbox_context *context)
return handle_mbox_req(context, &req);
}
int __transport_mbox_init(struct mbox_context *context, const char *path)
int __transport_mbox_init(struct mbox_context *context, const char *path,
const struct transport_ops **ops)
{
int fd;
context->transport = &transport_mbox_ops;
/* Open MBOX Device */
fd = open(path, O_RDWR | O_NONBLOCK);
if (fd < 0) {
MSG_ERR("Couldn't open %s with flags O_RDWR: %s\n",
MSG_INFO("Couldn't open %s with flags O_RDWR: %s\n",
path, strerror(errno));
return -errno;
}
......@@ -663,6 +662,10 @@ int __transport_mbox_init(struct mbox_context *context, const char *path)
context->fds[MBOX_FD].fd = fd;
if (ops) {
*ops = &transport_mbox_ops;
}
return 0;
}
......@@ -671,14 +674,10 @@ int transport_mbox_init(struct mbox_context *context,
{
int rc;
rc = __transport_mbox_init(context, MBOX_HOST_PATH);
rc = __transport_mbox_init(context, MBOX_HOST_PATH, ops);
if (rc)
return rc;
if (ops) {
*ops = &transport_mbox_ops;
}
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment