[ofa-general] [PATCH] infiniband-diags/scripts: Handle new and old topology file format

davem at systemfabricworks.com davem at systemfabricworks.com
Fri Jul 20 08:09:50 PDT 2007



   Fix infiniband-diags scripts to handle changed ibnetdiscover topology file
   format and remain backward compatible with old file format.

Signed-off-by: David A. McMillen <davem at systemfabricworks.com>
---
 infiniband-diags/scripts/ibcheckerrors.in      |    4 +++-
 infiniband-diags/scripts/ibchecknet.in         |    4 +++-
 infiniband-diags/scripts/ibcheckstate.in       |    4 +++-
 infiniband-diags/scripts/ibcheckwidth.in       |    4 +++-
 infiniband-diags/scripts/ibclearcounters.in    |    4 +++-
 infiniband-diags/scripts/ibclearerrors.in      |    4 +++-
 infiniband-diags/scripts/ibdatacounters.in     |    4 +++-
 7 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/infiniband-diags/scripts/ibcheckerrors.in b/infiniband-diags/scripts/ibcheckerrors.in
index 8a6c012..e08eba3 100644
--- a/infiniband-diags/scripts/ibcheckerrors.in
+++ b/infiniband-diags/scripts/ibcheckerrors.in
@@ -91,13 +91,15 @@ function check_node(lid)
 		nports++
 		port = $1
 		if (!nodechecked) {
-			lid = $5
+			lid = substr($0, index($0, " lid ") + 5)
+			lid = substr(lid, 1, index(lid, " ") - 1)
 			check_node(lid)
 		}
 		if (badnode) {
 			print "\n# " ntype ": nodeguid 0x" nodeguid " failed"
 			next
 		}
+		sub("\\(.*\\)", "", port)
 		gsub("[\\[\\]]", "", port)
 		if (nodeerr)
 			if (system("'$IBPATH'/ibcheckerrs '$gflags' '$verbose' '$brief' " lid " " port)) {
diff --git a/infiniband-diags/scripts/ibchecknet.in b/infiniband-diags/scripts/ibchecknet.in
index 3154d9e..9f36742 100644
--- a/infiniband-diags/scripts/ibchecknet.in
+++ b/infiniband-diags/scripts/ibchecknet.in
@@ -84,13 +84,15 @@ function check_node(lid)
 		nports++
 		port = $1
 		if (!nodechecked) {
-			lid = $5
+			lid = substr($0, index($0, " lid ") + 5)
+			lid = substr(lid, 1, index(lid, " ") - 1)
 			check_node(lid)
 		}
 		if (badnode) {
 			print "\n# " ntype ": nodeguid 0x" nodeguid " failed"
 			next
 		}
+		sub("\\(.*\\)", "", port)
 		gsub("[\\[\\]]", "", port)
 		if (system("'$IBPATH'/ibcheckport '$gflags' '$verbose' " lid " " port)) {
 			if (!'$v' && oldlid != lid) {
diff --git a/infiniband-diags/scripts/ibcheckstate.in b/infiniband-diags/scripts/ibcheckstate.in
index 9268670..30b5513 100644
--- a/infiniband-diags/scripts/ibcheckstate.in
+++ b/infiniband-diags/scripts/ibcheckstate.in
@@ -83,13 +83,15 @@ function check_node(lid)
 		nports++
 		port = $1
 		if (!nodechecked) {
-			lid = $5
+			lid = substr($0, index($0, " lid ") + 5)
+			lid = substr(lid, 1, index(lid, " ") - 1)
 			check_node(lid)
 		}
 		if (badnode) {
 			print "\n# " ntype ": nodeguid 0x" nodeguid " failed"
 			next
 		}
+		sub("\\(.*\\)", "", port)
 		gsub("[\\[\\]]", "", port)
 		if (system("'$IBPATH'/ibcheckportstate '$gflags' '$verbose' " lid " " port)) {
 			if (!'$v' && oldlid != lid) {
diff --git a/infiniband-diags/scripts/ibcheckwidth.in b/infiniband-diags/scripts/ibcheckwidth.in
index 7a8e7e0..072d433 100644
--- a/infiniband-diags/scripts/ibcheckwidth.in
+++ b/infiniband-diags/scripts/ibcheckwidth.in
@@ -83,13 +83,15 @@ function check_node(lid)
 		nports++
 		port = $1
 		if (!nodechecked) {
-			lid = $5
+			lid = substr($0, index($0, " lid ") + 5)
+			lid = substr(lid, 1, index(lid, " ") - 1)
 			check_node(lid)
 		}
 		if (badnode) {
 			print "\n# " ntype ": nodeguid 0x" nodeguid " failed"
 			next
 		}
+		sub("\\(.*\\)", "", port)
 		gsub("[\\[\\]]", "", port)
 		if (system("'$IBPATH'/ibcheckportwidth '$gflags' '$verbose' " lid " " port)) {
 			if (!'$v' && oldlid != lid) {
diff --git a/infiniband-diags/scripts/ibclearcounters.in b/infiniband-diags/scripts/ibclearcounters.in
index fa6ab83..54551b3 100644
--- a/infiniband-diags/scripts/ibclearcounters.in
+++ b/infiniband-diags/scripts/ibclearcounters.in
@@ -73,9 +73,11 @@ function clear_port_counters(lid, port)
 
 /^\[/   {
 			port = $1
+			sub("\\(.*\\)", "", port)
 			gsub("[\\[\\]]", "", port)
 			if (!nodecleared) {
-				lid = $5
+				lid = substr($0, index($0, " lid ") + 5)
+				lid = substr(lid, 1, index(lid, " ") - 1)
 				clear_port_counters(lid, port)
 			}
 		}
diff --git a/infiniband-diags/scripts/ibclearerrors.in b/infiniband-diags/scripts/ibclearerrors.in
index bce8f83..4a086ae 100644
--- a/infiniband-diags/scripts/ibclearerrors.in
+++ b/infiniband-diags/scripts/ibclearerrors.in
@@ -66,9 +66,11 @@ function clear_errors(lid, port)
 
 /^\[/   {
 			port = $1
+			sub("\\(.*\\)", "", port)
 			gsub("[\\[\\]]", "", port)
 			if (!nodecleared) {
-				lid = $5
+				lid = substr($0, index($0, " lid ") + 5)
+				lid = substr(lid, 1, index(lid, " ") - 1)
 				clear_errors(lid, port)
 			}
 		}
diff --git a/infiniband-diags/scripts/ibdatacounters.in b/infiniband-diags/scripts/ibdatacounters.in
index ce8c71a..d27149e 100644
--- a/infiniband-diags/scripts/ibdatacounters.in
+++ b/infiniband-diags/scripts/ibdatacounters.in
@@ -91,13 +91,15 @@ function check_node(lid)
 		nports++
 		port = $1
 		if (!nodechecked) {
-			lid = $5
+			lid = substr($0, index($0, " lid ") + 5)
+			lid = substr(lid, 1, index(lid, " ") - 1)
 			check_node(lid)
 		}
 		if (badnode) {
 			print "\n# " ntype ": nodeguid 0x" nodeguid " failed"
 			next
 		}
+		sub("\\(.*\\)", "", port)
 		gsub("[\\[\\]]", "", port)
 		if (nodeerr)
 			if (system("'$IBPATH'/ibdatacounts'$gflags' '$verbose' '$brief' " lid " " port)) {



More information about the general mailing list