[ofa-general] [PATCH] infiniband-diags/scripts: Add ibcheckroutes to scripts

Doron Shoham dorons at voltaire.com
Mon Sep 21 05:03:43 PDT 2009


Add ibcheckroutes script.
ibcheckroutes validates route between all leaf switches, switches or
CAs in the fabric.

Signed-off-by: Doron Shoham <dorons at voltaire.com>
---
 infiniband-diags/Makefile.am              |    4 +-
 infiniband-diags/configure.in             |    1 +
 infiniband-diags/man/ibcheckroutes.8      |   46 ++++++++++
 infiniband-diags/scripts/ibcheckroutes.in |  138 +++++++++++++++++++++++++++++
 4 files changed, 187 insertions(+), 2 deletions(-)
 create mode 100644 infiniband-diags/man/ibcheckroutes.8
 create mode 100644 infiniband-diags/scripts/ibcheckroutes.in

diff --git a/infiniband-diags/Makefile.am b/infiniband-diags/Makefile.am
index 1cdb60e..57363c4 100644
--- a/infiniband-diags/Makefile.am
+++ b/infiniband-diags/Makefile.am
@@ -33,7 +33,7 @@ sbin_SCRIPTS = scripts/ibcheckerrs scripts/ibchecknet scripts/ibchecknode \
 	       scripts/iblinkinfo.pl scripts/ibprintswitch.pl \
 	       scripts/ibprintca.pl scripts/ibprintrt.pl \
 	       scripts/ibfindnodesusing.pl scripts/ibidsverify.pl \
-	       scripts/check_lft_balance.pl
+	       scripts/check_lft_balance.pl scripts/ibcheckroutes
 
 noinst_LIBRARIES = libcommon.a
 
@@ -76,7 +76,7 @@ man_MANS = man/ibaddr.8 man/ibcheckerrors.8 man/ibcheckerrs.8 \
 	man/ibprintswitch.8 man/ibprintca.8 man/ibfindnodesusing.8 \
 	man/ibdatacounts.8 man/ibdatacounters.8 \
 	man/ibrouters.8 man/ibprintrt.8 man/ibidsverify.8 \
-	man/check_lft_balance.8
+	man/check_lft_balance.8 man/ibcheckroutes.8
 
 BUILT_SOURCES = ibdiag_version
 ibdiag_version:
