[ofa-general] [PATCH 3/7] Move nodenamemap out of infiniband-diags into libosmcomp

Ira Weiny weiny2 at llnl.gov
Thu Nov 1 20:15:08 PDT 2007


>From fe2756789ffbc69466eefea3cdffe200a0718561 Mon Sep 17 00:00:00 2001
From: Ira K. Weiny <weiny2 at llnl.gov>
Date: Thu, 1 Nov 2007 15:00:37 -0700
Subject: [PATCH] Move nodenamemap out of infiniband-diags into libosmcomp

Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
---
 infiniband-diags/Makefile.am             |    3 +
 infiniband-diags/configure.in            |   26 ------
 infiniband-diags/include/ibdiag_common.h |   13 ---
 infiniband-diags/src/ibdiag_common.c     |   81 -------------------
 infiniband-diags/src/ibnetdiscover.c     |    1 +
 infiniband-diags/src/ibtracert.c         |    1 +
 infiniband-diags/src/saquery.c           |    1 +
 infiniband-diags/src/smpquery.c          |    1 +
 opensm/complib/Makefile.am               |    7 +-
 opensm/complib/cl_nodenamemap.c          |  128 ++++++++++++++++++++++++++++++
 opensm/complib/libosmcomp.map            |    4 +
 opensm/configure.in                      |   26 ++++++
 opensm/include/Makefile.am               |    1 +
 opensm/include/complib/cl_nodenamemap.h  |   54 +++++++++++++
 14 files changed, 225 insertions(+), 122 deletions(-)
 create mode 100644 opensm/complib/cl_nodenamemap.c
 create mode 100644 opensm/include/complib/cl_nodenamemap.h

diff --git a/infiniband-diags/Makefile.am b/infiniband-diags/Makefile.am
index 7dcfa5a..edff06c 100644
--- a/infiniband-diags/Makefile.am
+++ b/infiniband-diags/Makefile.am
@@ -32,6 +32,7 @@ src_ibaddr_CFLAGS = -Wall $(DBGFLAGS)
 
 src_ibnetdiscover_SOURCES = src/ibnetdiscover.c src/grouping.c src/ibdiag_common.c
 src_ibnetdiscover_CFLAGS = -Wall $(DBGFLAGS)
+src_ibnetdiscover_LDFLAGS = -Wl,--rpath -Wl,$(libdir)
 
 src_ibping_SOURCES = src/ibping.c src/ibdiag_common.c
 src_ibping_CFLAGS = -Wall $(DBGFLAGS)
@@ -50,6 +51,7 @@ src_ibsysstat_CFLAGS = -Wall $(DBGFLAGS)
 
 src_ibtracert_SOURCES = src/ibtracert.c src/ibdiag_common.c
 src_ibtracert_CFLAGS = -Wall $(DBGFLAGS)
+src_ibtracert_LDFLAGS = -Wl,--rpath -Wl,$(libdir)
 
 src_perfquery_SOURCES = src/perfquery.c src/ibdiag_common.c
 src_perfquery_CFLAGS = -Wall $(DBGFLAGS)
@@ -62,6 +64,7 @@ src_smpdump_CFLAGS = -Wall $(DBGFLAGS)
 
 src_smpquery_SOURCES = src/smpquery.c src/ibdiag_common.c
 src_smpquery_CFLAGS = -Wall $(DBGFLAGS)
+src_smpquery_LDFLAGS = -Wl,--rpath -Wl,$(libdir)
 
 src_saquery_SOURCES = src/saquery.c src/ibdiag_common.c
 src_saquery_CFLAGS = -Wall -DOSM_VENDOR_INTF_OPENIB -DVENDOR_RMPP_SUPPORT -DDUAL_SIDED_RMPP $(DBGFLAGS)
