[ofa-general] Re: [PATCH] Fix bug which prevented some GUIDs from being found due to formating issues.
Ira Weiny
weiny2 at llnl.gov
Mon Mar 3 10:58:33 PST 2008
On Sat, 1 Mar 2008 02:04:41 +0000
Sasha Khapyorsky <sashak at voltaire.com> wrote:
> Hi Ira,
>
> On 11:25 Fri 29 Feb , Ira Weiny wrote:
> >
> > # =========================================================================
> > +# format_guid(guid)
> > +# The diags store the guids as strings. This converts the guid supplied
> > +# to the correct string format.
> > +# eg: 0x0008f10400411f56 == 0x8f10400411f56
> > +#
> > +sub format_guid
> > +{
> > + my $guid = hex $_[0];
> > + my $guid_str = "";
> > + $guid_str = sprintf("0x%016x", $guid);
> > + return ($guid_str);
> > +}
>
> And now I have this on 32-bit machine:
>
> $ iblinkinfo.pl -S 0x8f10400410bc0
> Integer overflow in hexadecimal number at /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/IBswcountlimits.pm line 441.
Frell! Ok, some research on the web indicates that there might be issues with
how perl is compiled and if it can handle 64-bit integers on a 32-bit machine.
I think it would work with bigint but here is an attempt without using ints.
Ira
>From 8bc9c94ae20fffcd4eff5d557ce6efb4ef1f7d38 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 which prevented some GUIDs from being found due to formating issues.
Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
---
infiniband-diags/scripts/IBswcountlimits.pm | 22 +++++++++++++++++++++-
infiniband-diags/scripts/ibfindnodesusing.pl | 2 +-
infiniband-diags/scripts/iblinkinfo.pl | 8 +++++---
infiniband-diags/scripts/ibprintca.pl | 2 +-
infiniband-diags/scripts/ibprintrt.pl | 2 +-
infiniband-diags/scripts/ibprintswitch.pl | 2 +-
infiniband-diags/scripts/ibqueryerrors.pl | 4 +++-
7 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/infiniband-diags/scripts/IBswcountlimits.pm b/infiniband-diags/scripts/IBswcountlimits.pm
index bddc421..9bc356f 100755
--- a/infiniband-diags/scripts/IBswcountlimits.pm
+++ b/infiniband-diags/scripts/IBswcountlimits.pm
@@ -431,6 +431,26 @@ sub get_num_ports
}
# =========================================================================
+# format_guid(guid)
+# The diags store the guids as strings. This converts the guid supplied
+# to the correct string format.
+# eg: 0x0008f10400411f56 == 0x8f10400411f56
+#
+sub format_guid
+{
+ my $guid = $_[0];
+ my $guid_str = "";
+
+ $guid =~ tr/[A-F]/[a-f]/;
+ if ($guid =~ /0x(.*)/) {
+ $guid_str = sprintf("0x%016s", $1);
+ } else {
+ $guid_str = sprintf("0x%016s", $guid);
+ }
+ return ($guid_str);
+}
+
+# =========================================================================
# convert_dr_to_guid(direct_route)
#
sub convert_dr_to_guid
@@ -442,7 +462,7 @@ sub convert_dr_to_guid
foreach my $line (@lines) {
if ($line =~ /^PortGuid:\.+(.*)/) { $guid = $1; }
}
- return $guid;
+ return format_guid($guid);
}
# =========================================================================
diff --git a/infiniband-diags/scripts/ibfindnodesusing.pl b/infiniband-diags/scripts/ibfindnodesusing.pl
index 2521255..1bf0987 100755
--- a/infiniband-diags/scripts/ibfindnodesusing.pl
+++ b/infiniband-diags/scripts/ibfindnodesusing.pl
@@ -92,7 +92,7 @@ if (defined $Getopt::Std::opt_R) { $regenerate_map = $Getopt::Std::opt_R; }
if (defined $Getopt::Std::opt_C) { $ca_name = $Getopt::Std::opt_C; }
if (defined $Getopt::Std::opt_P) { $ca_port = $Getopt::Std::opt_P; }
-my $target_switch = $ARGV[0];
+my $target_switch = format_guid($ARGV[0]);
my $target_port = $ARGV[1];
get_link_ends($regenerate_map, $ca_name, $ca_port);
diff --git a/infiniband-diags/scripts/iblinkinfo.pl b/infiniband-diags/scripts/iblinkinfo.pl
index 195c8cf..b2c90a1 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_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/ibprintca.pl b/infiniband-diags/scripts/ibprintca.pl
index 0c6ca0e..38b4330 100755
--- a/infiniband-diags/scripts/ibprintca.pl
+++ b/infiniband-diags/scripts/ibprintca.pl
@@ -67,7 +67,7 @@ if (defined $Getopt::Std::opt_l) { $list_hcas = $Getopt::Std::opt_l; }
if (defined $Getopt::Std::opt_C) { $ca_name = $Getopt::Std::opt_C; }
if (defined $Getopt::Std::opt_P) { $ca_port = $Getopt::Std::opt_P; }
-my $target_hca = $ARGV[0];
+my $target_hca = format_guid($ARGV[0]);
my $cache_file = get_cache_file($ca_name, $ca_port);
diff --git a/infiniband-diags/scripts/ibprintrt.pl b/infiniband-diags/scripts/ibprintrt.pl
index 2918dc6..86dcb64 100755
--- a/infiniband-diags/scripts/ibprintrt.pl
+++ b/infiniband-diags/scripts/ibprintrt.pl
@@ -67,7 +67,7 @@ if (defined $Getopt::Std::opt_l) { $list_rts = $Getopt::Std::opt_l; }
if (defined $Getopt::Std::opt_C) { $ca_name = $Getopt::Std::opt_C; }
if (defined $Getopt::Std::opt_P) { $ca_port = $Getopt::Std::opt_P; }
-my $target_rt = $ARGV[0];
+my $target_rt = format_guid($ARGV[0]);
my $cache_file = get_cache_file($ca_name, $ca_port);
diff --git a/infiniband-diags/scripts/ibprintswitch.pl b/infiniband-diags/scripts/ibprintswitch.pl
index b7f78f3..6712201 100755
--- a/infiniband-diags/scripts/ibprintswitch.pl
+++ b/infiniband-diags/scripts/ibprintswitch.pl
@@ -66,7 +66,7 @@ if (defined $Getopt::Std::opt_l) { $list_switches = $Getopt::Std::opt_l; }
if (defined $Getopt::Std::opt_C) { $ca_name = $Getopt::Std::opt_C; }
if (defined $Getopt::Std::opt_P) { $ca_port = $Getopt::Std::opt_P; }
-my $target_switch = $ARGV[0];
+my $target_switch = format_guid($ARGV[0]);
my $cache_file = get_cache_file($ca_name, $ca_port);
diff --git a/infiniband-diags/scripts/ibqueryerrors.pl b/infiniband-diags/scripts/ibqueryerrors.pl
index ef61e9b..200a40c 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_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