• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2
3################################################################################
4##                                                                            ##
5## Copyright (c) International Business Machines  Corp., 2005                 ##
6##                                                                            ##
7## This program is free software;  you can redistribute it and#or modify      ##
8## it under the terms of the GNU General Public License as published by       ##
9## the Free Software Foundation; either version 2 of the License, or          ##
10## (at your option) any later version.                                        ##
11##                                                                            ##
12## This program is distributed in the hope that it will be useful, but        ##
13## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
14## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
15## for more details.                                                          ##
16##                                                                            ##
17## You should have received a copy of the GNU General Public License          ##
18## along with this program;  if not, write to the Free Software               ##
19## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
20##                                                                            ##
21##                                                                            ##
22################################################################################
23#
24# File:
25#   initialize_if
26#
27# Description:
28#   Initialize the interface which belongs to the specified test link
29#
30# Author:
31#   Mitsuru Chinen <mitch@jp.ibm.com>
32#
33# Arguments:
34#   $1:	Set the host type (lhost - local host | rhost - remote host)
35#   $2: The number of the test link
36#
37# Exit Value:
38#    0: Exit normally
39#   >0: Exit abnormally
40#
41# History:
42#   Oct 19 2005 - Created (Mitsuru Chinen)
43#
44#-----------------------------------------------------------------------
45#Uncomment line below for debug output.
46$trace_logic
47
48# Make sure the value of LTPROOT
49LTPROOT=${LTPROOT:-`(cd ../../../../ ; pwd)`}
50export LTPROOT
51
52# Check the environmanet variable for the test
53. check_envval || exit 1
54
55# Arguments
56if [ $# -ne 2 ]; then
57    echo "Usage: $0 host_type link_num" >&2
58    exit 1
59fi
60host_type=$1
61link_num=$2
62
63# Check the host type
64if [ $host_type != lhost -a $host_type != rhost ]; then
65    echo "$0: 1st argumet is lhost or rhost" >$2
66    exit 1
67fi
68
69# Define the interface name
70ifname=`get_ifname $host_type $link_num` || exit 1
71
72# Initialize the specified interface
73command="ifconfig $ifname down mtu 1500 ; ip route flush dev $ifname ; ip addr flush dev $ifname ; ifconfig $ifname up"
74
75if [ $host_type = lhost ]; then
76    ( ifconfig $ifname down && \
77    ip link set mtu 1500 dev $ifname && \
78    ip route flush dev $ifname && \
79    ip addr flush dev $ifname && \
80    ifconfig $ifname up ) >/dev/null 2>&1
81    ret=$?
82else
83    ret=`$LTP_RSH $RHOST '( PATH=/sbin:/usr/sbin:$PATH ; ifconfig '$ifname' down && ip link set mtu 1500 dev '$ifname' && ip route flush dev '$ifname' && ip addr flush dev '$ifname' && ifconfig '$ifname' up ) >/dev/null 2>&1 ; echo $?'`
84fi
85
86if [ $ret -gt 0 ]; then
87    echo "Failed to initialize $ifname" >&2
88    exit 1
89fi
90