diff --git a/infiniband-diags/configure.in b/infiniband-diags/configure.in
index 0a5f3c8..a24d478 100644
--- a/infiniband-diags/configure.in
+++ b/infiniband-diags/configure.in
@@ -72,32 +72,6 @@ AC_CHECK_FUNCS([strchr strrchr strtol strtoul memset])
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 
-dnl Check for the specification of a default node name map file
-AC_MSG_CHECKING(for --with-node-name-map )
-AC_ARG_WITH(node-name-map,
-    AC_HELP_STRING([--with-node-name-map=file],
-                   [define a default node name map file]),
-    [ case "$withval" in
-    no)
-        ;;
-    *)
-        withnodenamemap=yes
-        NODENAMEMAPFILE=$withval
-        ;;
-    esac ]
-)
-AC_MSG_RESULT(${withnodenamemap=no})
-
-if test $withnodenamemap = "yes"; then
-   NODENAMEMAP_TMP1="`eval echo ${sysconfdir}/$NODENAMEMAPFILE`"
-   NODENAMEMAP_TMP2="`echo $NODENAMEMAP_TMP1 | sed 's/^NONE/$ac_default_prefix/'`"
-   NODENAMEMAP="`eval echo $NODENAMEMAP_TMP2`"
-
-   AC_DEFINE_UNQUOTED(HAVE_DEFAULT_NODENAME_MAP,
-	         ["$NODENAMEMAP"],
-	         [Define a default node name map file])
-fi
-
 dnl Check for perl and perl install location
 AC_MSG_CHECKING(for --with-perl-path )
 AC_ARG_WITH(perl-path,
diff --git a/infiniband-diags/include/ibdiag_common.h b/infiniband-diags/include/ibdiag_common.h
index 55df3fe..029d80e 100644
--- a/infiniband-diags/include/ibdiag_common.h
+++ b/infiniband-diags/include/ibdiag_common.h
@@ -45,16 +45,6 @@ extern int   ibdebug;
 /*                External interface                      */
 /*========================================================*/
 
-/**
- * Node name map interface.
- * It is OK to pass NULL for the node_name_map[_fp] parameters.
- */
-FILE *open_node_name_map(char *node_name_map);
-void  close_node_name_map(FILE *node_name_map_fp);
-char *remap_node_name(FILE *node_name_map_fp, uint64_t target_guid,
-			char *nodedesc);
-	/* NOTE: parameter "nodedesc" may be modified here. */
-
 #undef DEBUG
 #define	DEBUG	if (ibdebug || verbose) IBWARN
 #define	VERBOSE	if (ibdebug || verbose > 1) IBWARN
@@ -62,9 +52,6 @@ char *remap_node_name(FILE *node_name_map_fp, uint64_t target_guid,
 
 void  iberror(const char *fn, char *msg, ...);
 
-/* NOTE: this modifies the parameter "nodedesc". */
-char *clean_nodedesc(char *nodedesc);
-
 #ifdef __BUILD_VERSION_TAG__
 
 #define stringify(s) to_string(s)
diff --git a/infiniband-diags/src/ibdiag_common.c b/infiniband-diags/src/ibdiag_common.c
index c152853..2d573b9 100644
--- a/infiniband-diags/src/ibdiag_common.c
+++ b/infiniband-diags/src/ibdiag_common.c
@@ -51,73 +51,6 @@
 
 int ibdebug;
 
-FILE *
-open_node_name_map(char *node_name_map)
-{
-	FILE *rc = NULL;
-
-	if (node_name_map != NULL) {
-		rc = fopen(node_name_map, "r");
-		if (rc == NULL) {
-			fprintf(stderr,
-				"WARNING failed to open switch map \"%s\" (%s)\n",
-				node_name_map, strerror(errno));
-		}
-#ifdef HAVE_DEFAULT_NODENAME_MAP
-	} else {
-		rc = fopen(HAVE_DEFAULT_NODENAME_MAP, "r");
-#endif /* HAVE_DEFAULT_NODENAME_MAP */
-	}
-	return (rc);
-}
-
-void
-close_node_name_map(FILE *fp)
-{
-	if (fp)
-		fclose(fp);
-}
-
-char *
-remap_node_name(FILE *node_name_map_fp, uint64_t target_guid, char *nodedesc)
-{
-#define NAME_LEN (256)
-	char     *line = NULL;
-	size_t    len = 0;
-	uint64_t  guid = 0;
-	char     *rc = NULL;
-	int       line_count = 0;
-
-	if (node_name_map_fp == NULL)
-		goto done;
-
-	rewind(node_name_map_fp);
-	for (line_count = 1;
-		getline(&line, &len, node_name_map_fp) != -1;
-		line_count++) {
-		line[len-1] = '\0';
-		if (line[0] == '#')
-			goto next_one;
-		char *guid_str = strtok(line, "\"#");
-		char *name = strtok(NULL, "\"#");
-		if (!guid_str || !name)
-			goto next_one;
-		guid = strtoull(guid_str, NULL, 0);
-		if (target_guid == guid) {
-			rc = strdup(name);
-			free (line);
-			goto done;
-		}
-next_one:
-		free (line);
-		line = NULL;
-	}
-done:
-	if (rc == NULL)
-		rc = strdup(clean_nodedesc(nodedesc));
-	return (rc);
-}
-
 void
 iberror(const char *fn, char *msg, ...)
 {
@@ -141,17 +74,3 @@ iberror(const char *fn, char *msg, ...)
 	exit(-1);
 }
 
-char *
-clean_nodedesc(char *nodedesc)
-{
-	int i = 0;
-
-	nodedesc[63] = '\0';
-	while (nodedesc[i]) {
-		if (!isprint(nodedesc[i]))
-			nodedesc[i] = ' ';
-		i++;
-	}
-
-	return (nodedesc);
-}
diff --git a/infiniband-diags/src/ibnetdiscover.c b/infiniband-diags/src/ibnetdiscover.c
index 5594b1c..03ef6f9 100644
--- a/infiniband-diags/src/ibnetdiscover.c
+++ b/infiniband-diags/src/ibnetdiscover.c
@@ -51,6 +51,7 @@
 #include <infiniband/common.h>
 #include <infiniband/umad.h>
 #include <infiniband/mad.h>
+#include <infiniband/complib/cl_nodenamemap.h>
 
 #include "ibnetdiscover.h"
 #include "grouping.h"
diff --git a/infiniband-diags/src/ibtracert.c b/infiniband-diags/src/ibtracert.c
index 2e04f2f..c8a7b19 100644
--- a/infiniband-diags/src/ibtracert.c
+++ b/infiniband-diags/src/ibtracert.c
@@ -50,6 +50,7 @@
 #include <infiniband/common.h>
 #include <infiniband/umad.h>
 #include <infiniband/mad.h>
+#include <infiniband/complib/cl_nodenamemap.h>
 
 #include "ibdiag_common.h"
 
diff --git a/infiniband-diags/src/saquery.c b/infiniband-diags/src/saquery.c
index 7dcd5fb..a8d810f 100644
--- a/infiniband-diags/src/saquery.c
+++ b/infiniband-diags/src/saquery.c
@@ -54,6 +54,7 @@
 #include <infiniband/vendor/osm_vendor_sa_api.h>
 #include <infiniband/opensm/osm_mad_pool.h>
 #include <infiniband/complib/cl_debug.h>
+#include <infiniband/complib/cl_nodenamemap.h>
 
 #include "ibdiag_common.h"
 
diff --git a/infiniband-diags/src/smpquery.c b/infiniband-diags/src/smpquery.c
index 60212f5..7c2c129 100644
--- a/infiniband-diags/src/smpquery.c
+++ b/infiniband-diags/src/smpquery.c
@@ -51,6 +51,7 @@
 #include <infiniband/common.h>
 #include <infiniband/umad.h>
 #include <infiniband/mad.h>
+#include <infiniband/complib/cl_nodenamemap.h>
 
 #include "ibdiag_common.h"
 
diff --git a/opensm/complib/Makefile.am b/opensm/complib/Makefile.am
index 2967c87..3ef5357 100644
--- a/opensm/complib/Makefile.am
+++ b/opensm/complib/Makefile.am
@@ -26,7 +26,9 @@ libosmcomp_la_SOURCES = cl_complib.c cl_dispatcher.c \
 			cl_spinlock.c cl_statustext.c \
 			cl_thread.c cl_threadpool.c \
 			cl_timer.c cl_vector.c \
-			ib_statustext.c
+			ib_statustext.c \
+			cl_nodenamemap.c
+
 libosmcomp_la_LDFLAGS = -version-info $(complib_api_version) \
 	 -export-dynamic $(libosmcomp_version_script)
 libosmcomp_la_DEPENDENCIES = $(srcdir)/libosmcomp.map
@@ -73,7 +75,8 @@ libosmcompinclude_HEADERS = $(srcdir)/../include/complib/cl_atomic.h \
 	$(srcdir)/../include/complib/cl_timer_osd.h \
 	$(srcdir)/../include/complib/cl_types.h \
 	$(srcdir)/../include/complib/cl_types_osd.h \
-	$(srcdir)/../include/complib/cl_vector.h
+	$(srcdir)/../include/complib/cl_vector.h \
+	$(srcdir)/../include/complib/cl_nodenamemap.h
 
 # headers are distributed as part of the include dir
 EXTRA_DIST = $(srcdir)/libosmcomp.map $(srcdir)/libosmcomp.ver
diff --git a/opensm/complib/cl_nodenamemap.c b/opensm/complib/cl_nodenamemap.c
new file mode 100644
index 0000000..144a7e4
--- /dev/null
+++ b/opensm/complib/cl_nodenamemap.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2007 Lawrence Livermore National Lab
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <config.h>
+
+#include <complib/cl_nodenamemap.h>
+
+FILE *
+open_node_name_map(char *node_name_map)
+{
+	FILE *rc = NULL;
+
+	if (node_name_map != NULL) {
+		rc = fopen(node_name_map, "r");
+		if (rc == NULL) {
+			fprintf(stderr,
+				"WARNING failed to open switch map \"%s\" (%s)\n",
+				node_name_map, strerror(errno));
+		}
+#ifdef HAVE_DEFAULT_NODENAME_MAP
+	} else {
+		rc = fopen(HAVE_DEFAULT_NODENAME_MAP, "r");
+#endif /* HAVE_DEFAULT_NODENAME_MAP */
+	}
+	return (rc);
+}
+
+void
+close_node_name_map(FILE *fp)
+{
+	if (fp)
+		fclose(fp);
+}
+
+char *
+remap_node_name(FILE *node_name_map_fp, uint64_t target_guid, char *nodedesc)
+{
+#define NAME_LEN (256)
+	char     *line = NULL;
+	size_t    len = 0;
+	uint64_t  guid = 0;
+	char     *rc = NULL;
+	int       line_count = 0;
+
+	if (node_name_map_fp == NULL)
+		goto done;
+
+	rewind(node_name_map_fp);
+	for (line_count = 1;
+		getline(&line, &len, node_name_map_fp) != -1;
+		line_count++) {
+		line[len-1] = '\0';
+		if (line[0] == '#')
+			goto next_one;
+		char *guid_str = strtok(line, "\"#");
+		char *name = strtok(NULL, "\"#");
+		if (!guid_str || !name)
+			goto next_one;
+		guid = strtoull(guid_str, NULL, 0);
+		if (target_guid == guid) {
+			rc = strdup(name);
+			free (line);
+			goto done;
+		}
+next_one:
+		free (line);
+		line = NULL;
+	}
+done:
+	if (rc == NULL)
+		rc = strdup(clean_nodedesc(nodedesc));
+	return (rc);
+}
+
+char *
+clean_nodedesc(char *nodedesc)
+{
+	int i = 0;
+
+	nodedesc[63] = '\0';
+	while (nodedesc[i]) {
+		if (!isprint(nodedesc[i]))
+			nodedesc[i] = ' ';
+		i++;
+	}
+
+	return (nodedesc);
+}
+
diff --git a/opensm/complib/libosmcomp.map b/opensm/complib/libosmcomp.map
index cb2505b..7ee845d 100644
--- a/opensm/complib/libosmcomp.map
+++ b/opensm/complib/libosmcomp.map
@@ -151,5 +151,9 @@ OSMCOMP_2.3 {
 		ib_error_str;
 		ib_async_event_str;
 		ib_wc_status_str;
+		open_node_name_map;
+		close_node_name_map;
+		remap_node_name;
+		clean_nodedesc;
 	local: *;
 };
diff --git a/opensm/configure.in b/opensm/configure.in
index d120c05..b596004 100644
--- a/opensm/configure.in
+++ b/opensm/configure.in
@@ -70,6 +70,32 @@ OPENIB_OSM_CONSOLE_SOCKET_SEL
 dnl select performance manager or not
 OPENIB_OSM_PERF_MGR_SEL
 
+dnl Check for the specification of a default node name map file
+AC_MSG_CHECKING(for --with-node-name-map )
+AC_ARG_WITH(node-name-map,
+    AC_HELP_STRING([--with-node-name-map=file],
+                   [define a default node name map file]),
+    [ case "$withval" in
+    no)
+        ;;
+    *)
+        withnodenamemap=yes
+        NODENAMEMAPFILE=$withval
+        ;;
+    esac ]
+)
+AC_MSG_RESULT(${withnodenamemap=no})
+
+if test $withnodenamemap = "yes"; then
+   NODENAMEMAP_TMP1="`eval echo ${sysconfdir}/$NODENAMEMAPFILE`"
+   NODENAMEMAP_TMP2="`echo $NODENAMEMAP_TMP1 | sed 's/^NONE/$ac_default_prefix/'`"
+   NODENAMEMAP="`eval echo $NODENAMEMAP_TMP2`"
+
+   AC_DEFINE_UNQUOTED(HAVE_DEFAULT_NODENAME_MAP,
+	         ["$NODENAMEMAP"],
+	         [Define a default node name map file])
+fi
+
 dnl select example event plugin or not
 OPENIB_OSM_DEFAULT_EVENT_PLUGIN_SEL
 
