[ofa-general] [PATCH] infiniband-diags/scripts/iblinkinfo.pl: fix printing of switch name when port 1 is down.

Ira Weiny weiny2 at llnl.gov
Thu May 1 15:50:45 PDT 2008


I found a bug in the printing of the names of switches on iblinkinfo.pl.  The
name of the switch was being pulled from the first ports "link" structure.  The
problem is, if the first port is down there was no structure available.  This
gets the switch name from the first link structure available and prints the
name correctly.

Ira

>From 9b69c0ff4c7785be78157ab78e4a4892d64e2fb2 Mon Sep 17 00:00:00 2001
From: Ira K. Weiny <weiny2 at llnl.gov>
Date: Thu, 1 May 2008 15:46:25 -0700
Subject: [PATCH] infiniband-diags/scripts/iblinkinfo.pl: fix printing of switch name when port 1
is down.

Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
---
 infiniband-diags/scripts/iblinkinfo.pl |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/infiniband-diags/scripts/iblinkinfo.pl b/infiniband-diags/scripts/iblinkinfo.pl
index 890567c..6077ded 100755
--- a/infiniband-diags/scripts/iblinkinfo.pl
+++ b/infiniband-diags/scripts/iblinkinfo.pl
@@ -139,11 +139,23 @@ sub main
 		foreach my $port (1 .. $num_ports) {
 			my $hr = $IBswcountlimits::link_ends{$switch}{$port};
 			if ($switch_prompt eq "no" && !$line_mode) {
+			   	my $switch_name = "";
+				my $tmp_port = $port;
+				while ($switch_name eq "" && $tmp_port <= $num_ports) {
+					# the first port is down find switch name with up port
+					my $hr = $IBswcountlimits::link_ends{$switch}{$tmp_port};
+			   		$switch_name = $hr->{loc_desc};
+					$tmp_port++;
+				}
+				if ($switch_name eq "") {
+					printf(
+						"WARNING: Switch Name not found for $switch\n");
+				}
 				push(
 					@output_lines,
 					sprintf(
 						"Switch %18s %s%s:\n",
-						$switch, $hr->{loc_desc}, $pkt_life_prompt
+						$switch, $switch_name, $pkt_life_prompt
 					)
 				);
 				$switch_prompt = "yes";
-- 
1.5.1




More information about the general mailing list