[ofa-general] [PATCH] OpenSM/console: Support loopback in -console option

Hal Rosenstock hrosenstock at xsigo.com
Tue Sep 11 11:03:58 PDT 2007


OpenSM/(osm_console main).c: Support loopback option to -console for
local only telnet support

Note: Patch is based on OFED 1.2

Signed-off-by: Hal Rosenstock <hal at xsigo.com> 

diff --git a/osm/man/opensm.8 b/osm/man/opensm.8
index 38b49c1..5da53b5 100644
--- a/osm/man/opensm.8
+++ b/osm/man/opensm.8
@@ -1,11 +1,11 @@
-.TH OPENSM 8 "May 15, 2007" "OpenIB" "OpenIB Management"
+.TH OPENSM 8 "August 8, 2007" "OpenIB" "OpenIB Management"
 
 .SH NAME
 opensm \- InfiniBand subnet manager and administration (SM/SA) 
 
 .SH SYNOPSIS
 .B opensm
-[\-c(ache-options)] [\-g(uid)[=]<GUID in hex>] [\-l(mc) <LMC>] [\-p(riority) <PRIORITY>] [\-smkey <SM_Key>] [\-r(eassign_lids)] [\-R <engine name> | \-routing_engine <engine name>] [\-M <file name> | \-lid_matrix_file <file name>] [\-U <file name> | \-ucast_file <file name>] [\-S | \-\-sadb_file <file name>] [\-a(dd_guid_file) <path to file>] [\-o(nce)] [\-s(weep) <interval>] [\-t(imeout) <milliseconds>] [\-maxsmps <number>] [\-console [off | local | socket]] [\-console-port <port>] [\-i(gnore-guids) <equalize-ignore-guids-file>] [\-f | \-\-log_file] [\-L | \-\-log_limit <size in MB>] [\-e(rase_log_file)] [\-P(config)] [\-Q | \-qos] [\-N | \-no_part_enforce] [\-y | \-stay_on_fatal] [\-v(erbose)] [\-V] [\-D <flags>] [\-d(ebug) <number>] [\-h(elp)] [\-?]
+[\-c(ache-options)] [\-g(uid)[=]<GUID in hex>] [\-l(mc) <LMC>] [\-p(riority) <PRIORITY>] [\-smkey <SM_Key>] [\-r(eassign_lids)] [\-R <engine name> | \-routing_engine <engine name>] [\-M <file name> | \-lid_matrix_file <file name>] [\-U <file name> | \-ucast_file <file name>] [\-S | \-\-sadb_file <file name>] [\-a(dd_guid_file) <path to file>] [\-o(nce)] [\-s(weep) <interval>] [\-t(imeout) <milliseconds>] [\-maxsmps <number>] [\-console [off | local | socket | loopback]] [\-console-port <port>] [\-i(gnore-guids) <equalize-ignore-guids-file>] [\-f | \-\-log_file] [\-L | \-\-log_limit <size in MB>] [\-e(rase_log_file)] [\-P(config)] [\-Q | \-qos] [\-N | \-no_part_enforce] [\-y | \-stay_on_fatal] [\-v(erbose)] [\-V] [\-D <flags>] [\-d(ebug) <number>] [\-h(elp)] [\-?]
 
 .SH DESCRIPTION
 .PP
@@ -132,10 +132,10 @@ SMPs.
 Without -maxsmps, OpenSM defaults to a maximum of
 4 outstanding SMPs.
 .TP
-\fB\-console [off | local | socket]\fR
+\fB\-console [off | local | socket | loopback]\fR
 This option brings up the OpenSM console (default off).
-Note that the socket option will only be available if OpenSM
---enable-console-socket.
+Note that the socket and loopback options will only be available
+if OpenSM was built with --enable-console-socket.
 .TP
 \fB\-console-port\fR <port>
 Specify an alternate telnet port for the socket console (default 10000).
diff --git a/osm/opensm/main.c b/osm/opensm/main.c
index e38ea7f..7cbca74 100644
--- a/osm/opensm/main.c
+++ b/osm/opensm/main.c
@@ -214,7 +214,7 @@ show_usage(void)
           "          4 outstanding SMPs.\n\n" );
   printf( "-console [off|local"
 #ifdef ENABLE_OSM_CONSOLE_SOCKET
-          "|socket"
+          "|socket|loopback"
 #endif
           "]\n          This option activates the OpenSM console (default off).\n\n");
 #ifdef ENABLE_OSM_CONSOLE_SOCKET
@@ -676,17 +676,17 @@ main(
       /*
        * OpenSM interactive console
        */
-      if (strcmp(optarg, "off") == 0) {
-      	opt.console = "off";
-      } else if (strcmp(optarg, "local") == 0) {
-      	opt.console = "local";
+      if (strcmp(optarg, "off") == 0 ||
+          strcmp(optarg, "local") == 0
 #ifdef ENABLE_OSM_CONSOLE_SOCKET
-      } else if (strcmp(optarg, "socket") == 0) {
-      	opt.console = "socket";
+                                       ||
+          strcmp(optarg, "socket") == 0 ||
+          strcmp(optarg, "loopback") == 0
 #endif
-      } else {
+                                         )
+        opt.console = optarg;
+      else
 	printf("-console %s option not understood\n", optarg);
-      }
       break;
 
 #ifdef ENABLE_OSM_CONSOLE_SOCKET
@@ -957,7 +957,8 @@ main(
         osm_console(&osm);
 #ifdef ENABLE_OSM_CONSOLE_SOCKET
       }
-      else if (strcmp(opt.console, "socket") == 0)
+      else if (strcmp(opt.console, "socket") == 0 ||
+	       strcmp(opt.console, "loopback") == 0)
       {
         osm_console(&osm);
 #endif
diff --git a/osm/opensm/osm_console.c b/osm/opensm/osm_console.c
index 38b978a..5575425 100644
--- a/osm/opensm/osm_console.c
+++ b/osm/opensm/osm_console.c
@@ -520,7 +520,8 @@ void osm_console_init(osm_subn_opt_t *opt, osm_opensm_t *p_osm)
 
 		osm_console_prompt(p_osm->console.out);
 #ifdef ENABLE_OSM_CONSOLE_SOCKET
-    	} else if (strcmp(opt->console, "socket") == 0) {
+    	} else if (strcmp(opt->console, "socket") == 0 ||
+		   strcmp(opt->console, "loopback") == 0) {
 		struct sockaddr_in  sin;
 		int optval = 1;
 
@@ -534,7 +535,10 @@ void osm_console_init(osm_subn_opt_t *opt, osm_opensm_t *p_osm)
 		setsockopt(p_osm->console.socket, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval));
 		sin.sin_family = AF_INET;
 		sin.sin_port = htons(opt->console_port);
-		sin.sin_addr.s_addr = htonl(INADDR_ANY);
+		if (strcmp(opt->console, "socket") == 0)
+			sin.sin_addr.s_addr = htonl(INADDR_ANY);
+		else
+			sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
 		if (bind(p_osm->console.socket, &sin, sizeof(sin)) < 0)
 		{
 			osm_log(&(p_osm->log), OSM_LOG_ERROR,





More information about the general mailing list