diff --git a/opensm/include/Makefile.am b/opensm/include/Makefile.am
index b2d01fa..34f82a1 100644
--- a/opensm/include/Makefile.am
+++ b/opensm/include/Makefile.am
@@ -126,6 +126,7 @@ EXTRA_DIST = \
 	$(srcdir)/complib/cl_types.h \
 	$(srcdir)/complib/cl_fleximap.h \
 	$(srcdir)/complib/cl_qcomppool.h \
+	$(srcdir)/complib/cl_nodenamemap.h \
 	$(srcdir)/iba/ib_types.h \
 	$(srcdir)/iba/ib_cm_types.h \
 	$(srcdir)/vendor/osm_vendor_mlx_transport_anafa.h \
diff --git a/opensm/include/complib/cl_nodenamemap.h b/opensm/include/complib/cl_nodenamemap.h
new file mode 100644
index 0000000..a4a09f7
--- /dev/null
+++ b/opensm/include/complib/cl_nodenamemap.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2007 Lawrence Livermore National Lab
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _CL_NODE_NAME_MAP_H_
+#define _CL_NODE_NAME_MAP_H_
+
+#include <stdio.h>
+#include <stdint.h>
+
+/* NOTE: this modifies the parameter "nodedesc". */
+char *clean_nodedesc(char *nodedesc);
+
+/**
+ * Node name map interface.
+ * It is OK to pass NULL for the node_name_map[_fp] parameters.
+ */
+FILE *open_node_name_map(char *node_name_map);
+void  close_node_name_map(FILE *node_name_map_fp);
+char *remap_node_name(FILE *node_name_map_fp, uint64_t target_guid,
+			char *nodedesc);
+	/* NOTE: parameter "nodedesc" may be modified here. */
+
+#endif				/* _CL_NODE_NAME_MAP_H_ */
+
-- 
1.5.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Move-nodenamemap-out-of-infiniband-diags-into-libosm.patch
Type: application/octet-stream
Size: 17098 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20071101/ad0783c1/attachment.obj>


More information about the general mailing list