Commit a86a29a8 authored by Mike Hibler's avatar Mike Hibler

Sigh...Debian/Ubuntu people apparently felt it necessary to write their

own dhclient-script which ignores the exit value from dhclient-enter-hooks.
The result is that an Ubuntu node in an inner elab can wind up with a
1.1.1.1 nameserver if the DHCP replies come in in a particular order.
So we, um..."work around" that situation.

Also, ethtool is in a different location.
parent ea450e30
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
# Copyright (c) 2000-2007, 2009 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -61,8 +61,12 @@ common-sysetc-install: dir-install
sysetc-fixup:
rm -rf $(SYSETCDIR)/modules.conf $(SYSETCDIR)/cron.pend $(SYSETCDIR)/sysconfig $(SYSETCDIR)/init.d/ntpd
mv $(SYSETCDIR)/dhclient-enter-hooks $(SYSETCDIR)/dhcp3/
mv $(SYSETCDIR)/dhclient-exit-hooks $(SYSETCDIR)/dhcp3/
rm -f $(SYSETCDIR)/dhclient-enter-hooks \
$(SYSETCDIR)/dhclient-exit-hooks
$(INSTALL) -m 755 $(SRCDIR)/dhclient-exit-hooks \
$(SYSETCDIR)/dhcp3/dhclient-exit-hooks
$(INSTALL) -m 755 $(SRCDIR)/dhclient-enter-hooks \
$(SYSETCDIR)/dhcp3/dhclient-enter-hooks
rm -f $(RRCDIR)/rc.local $(SYSETCDIR)/rc.local
$(INSTALL) -m 755 $(SRCDIR)/rc.local $(SYSETCDIR)/rc.local
$(INSTALL) -m 755 $(SRCDIR)/interfaces $(SYSETCDIR)/network/interfaces
......
#!/bin/sh
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004-2009 University of Utah and the Flux Group.
# All rights reserved.
#
. /etc/emulab/paths.sh
#
# Sweet! dhclient on linux wants to DHCP on the loopback interface
# thus screwing up its default setting. Put a stop to that early on!
#
if [ xxx$interface = xxxlo ]; then
exit_status=1
return
fi
echo "`date`: ${interface}: ${reason}" >>$LOGDIR/dhclient-enter.log 2>&1
#
# XXX Hack to force the duplex on interfaces
#
setduplex() {
_if=$1
_rc=0
if [ -x /sbin/ethtool ]; then
_ethtool=/sbin/ethtool
else
_ethtool=/usr/sbin/ethtool
fi
_out=`$_ethtool $_if`
if [ $? -eq 0 ]; then
_hmb=`echo $_out | grep -c 'Speed: 100Mb/s'`
_fdx=`echo $_out | grep -c 'Duplex: Full'`
else
_out=`/sbin/mii-tool $_if`
_hmb=`echo $_out | grep -c '100 Mbit'`
_fdx=`echo $_out | grep -c 'full duplex'`
fi
if [ $_hmb -ne 0 -a $_fdx -ne 0 ]; then
echo "$_if: speed/duplex correct"
else
echo -n "$_if: fixing speed/duplex..."
if $_ethtool $_if >/dev/null 2>&1; then
$_ethtool -s $_if autoneg off speed 100 duplex full
else
/sbin/mii-tool --force=100baseTx-FD $_if
fi
_rc=$?
echo "returns $_rc"
fi
return $_rc
}
if [ x$reason != xREBOOT -a x$reason != xBOUND -a x$reason != xRENEW -a x$reason != xREBIND ]
then
# do nothing
true
elif [ x"$new_domain_name_servers" = "x1.1.1.1" ]; then
#
# ElabinElab support.
#
# 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 it just keeps getting better! The Ubuntu (Debian?) dhclient-script
# doesn't check that status code and just plows ahead. Thus we will wind
# up with a resolv.conf file with 1.1.1.1 as the name server. So if we
# currently have a legit resolv.conf (one without a 1.1.1.1 nameserver),
# save that off so we can restore it in the exit hook.
#
if grep -q 1.1.1.1 /etc/resolv.conf; then
echo "`date`: ${interface}: resolv.conf already bad"
else
echo "`date`: ${interface}: saving current resolv.conf"
cp -p /etc/resolv.conf /etc/resolv.conf.good
fi >>$LOGDIR/dhclient-enter.log 2>&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 -s | awk '{ print $1 }' | grep -v Iface`
do
if [ $_if != "lo" -a x$_if != x$interface ]; then
setduplex $_if >>$LOGDIR/dhclient-enter.log 2>&1
fi
done
#
# XXX sleep here so we don't pummel boss with REQUEST/DECLINE pairs.
#
sleep 3
elif [ "$new_network_number" = "10.200.1.0" ]; then
#
# 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.
#
setduplex $interface >>$LOGDIR/dhclient-enter.log 2>&1
fi
echo "`date`: ${interface}: ${reason}: done" >>$LOGDIR/dhclient-enter.log 2>&1
#!/bin/sh
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2009 University of Utah and the Flux Group.
# All rights reserved.
#
. /etc/emulab/paths.sh
echo "`date`: ${interface}: ${reason}" >>$LOGDIR/dhclient-exit.log 2>&1
if [ x$reason != xREBOOT -a x$reason != xBOUND -a x$reason != xRENEW -a x$reason != xREBIND ]
then
exit 0
fi
#
# ElabinElab support
#
# The enter-hooks script should weed out outer boss calls, so there
# should be nothing to do here. However, just in case we smack em down
# again here.
#
# XXX we will get here on Ubuntu (Debian?), as the exit status of the
# enter hook is not checked (see dhclient-enter-hook). At this point
# we have a bogus resolv.conf file and we must fix it up.
#
if [ x"$new_domain_name_servers" = "x1.1.1.1" ]; then
echo -n "`date`: ${interface}: exit with bad name server..."
if [ -f /etc/resolv.conf.good ]; then
echo "replacing"
mv /etc/resolv.conf.good /etc/resolv.conf
else
echo "no good replacement, removing"
cp /dev/null /etc/resolv.conf
fi
exit_status=1
exit 1
fi >>$LOGDIR/dhclient-exit.log 2>&1
#
# Remember our server IP, real hostname, router IP, etc.
#
echo $new_dhcp_server_identifier > $BOOTDIR/bossip
echo $new_host_name > $BOOTDIR/realname
echo $new_routers > $BOOTDIR/routerip
echo $new_ip_address > $BOOTDIR/myip
echo $new_subnet_mask > $BOOTDIR/mynetmask
if [ -n "$interface" ]; then
echo $interface > $BOOTDIR/controlif
fi
#
# If this is a newnode boot, boss (inner or outer) will have returned with
# no hostname. We don't need to record anything in this case, so skip it.
#
if [ x"$new_host_name" = x ]; then
exit 0
fi
#
# We have observed problems where changing the speed/duplex of a link
# leaves DNS a little wonky. So we whack on it til it responds so that
# the sethostname script won't fail.
#
if [ "$new_network_number" = "10.200.1.0" ]; then
for i in 0 1 2; do
if `$BINDIR/tmcc bossinfo >/dev/null 2>&1`; then
break
fi
echo "`date`: ${interface}: waiting for DNS.." >>$LOGDIR/dhclient-exit.log 2>&1
sleep $i
done
fi
#
# See if the Testbed configuration software wants to change the hostname.
#
$BINDIR/sethostname.dhclient >>$LOGDIR/dhclient.log 2>&1
echo "`date`: ${interface}: ${reason}: done" >>$LOGDIR/dhclient-exit.log 2>&1
#
# The killing of dhclient and shutdown of other interfaces is handled
# by the dhclient caller (sysconfig/network-scripts/ifcfg-eth99)
#
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment