Hi Ira,

On 09:58 Tue 04 Nov     , Ira Weiny wrote:
> From 0db0d6667ed8baede1093a95127e2ce9c81959bd Mon Sep 17 00:00:00 2001
> From: Ira Weiny <[EMAIL PROTECTED]>
> 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 <[EMAIL PROTECTED]>
> ---
>  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);

The problem IMHO that this changes the current interface and will
require to change all plugins (not just rebuild - actually rebuild will
hide any interface changing issues and will not fail).

What about the check like this:


diff --git a/opensm/opensm/osm_event_plugin.c b/opensm/opensm/osm_event_plugin.c
index c6999f5..f332a24 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,17 @@ osm_epi_plugin_t *osm_epi_construct(osm_opensm_t *osm, char 
*plugin_name)
                goto Exit;
        }
 
+       /* be sure that not old interface plugin is used */
+       old_impl = (struct old_if *) rc->impl;
+       if (old_impl->ver < OSM_EVENT_PLUGIN_INTERFACE_VER) {
+               OSM_LOG(&osm->log, OSM_LOG_ERROR, "Error loading plugin"
+                       "\'%s\': it has the wrong interface version (%u); "
+                       "OpenSM expected %u. Please rebuild.\n",
+                       plugin_name, old_impl->ver,
+                       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"

Sasha
_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to