dhclient-enter-hooks 2.74 KB
Newer Older
1 2 3
#!/bin/sh
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
5 6 7 8
# All rights reserved.
#
. /etc/emulab/paths.sh

9
echo "`date`: ${interface}: ${reason}" >>$LOGDIR/dhclient-enter.log 2>&1
10 11

#
Mike Hibler's avatar
Mike Hibler committed
12
# XXX Hack to force the duplex on interfaces
13
#
Mike Hibler's avatar
Mike Hibler committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
setduplex() {
    _if=$1
    _rc=0

    _out=`ifconfig $_if`
    _hmb=`echo $_out | grep -c '100baseTX'`
    _fdx=`echo $_out | grep -c 'full-duplex'`

    if [ $_hmb -ne 0 -a $_fdx -ne 0 ]; then
	echo "$_if: speed/duplex correct"
    else
        # If we are fixing the current interface, just let dhclient do it
        if [ x$_if = x$interface ]; then
	    echo "$_if: telling dhclient to fix speed/duplex"
	    medium="media 100baseTX mediaopt full-duplex"
        else
	    echo -n "$_if: fixing speed/duplex..."
	    ifconfig $_if media 100baseTX mediaopt full-duplex
	    _rc=$?
	    echo "returns $_rc"
	fi
    fi
    return $_rc
}

if [ x$reason != xREBOOT -a x$reason != xBOUND -a x$reason != xRENEW -a x$reason != xREBIND ]
then
    # do nothing
    true
elif [ -e "$ETCDIR/outer_bossnode" ]; then
    #
    # ElabinElab support.
46 47 48 49 50 51 52 53 54
    #
    # On inner boss/ops, we do not accept the following from the DHCPD
    # server on outer boss. This stuff has been setup in /etc/rc.conf
    # when the inner boss/ops was created. 
    #
    unset new_host_name
    unset new_domain_name_servers
    unset new_domain_name
    unset new_routers
Mike Hibler's avatar
Mike Hibler committed
55
elif [ x"$new_domain_name_servers" = "x1.1.1.1" ]; then
56
    #
Mike Hibler's avatar
Mike Hibler committed
57
    # ElabinElab support.
58
    #
Mike Hibler's avatar
Mike Hibler committed
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
    # XXX oh so hacky.  Real boss is set to return 1.1.1.1 as a name server
    # for nodes in inner elabs.  This is the hack de jour for determining
    # who has responded to our DHCP request.  If it is outer boss and we are
    # an inner node, we want to decline this offer and not configure the
    # interface
    #
    exit_status=1

    #
    # XXX since we now know that we are in an inner elab and we know which
    # interface is the real control net, we force 100Mb full-duplex on all
    # other (experimental) interfaces.  This is necessary to ensure a
    # response from the inner control net.
    #
    for _if in `ifconfig -lu`
    do
	if [ $_if != "lo0" -a x$_if != x$interface ]; then
	    setduplex $_if >>$LOGDIR/dhclient-enter.log 2>&1
	fi
    done
79 80

    #
81
    # XXX sleep here so we don't pummel boss with REQUEST/DECLINE pairs.
Mike Hibler's avatar
Mike Hibler committed
82
    #
83 84 85
    sleep 5
elif [ "$new_network_number" = "10.200.1.0" ]; then
    #
Mike Hibler's avatar
Mike Hibler committed
86 87 88 89
    # XXX sometime we can get a reply even if the duplex is wrong.
    # If we get such a reply and we are inside an inner elab, again
    # force 100Mb full-duplex to make sure we continue to communicate
    # with the server.
90
    #
Mike Hibler's avatar
Mike Hibler committed
91
    setduplex $interface >>$LOGDIR/dhclient-enter.log 2>&1
92
fi
Mike Hibler's avatar
Mike Hibler committed
93

94
echo "`date`: ${interface}: ${reason}: done" >>$LOGDIR/dhclient-enter.log 2>&1