Home | History | Annotate | Download | only in tracepath
      1 #!/bin/sh
      2 # Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved.
      3 #
      4 # This program is free software; you can redistribute it and/or
      5 # modify it under the terms of the GNU General Public License as
      6 # published by the Free Software Foundation; either version 2 of
      7 # the License, or (at your option) any later version.
      8 #
      9 # This program is distributed in the hope that it would be useful,
     10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12 # GNU General Public License for more details.
     13 #
     14 # You should have received a copy of the GNU General Public License
     15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
     16 #
     17 # Author: Alexey Kodanev <alexey.kodanev (at] oracle.com>
     18 
     19 TCID=tracepath01
     20 TST_TOTAL=1
     21 . test_net.sh
     22 
     23 test_tracepath()
     24 {
     25 	local cmd="$1"
     26 	local len=1280
     27 	local output=
     28 	local ret=0
     29 	local rhost="$2"
     30 	tst_check_cmds "$cmd"
     31 
     32 	tst_resm TINFO "test $cmd with $rhost, pmtu is $len"
     33 
     34 	output=$($cmd $rhost -l $len | grep "pmtu $len")
     35 	if [ $? -ne 0 ]; then
     36 		tst_resm TFAIL "$cmd failed: pmtu $len not found in output"
     37 		return
     38 	fi
     39 
     40 	# Usually only one hop is required to get to remote test machine
     41 	hops_num=$(echo "$output" | sed -nE 's/.*hops ([0-9]+).*/\1/p')
     42 	if [ -z "$hops_num" ]; then
     43 		tst_resm TFAIL "failed to trace path to '$rhost'"
     44 		return
     45 	fi
     46 
     47 	if [ "$hops_num" -eq 0 ]; then
     48 		tst_resm TFAIL "can't trace path to '$rhost' in 1+ hops"
     49 		return
     50 	fi
     51 
     52 	tst_resm TPASS "traced path to '$rhost' in $hops_num hops"
     53 }
     54 
     55 test_tracepath tracepath$TST_IPV6 $(tst_ipaddr rhost)
     56 
     57 tst_exit
     58