• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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@oracle.com>
18
19TCID=tracepath01
20TST_TOTAL=1
21TST_USE_LEGACY_API=1
22. tst_net.sh
23
24test_tracepath()
25{
26	local cmd="$1"
27	local len=1280
28	local output=
29	local ret=0
30	local rhost="$2"
31	tst_test_cmds "$cmd"
32
33	tst_resm TINFO "test $cmd with $rhost, pmtu is $len"
34
35	output=$($cmd $rhost -l $len | grep "pmtu $len")
36	if [ $? -ne 0 ]; then
37		tst_resm TFAIL "$cmd failed: pmtu $len not found in output"
38		return
39	fi
40
41	# Usually only one hop is required to get to remote test machine
42	hops_num=$(echo "$output" | sed -nE 's/.*hops ([0-9]+).*/\1/p')
43	if [ -z "$hops_num" ]; then
44		tst_resm TFAIL "failed to trace path to '$rhost'"
45		return
46	fi
47
48	if [ "$hops_num" -eq 0 ]; then
49		tst_resm TFAIL "can't trace path to '$rhost' in 1+ hops"
50		return
51	fi
52
53	tst_resm TPASS "traced path to '$rhost' in $hops_num hops"
54}
55
56test_tracepath tracepath$TST_IPV6 $(tst_ipaddr rhost)
57
58tst_exit
59