[ofa-general] [PATCH v2] opensm: fixing handling of opt.max_wire_smps

Yevgeny Kliteynik kliteyn at dev.mellanox.co.il
Wed Aug 5 04:20:53 PDT 2009


Hi Sasha,

V2 of this patch:

opt.max_wire_smps is uint32, but then when it's propagated
into the VL15 poller it's casted to int32. Fixing the
parameter handling to protect it from wrong values.

Signed-off-by: Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>
---
 opensm/opensm/main.c       |    5 +++--
 opensm/opensm/osm_subnet.c |   12 ++++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/opensm/opensm/main.c b/opensm/opensm/main.c
index 296d5d5..ca20ff9 100644
--- a/opensm/opensm/main.c
+++ b/opensm/opensm/main.c
@@ -721,8 +721,9 @@ int main(int argc, char *argv[])
 			break;

 		case 'n':
-			opt.max_wire_smps = strtol(optarg, NULL, 0);
-			if (opt.max_wire_smps <= 0)
+			opt.max_wire_smps = strtoul(optarg, NULL, 0);
+			if (opt.max_wire_smps == 0 ||
+			    opt.max_wire_smps > 0x7FFFFFFF)
 				opt.max_wire_smps = 0x7FFFFFFF;
 			printf(" Max wire smp's = %d\n", opt.max_wire_smps);
 			break;
diff --git a/opensm/opensm/osm_subnet.c b/opensm/opensm/osm_subnet.c
index ec15f8a..c43bef7 100644
--- a/opensm/opensm/osm_subnet.c
+++ b/opensm/opensm/osm_subnet.c
@@ -1066,6 +1066,18 @@ int osm_subn_verify_config(IN osm_subn_opt_t * const p_opts)
 		p_opts->force_link_speed = IB_PORT_LINK_SPEED_ENABLED_MASK;
 	}

+	if (p_opts->max_wire_smps == 0) {
+		log_report(" Invalid Cached Option Value: max_wire_smps = 0,"
+			   " Using unlimited: 0x7FFFFFFF\n");
+		p_opts->max_wire_smps = 0x7FFFFFFF;
+	}
+	else if (p_opts->max_wire_smps > 0x7FFFFFFF) {
+		log_report(" Invalid Cached Option Value: max_wire_smps = %u,"
+			   " Using Default: %u\n",
+			   p_opts->max_wire_smps, OSM_DEFAULT_SMP_MAX_ON_WIRE);
+		p_opts->max_wire_smps = OSM_DEFAULT_SMP_MAX_ON_WIRE;
+	}
+
 	if (strcmp(p_opts->console, OSM_DISABLE_CONSOLE)
 	    && strcmp(p_opts->console, OSM_LOCAL_CONSOLE)
 #ifdef ENABLE_OSM_CONSOLE_SOCKET
-- 
1.5.1.4




More information about the general mailing list