[ofa-general] Re: [PATCH V2] Add check for previous versions of plugins.

Ira Weiny weiny2 at llnl.gov
Fri Nov 14 14:28:48 PST 2008


I believe this will work.  I incorporated your patch but I made this explicit
so it will hopefully be clear what is going on.

Ira


>From 061822466a157bb425600ee0b63cc80ff038d615 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         |   11 +++++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/opensm/include/opensm/osm_event_plugin.h b/opensm/include/opensm/osm_event_plugin.h
index b2deeba..0922c65 100644
--- a/opensm/include/opensm/osm_event_plugin.h
+++ b/opensm/include/opensm/osm_event_plugin.h
@@ -148,6 +148,7 @@ typedef struct osm_epi_trap_event {
  * The version should be set to OSM_EVENT_PLUGIN_INTERFACE_VER
  */
 #define OSM_EVENT_PLUGIN_IMPL_NAME "osm_event_plugin"
+#define OSM_ORIG_EVENT_PLUGIN_INTERFACE_VER 1
 #define OSM_EVENT_PLUGIN_INTERFACE_VER 2
 typedef struct osm_event_plugin {
 	const char *osm_version;
diff --git a/opensm/opensm/osm_event_plugin.c b/opensm/opensm/osm_event_plugin.c
index c6999f5..b0dc549 100644
--- a/opensm/opensm/osm_event_plugin.c
+++ b/opensm/opensm/osm_event_plugin.c
@@ -66,6 +66,7 @@
 osm_epi_plugin_t *osm_epi_construct(osm_opensm_t *osm, char *plugin_name)
 {
 	char lib_name[OSM_PATH_MAX];
+	struct old_if { unsigned ver; } *old_impl;
 	osm_epi_plugin_t *rc = NULL;
 
 	if (!plugin_name || !*plugin_name)
@@ -96,6 +97,16 @@ osm_epi_plugin_t *osm_epi_construct(osm_opensm_t *osm, char *plugin_name)
 		goto Exit;
 	}
 
+	/* check for old interface */
+	old_impl = (struct old_if *) rc->impl;
+	if (old_impl->ver == OSM_ORIG_EVENT_PLUGIN_INTERFACE_VER) {
+		OSM_LOG(&osm->log, OSM_LOG_ERROR, "Error loading plugin: "
+			"\'%s\' contains a depricated interface version %d\n"
+			"   Please recompile with the new interface.\n",
+			plugin_name, old_impl->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