Commit c3a9c412 authored by Mike Hibler's avatar Mike Hibler

Add a timeout to the fixarpinfo command.

This ensures that if testbed services are disabled on boss (in particular
tmcd), we can still boot ops without hanging!
parent 38efff24
......@@ -39,15 +39,17 @@ sub usage()
print STDERR " -u update existing static arp entries (default)\n";
print STDERR " -c clear all arp entries and disable staticarp if set\n";
print STDERR " -n do not change anything, just report what would be done\n";
print STDERR " -t <sec> only wait up to <sec> seconds for info from boss\n";
print STDERR " -v enable verbose mode\n";
exit(1);
}
my $optlist = "sucnv";
my $optlist = "sucnvt:";
my $iface = "";
my $myip = "";
my $doit = 1;
my $verbose = 0;
my $action = "update";
my $timo = 0;
# Turn off line buffering on output
$| = 1;
......@@ -88,20 +90,31 @@ if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{'n'})) {
$doit = 0;
$doit = 0;
}
if (defined($options{'v'})) {
$verbose = 1;
}
if (defined($options{'s'})) {
$action = "set";
$action = "set";
}
if (defined($options{'c'})) {
$action = "clear";
$action = "clear";
}
if (defined($options{'u'})) {
$action = "update";
}
if (defined($options{'t'})) {
if ($options{'t'} =~ /^(\d+)$/) {
$timo = $1;
} else {
$timo = -1;
}
if ($timo < 0 || $timo > 1000000) {
print STDERR "Bad -t timeout value\n";
usage();
}
}
# Only root can actual perform the operations.
if ($doit && $EUID != 0) {
......@@ -163,7 +176,7 @@ sub doset()
# to the issue.
#
my %arpinfo = ();
my $atype = getarpinfo(\%arpinfo);
my $atype = getarpinfo(\%arpinfo, $timo);
if (!$atype) {
fatal("fixarpinfo: Could not get arpinfo from libsetup!\n");
}
......@@ -279,7 +292,7 @@ sub doupdate()
# to the issue.
#
my %newinfo = ();
my $atype = getarpinfo(\%newinfo);
my $atype = getarpinfo(\%newinfo, $timo);
if (!$atype) {
fatal("Could not get arpinfo from tmcc!\n");
}
......
......@@ -3260,13 +3260,16 @@ sub getlocalevserver()
# Note that the hash key is the IP address and not the name.
# Function returns the type of the arp configuration or undef on error.
#
sub getarpinfo($)
sub getarpinfo($;$)
{
my ($rptr) = @_;
my ($rptr,$timo) = @_;
my %arpinfo = ();
my @tmccresults = ();
# don't cache
my %opthash = ( 'nocache' => 1 );
if (defined($timo) && $timo > 0) {
$opthash{'timeout'} = $timo;
}
if (tmcc(TMCCCMD_ARPINFO, undef, \@tmccresults, %opthash) < 0) {
warn("*** WARNING: Could not get arpinfo from server!\n");
......
......@@ -30,6 +30,12 @@
. /etc/emulab/paths.sh
#
# XXX allow a timeout on tmcc calls. Without timeout, ops/fs boot will hang
# if Emulab services (i.e., tmcd) are not running on boss.
# Set to zero for no timeout.
timo=5
if [ ! -x $BINDIR/fixarpinfo ]; then
echo "*** fixarpinfo script missing, ARP lockdown not done"
exit 0
......@@ -66,21 +72,24 @@ fi
case "$1" in
start|faststart)
echo "Setting up static ARP entries."
$BINDIR/fixarpinfo -sv >$LOGDIR/fixarpinfo.log 2>&1
$BINDIR/fixarpinfo -sv -t $timo >$LOGDIR/fixarpinfo.log 2>&1
;;
restart)
echo "Updating static ARP entries."
$BINDIR/fixarpinfo -uv >$LOGDIR/fixarpinfo.log 2>&1
$BINDIR/fixarpinfo -uv -t $timo >$LOGDIR/fixarpinfo.log 2>&1
;;
stop)
echo "Removing static ARP entries."
$BINDIR/fixarpinfo -cv >$LOGDIR/fixarpinfo.log 2>&1
$BINDIR/fixarpinfo -cv -t $timo >$LOGDIR/fixarpinfo.log 2>&1
;;
*)
echo "Usage: `basename $0` {start|stop|restart}" >&2
false
;;
esac
stat=$?
exit $?
if [ $timo -gt 0 -a $stat -eq 255 ]; then
echo "WARNING: arpinfo call timed out; ARP not locked down!"
fi
exit $stat
......@@ -30,6 +30,12 @@
. /etc/emulab/paths.sh
#
# XXX allow a timeout on tmcc calls. Without timeout, ops/fs boot will hang
# if Emulab services (i.e., tmcd) are not running on boss.
# Set to zero for no timeout.
timo=5
if [ ! -x $BINDIR/fixarpinfo ]; then
echo "*** fixarpinfo script missing, ARP lockdown not done"
exit 0
......@@ -53,21 +59,24 @@ fi
case "$1" in
start|faststart)
echo "Setting up static ARP entries."
$BINDIR/fixarpinfo -sv >$LOGDIR/fixarpinfo.log 2>&1
$BINDIR/fixarpinfo -sv -t $timo >$LOGDIR/fixarpinfo.log 2>&1
;;
restart)
echo "Updating static ARP entries."
$BINDIR/fixarpinfo -uv >$LOGDIR/fixarpinfo.log 2>&1
$BINDIR/fixarpinfo -uv -t $timo >$LOGDIR/fixarpinfo.log 2>&1
;;
stop)
echo "Removing static ARP entries."
$BINDIR/fixarpinfo -cv >$LOGDIR/fixarpinfo.log 2>&1
$BINDIR/fixarpinfo -cv -t $timo >$LOGDIR/fixarpinfo.log 2>&1
;;
*)
echo "Usage: `basename $0` {start|stop|restart}" >&2
false
;;
esac
stat=$?
exit $?
if [ $timo -gt 0 -a $stat -eq 255 ]; then
echo "WARNING: arpinfo call timed out; ARP not locked down!"
fi
exit $stat
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