diff --git a/infiniband-diags/configure.in b/infiniband-diags/configure.in
index 3ef35cc..aa178c5 100644
--- a/infiniband-diags/configure.in
+++ b/infiniband-diags/configure.in
@@ -158,6 +158,7 @@ AC_CONFIG_FILES([\
 	scripts/ibcheckportwidth \
 	scripts/ibcheckstate \
 	scripts/ibcheckwidth \
+	scripts/ibcheckroutes \
 	scripts/ibclearcounters \
 	scripts/ibclearerrors \
 	scripts/ibdatacounts \
diff --git a/infiniband-diags/man/ibcheckroutes.8 b/infiniband-diags/man/ibcheckroutes.8
new file mode 100644
index 0000000..fe6f0d6
--- /dev/null
+++ b/infiniband-diags/man/ibcheckroutes.8
@@ -0,0 +1,46 @@
+.TH IBCHECKROUTES 8 "September 10, 2009" "OpenIB" "OpenIB Diagnostics"
+
+.SH NAME
+ibcheckroutes \- validate routes between all hosts in fabric
+
+.SH SYNOPSIS
+.B ibcheckroutes
+[\-l] [\-s] [\-c] [\-n topology-file ] [\-h] [\-N] [\-b] [\-e] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms]
+
+.SH DESCRIPTION
+.PP
+ibcheckroutes is a script which can use a full topology file that was created by ibnetdiscover or
+scans the subnet. Then it validates routes between all leaf switches, switches or CAs in the fabric.
+
+.SH OPTIONS
+.PP
+\-n  Use topology-file.
+.PP
+\-l  Check routes between all leaf switches.
+.PP
+\-s  Check routes between all switches.
+.PP
+\-c  Check routes between all CAs.
+.PP
+\-h  Show help.
+.PP
+\-N  Use mono rather than color mode.
+.PP
+\-b  Suppress output.
+.PP
+\-e  Show errors only.
+.PP
+\-C <ca_name>    Use the specified ca_name.
+.PP
+\-P <ca_port>    Use the specified ca_port.
+.PP
+\-t <timeout_ms> Override the default timeout for the solicited mads.
+
+.SH SEE ALSO
+.BR ibnetdiscover(8),
+.BR ibtracert(8)
+
+.SH AUTHOR
+.TP
+Doron Shoham
+.RI < dorons at voltaire.com >
diff --git a/infiniband-diags/scripts/ibcheckroutes.in b/infiniband-diags/scripts/ibcheckroutes.in
new file mode 100644
index 0000000..c7dd191
--- /dev/null
+++ b/infiniband-diags/scripts/ibcheckroutes.in
@@ -0,0 +1,138 @@
+#!/bin/sh
+
+IBPATH=${IBPATH:- at IBSCRIPTPATH@}
+
+function usage() {
+	echo -e Usage: `basename $0` "[-l] [-s] [-c] [-h] [-N] [-b] [-e] [-n topology-file ] \
+[-C ca_name] [-P ca_port] [-t(imeout) timeout_ms]"
+	echo -e "  Validate routes between all leaf switches, switches or CAs in the fabric"
+	echo -e " -n   - Use topology-file"
+	echo -e " -l   - Check routes between all leaf switches"
+	echo -e " -s   - Check routes between all switches"
+	echo -e " -c   - Check routes between all CAs"
+	echo -e " -h   - Show help"
+	echo -e " -N   - Use mono rather than color mode"
+	echo -e " -b   - Suppress output"
+	echo -e " -e   - Show errors only"
+	echo -e " -C   - Use the specified ca_name"
+	echo -e " -P   - Use the specified ca_port"
+	echo -e " -t   - Override the default timeout for the solicited mads"
+	exit -1
+}
+
+function user_abort() {
+	echo "Aborted"
+	exit 1
+}
+
+function green() {
+	if [ "$bw" = "yes" ]; then
+		printf "${res_col}[OK]\n" $1
+		return
+	fi
+	printf "\033[1;032m${res_col}[OK]\033[0;39m\n" $1
+}
+
+function red() {
+	if [ "$bw" = "yes" ]; then
+		printf "${res_col}[FAILED]\n" "$1"
+		return
+	fi
+	printf "\033[31m${res_col}[FAILED]\033[0m\n" "$1"
+}
+
+trap user_abort SIGINT SIGTERM
+
+bw=""
+brief=0
+error=0
+ca_info=""
+st=0
+method="leaf"
+topofile=/tmp/net
+discover=1
+res_col="%-20.20s"
+
+function get_opts() {
+	while getopts P:C:t:n:beNhlsc o; do
+		case "$o" in
+		n)
+			topofile="$OPTARG"
+			discover=0
+			;;
+		l)
+			method="leaf"
+			;;
+		s)
+			method="sw"
+			;;
+		c)
+			method="ca"
+			;;
+		h)
+			usage
+			;;
+		N)
+			bw="yes"
+			;;
+		b)
+			brief=1
+			;;
+		e)
+			error=1
+			;;
+		P | C | t | timeout)
+			ca_info="$ca_info -$o $OPTARG"
+			;;
+		*)
+			usage
+			;;
+		esac
+	done
+}
+
+get_opts $*
+
+if [ $discover -eq 1 ]; then
+	$IBPATH/ibnetdiscover $ca_info > $topofile
+fi
+
+# find LIDs to check
+case $method in
+leaf)
+	[ $brief -eq 0 ] && echo -e "Checking routes between all Leaf Switches"
+	LIDS=($(awk  '/# lid /{a[$(NF-1)]=$(NF-1)} END{for(v in a) if (v!=0) print v}' $topofile))
+	;;
+sw)
+	[ $brief -eq 0 ] && echo -e "Checking routes between all Switches"
+	LIDS=($(awk '/^Switch/ {a[$(NF-2)]=$(NF-2)} END{for(v in a) if (v!=0) print v}' $topofile))
+	;;
+ca)
+	[ $brief -eq 0 ] && echo -e "Checking routes between all CAs"
+	LIDS=($(awk  '/# lid /{lmc=$7; e=2^lmc+$5; for(i=$5; i<e; i++) {if (i!=0) print i}}' $topofile))
+	;;
+esac
+
+# number of LIDs
+N=${#LIDS[@]}
+
+if [ $N -lt 2 ]; then
+	[ $brief -eq 0 ] && echo "Error: found single node"
+	exit 0
+fi
+
+# check routes
+[ $brief -eq 0 ] && echo -e "Checking route between:\nSource lid --> Destination lid"
+for((s=0; s<N-1; s++)); do
+	for ((d=s+1; d<N; d++)); do
+		$IBPATH/ibtracert $ca_info ${LIDS[$s]} ${LIDS[$d]} > /dev/null
+		if [ $? -eq 0 ]; then
+			[ $brief -eq 0 ] && [ $error -eq 0 ] && green "${LIDS[$s]}-->${LIDS[$d]}"
+		else
+			[ $brief -eq 0 ] && red "${LIDS[$s]}-->${LIDS[$d]}"
+			st=1
+		fi
+	done
+done
+
+exit $st
-- 
1.5.4




More information about the general mailing list