[ofa-general] [PATCH] Add check for previous versions of plugins.
Ira Weiny
weiny2 at llnl.gov
Tue Nov 4 09:58:12 PST 2008
>From 0db0d6667ed8baede1093a95127e2ce9c81959bd Mon Sep 17 00:00:00 2001
From: Ira Weiny <weiny2 at llnl.gov>
Date: Mon, 3 Nov 2008 15:50:15 -0800
Subject: [PATCH] Add check for previous versions of plugins.
If old interface plugins are available to OpenSM they will cause a crash.
Check for this old version and error out gracefully.
Signed-off-by: Ira Weiny <weiny2 at llnl.gov>
---
opensm/include/opensm/osm_event_plugin.h | 1 +
opensm/opensm/osm_event_plugin.c | 10 ++++++++++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/opensm/include/opensm/osm_event_plugin.h b/opensm/include/opensm/osm_event_plugin.h
index b2deeba..0b80b63 100644
--- a/opensm/include/opensm/osm_event_plugin.h
+++ b/opensm/include/opensm/osm_event_plugin.h
@@ -150,6 +150,7 @@ typedef struct osm_epi_trap_event {
#define OSM_EVENT_PLUGIN_IMPL_NAME "osm_event_plugin"
#define OSM_EVENT_PLUGIN_INTERFACE_VER 2
typedef struct osm_event_plugin {
+ int interface_version;
const char *osm_version;
void *(*create) (struct osm_opensm *osm);
void (*delete) (void *plugin_data);
diff --git a/opensm/opensm/osm_event_plugin.c b/opensm/opensm/osm_event_plugin.c
index c6999f5..86cabf0 100644
--- a/opensm/opensm/osm_event_plugin.c
+++ b/opensm/opensm/osm_event_plugin.c
@@ -96,6 +96,16 @@ osm_epi_plugin_t *osm_epi_construct(osm_opensm_t *osm, char *plugin_name)
goto Exit;
}
+ /* check for new interface */
+ if (rc->impl->interface_version < OSM_EVENT_PLUGIN_INTERFACE_VER) {
+ OSM_LOG(&osm->log, OSM_LOG_ERROR, "Error loading plugin"
+ "\'%s\': is the wrong interface version (%d); "
+ "OpenSM expected %d\n",
+ plugin_name, rc->impl->interface_version,
+ OSM_EVENT_PLUGIN_INTERFACE_VER);
+ goto Exit;
+ }
+
/* Check the version to make sure this module will work with us */
if (strcmp(rc->impl->osm_version, osm->osm_version)) {
OSM_LOG(&osm->log, OSM_LOG_ERROR, "Error loading plugin"
--
1.5.4.5
More information about the general
mailing list