[ofa-general] [PATCH] Fix bug with "-S" option which prevented some formated GUIDs from being found.

Ira Weiny weiny2 at llnl.gov
Thu Feb 28 15:10:04 PST 2008


We have found that some tools and log files print guids without leading 0's
(eg 0x8f10400411f56 vs 0x0008f10400411f56)

The perl script "-S" option were failing without leading 0's.  This patch
formats the guids properly before performing lookups.

Ira

>From f1ab294d12569f81913c3c169ecefb003c11f714 Mon Sep 17 00:00:00 2001
From: Ira K. Weiny <weiny2 at llnl.gov>
Date: Thu, 28 Feb 2008 15:03:23 -0800
Subject: [PATCH] Fix bug with "-S" option which prevented some formated GUIDs from being found.


Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
---
 infiniband-diags/scripts/IBswcountlimits.pm |   17 ++++++++++++++++-
 infiniband-diags/scripts/iblinkinfo.pl      |    8 +++++---
 infiniband-diags/scripts/ibqueryerrors.pl   |    4 +++-
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/infiniband-diags/scripts/IBswcountlimits.pm b/infiniband-diags/scripts/IBswcountlimits.pm
index bddc421..3fd1efa 100755
--- a/infiniband-diags/scripts/IBswcountlimits.pm
+++ b/infiniband-diags/scripts/IBswcountlimits.pm
@@ -431,6 +431,21 @@ sub get_num_ports
 }
 
 # =========================================================================
+# format_switch_guid(guid)
+# The diags store the switch guids as strings.  This converts the guid supplied
+# to the correct string format.
+# eg: 0x0008f10400411f56 and 0x8f10400411f56 Should be equal but the strings
+# are not.
+#
+sub format_switch_guid
+{
+	my $guid     = $_[0];
+	my $guid_str = "";
+	sprintf($guid_str, "0x%0X", $guid);
+	return ($guid_str);
+}
+
+# =========================================================================
 # convert_dr_to_guid(direct_route)
 #
 sub convert_dr_to_guid
@@ -442,7 +457,7 @@ sub convert_dr_to_guid
 	foreach my $line (@lines) {
 		if ($line =~ /^PortGuid:\.+(.*)/) { $guid = $1; }
 	}
-	return $guid;
+	return format_switch_guid($guid);
 }
 
 # =========================================================================
diff --git a/infiniband-diags/scripts/iblinkinfo.pl b/infiniband-diags/scripts/iblinkinfo.pl
index 195c8cf..93152d5 100755
--- a/infiniband-diags/scripts/iblinkinfo.pl
+++ b/infiniband-diags/scripts/iblinkinfo.pl
@@ -80,9 +80,11 @@ chomp $argv0;
 
 if (!getopts("hcpldRS:D:C:P:g")) { usage_and_exit $argv0; }
 if (defined $Getopt::Std::opt_h) { usage_and_exit $argv0; }
-if (defined $Getopt::Std::opt_D) { $direct_route       = $Getopt::Std::opt_D; }
-if (defined $Getopt::Std::opt_R) { $regenerate_map     = $Getopt::Std::opt_R; }
-if (defined $Getopt::Std::opt_S) { $single_switch      = $Getopt::Std::opt_S; }
+if (defined $Getopt::Std::opt_D) { $direct_route   = $Getopt::Std::opt_D; }
+if (defined $Getopt::Std::opt_R) { $regenerate_map = $Getopt::Std::opt_R; }
+if (defined $Getopt::Std::opt_S) {
+	$single_switch = format_switch_guid($Getopt::Std::opt_S);
+}
 if (defined $Getopt::Std::opt_d) { $only_down_links    = $Getopt::Std::opt_d; }
 if (defined $Getopt::Std::opt_l) { $line_mode          = $Getopt::Std::opt_l; }
 if (defined $Getopt::Std::opt_p) { $print_add_switch   = $Getopt::Std::opt_p; }
diff --git a/infiniband-diags/scripts/ibqueryerrors.pl b/infiniband-diags/scripts/ibqueryerrors.pl
index ef61e9b..249fba3 100755
--- a/infiniband-diags/scripts/ibqueryerrors.pl
+++ b/infiniband-diags/scripts/ibqueryerrors.pl
@@ -171,7 +171,9 @@ if (defined $Getopt::Std::opt_c) {
 if (defined $Getopt::Std::opt_r) { $report_port_info = $Getopt::Std::opt_r; }
 if (defined $Getopt::Std::opt_R) { $regenerate_map   = $Getopt::Std::opt_R; }
 if (defined $Getopt::Std::opt_D) { $direct_route     = $Getopt::Std::opt_D; }
-if (defined $Getopt::Std::opt_S) { $single_switch    = $Getopt::Std::opt_S; }
+if (defined $Getopt::Std::opt_S) {
+	$single_switch = format_switch_guid($Getopt::Std::opt_S);
+}
 if (defined $Getopt::Std::opt_d) {
 	$include_data_counters = $Getopt::Std::opt_d;
 }
-- 
1.5.1



More information about the general mailing list