Commit ebdbec62 authored by Mike Hibler's avatar Mike Hibler

Changes for dynamic generation of gated config files

parent 698197b0
......@@ -27,8 +27,7 @@ use Exporter;
CONFDIR TMCC TMIFC TMDELAY TMRPM TMTARBALLS TMHOSTS TMJAILNAME
TMNICKNAME HOSTSFILE TMSTARTUPCMD FINDIF TMTUNNELCONFIG
TMTRAFFICCONFIG TMROUTECONFIG TMLINKDELAY TMDELMAP TMMOUNTDB
TMPROGAGENTS TMPASSDB TMGROUPDB
TMPROGAGENTS TMPASSDB TMGROUPDB TMGATEDCONFIG
TMCCCMD_REBOOT TMCCCMD_STATUS TMCCCMD_IFC TMCCCMD_ACCT TMCCCMD_DELAY
TMCCCMD_HOSTS TMCCCMD_RPM TMCCCMD_TARBALL TMCCCMD_STARTUP
TMCCCMD_DELTA TMCCCMD_STARTSTAT TMCCCMD_READY TMCCCMD_TRAFFIC
......@@ -192,6 +191,7 @@ sub TMIFC() { CONFDIR() . "/rc.ifc"; }
sub TMRPM() { CONFDIR() . "/rc.rpm";}
sub TMTARBALLS() { CONFDIR() . "/rc.tarballs";}
sub TMROUTECONFIG() { CONFDIR() . "/rc.route";}
sub TMGATEDCONFIG() { CONFDIR() . "/gated.conf";}
sub TMTRAFFICCONFIG() { CONFDIR() . "/rc.traffic";}
sub TMTUNNELCONFIG() { CONFDIR() . "/rc.tunnel";}
sub TMVTUNDCONFIG() { CONFDIR() . "/vtund.conf";}
......@@ -337,10 +337,6 @@ sub OPENTMCC($;$$)
die("\n") if $tmccdie;
return undef;
}
# XXX For debugging
print STDERR "$foo\n";
return (*TM);
}
......@@ -834,7 +830,17 @@ sub doifconfig (;$)
}
CLOSETMCC($TM);
#
# Create the interface list file.
# Control net is always first.
#
open(XIFS, ">$BOOTDIR/tmcc.ifs") or
die "Cannot open file $BOOTDIR/tmcc.ifs: $!";
print XIFS `control_interface`;
if (! @ifaces) {
close(XIFS);
return 0;
}
......@@ -855,6 +861,12 @@ sub doifconfig (;$)
my $routearg = inet_ntoa(inet_aton($inet) & inet_aton($mask));
if (my $iface = findiface($mac)) {
print XIFS "$iface\n";
if (JAILED()) {
next;
}
my ($upline, $downline) =
os_ifconfig_line($iface, $inet,
$mask, $speed, $duplex, $aliases,$rtabid);
......@@ -888,8 +900,17 @@ sub doifconfig (;$)
my $pmac = $6;
my $routearg = inet_ntoa(inet_aton($inet) & inet_aton($mask));
if (JAILED()) {
if ($iface = findiface($vmac)) {
print XIFS "$iface\n";
}
next;
}
if ($pmac eq "none" ||
($iface = findiface($pmac))) {
print XIFS "$iface\n";
my ($upline, $downline) =
os_ifconfig_veth($iface, $inet, $mask, $id, $vmac,$rtabid);
......@@ -908,6 +929,11 @@ sub doifconfig (;$)
warn "*** WARNING: Bad ifconfig line: $_";
}
}
close(XIFS);
if (JAILED()) {
return 0;
}
#
# Local file into which we write ifconfig commands (as a shell script).
#
......@@ -1075,7 +1101,7 @@ sub dorouterconfig (;$)
# this work (i.e., to import existing kernel routes).
#
if ($usegated) {
$rcline = os_routing_enable_gated();
$rcline = gatedsetup();
print RC " $rcline\n";
}
print RC " ;;\n";
......@@ -1088,6 +1114,39 @@ sub dorouterconfig (;$)
return 0;
}
sub gatedsetup ()
{
my ($cnet, @xifs) = split('\n', `cat $BOOTDIR/tmcc.ifs`);
open(IFS, ">" . TMGATEDCONFIG)
or die("Could not open " . TMGATEDCONFIG . ": $!");
print IFS "# auto-generated by libsetup.pm, DO NOT EDIT\n\n";
#
# XXX hack: in a jail, the control net is an IP alias with a host mask.
# This blows gated out of the water, so we have to make the control
# interface appear to have a subnet mask.
#
if (JAILED() && -e "$BOOTDIR/myip") {
my $hostip = `cat $BOOTDIR/myip`;
chomp($hostip);
print IFS "interfaces {\n".
"\tdefine subnet local $hostip netmask 255.240.0.0;\n};\n";
}
print IFS "smux off;\nrip off;\nospf on {\n";
print IFS "\tbackbone {\n\t\tinterface $cnet { passive; };\n\t};\n";
print IFS "\tarea 0.0.0.2 {\n\t\tauthtype none;\n";
foreach my $xif (@xifs) {
print IFS "\t\tinterface $xif { priority 1; };\n";
}
print IFS "\t};\n};\n";
close(IFS);
return os_routing_enable_gated(TMGATEDCONFIG);
}
#
# Host names configuration (/etc/hosts).
#
......@@ -1231,7 +1290,7 @@ sub doaccounts()
if (! MFS()) {
#
# One the MFS, these will just start out as empty hashes.
# On the MFS, these will just start out as empty hashes.
#
dbmopen(%PWDDB, TMPASSDB, 0660) or
die("Cannot open " . TMPASSDB . ": $!\n");
......@@ -2326,6 +2385,12 @@ sub jailsetup()
}
print STDOUT " Allocated! $pid/$eid/$vname\n";
#
# XXX just generates interface list for routing config
#
print STDOUT "Checking Testbed interface configuration ... \n";
doifconfig();
#
# Setup SFS hostid.
#
......
......@@ -118,9 +118,6 @@ script-install: dir-install
$(INSTALL) -m 755 $(SRCDIR)/ifsetup $(BINDIR)/ifsetup
$(INSTALL) -m 755 $(SRCDIR)/control_interface \
$(BINDIR)/control_interface
$(INSTALL) -m 644 $(SRCDIR)/gated_fxp0.conf $(BINDIR)/gated_fxp0.conf
$(INSTALL) -m 644 $(SRCDIR)/gated_fxp1.conf $(BINDIR)/gated_fxp1.conf
$(INSTALL) -m 644 $(SRCDIR)/gated_fxp4.conf $(BINDIR)/gated_fxp4.conf
sfs-install:
$(INSTALL) -m 755 -o root -g wheel -d $(DESTDIR)/etc/sfs
......
......@@ -390,15 +390,16 @@ sub os_routing_enable_forward()
return $cmd;
}
sub os_routing_enable_gated()
sub os_routing_enable_gated($)
{
my ($conffile) = @_;
my $cmd;
if (REMOTE()) {
$cmd = "echo 'GATED IS NOT ALLOWED!'";
}
else {
$cmd = "$GATED -f $BINDIR/gated_`$BINDIR/control_interface`.conf";
$cmd = "$GATED -f $conffile";
}
return $cmd;
}
......
......@@ -27,8 +27,7 @@ use Exporter;
CONFDIR TMCC TMIFC TMDELAY TMRPM TMTARBALLS TMHOSTS TMJAILNAME
TMNICKNAME HOSTSFILE TMSTARTUPCMD FINDIF TMTUNNELCONFIG
TMTRAFFICCONFIG TMROUTECONFIG TMLINKDELAY TMDELMAP TMMOUNTDB
TMPROGAGENTS TMPASSDB TMGROUPDB
TMPROGAGENTS TMPASSDB TMGROUPDB TMGATEDCONFIG
TMCCCMD_REBOOT TMCCCMD_STATUS TMCCCMD_IFC TMCCCMD_ACCT TMCCCMD_DELAY
TMCCCMD_HOSTS TMCCCMD_RPM TMCCCMD_TARBALL TMCCCMD_STARTUP
TMCCCMD_DELTA TMCCCMD_STARTSTAT TMCCCMD_READY TMCCCMD_TRAFFIC
......@@ -192,6 +191,7 @@ sub TMIFC() { CONFDIR() . "/rc.ifc"; }
sub TMRPM() { CONFDIR() . "/rc.rpm";}
sub TMTARBALLS() { CONFDIR() . "/rc.tarballs";}
sub TMROUTECONFIG() { CONFDIR() . "/rc.route";}
sub TMGATEDCONFIG() { CONFDIR() . "/gated.conf";}
sub TMTRAFFICCONFIG() { CONFDIR() . "/rc.traffic";}
sub TMTUNNELCONFIG() { CONFDIR() . "/rc.tunnel";}
sub TMVTUNDCONFIG() { CONFDIR() . "/vtund.conf";}
......@@ -337,10 +337,6 @@ sub OPENTMCC($;$$)
die("\n") if $tmccdie;
return undef;
}
# XXX For debugging
print STDERR "$foo\n";
return (*TM);
}
......@@ -834,7 +830,17 @@ sub doifconfig (;$)
}
CLOSETMCC($TM);
#
# Create the interface list file.
# Control net is always first.
#
open(XIFS, ">$BOOTDIR/tmcc.ifs") or
die "Cannot open file $BOOTDIR/tmcc.ifs: $!";
print XIFS `control_interface`;
if (! @ifaces) {
close(XIFS);
return 0;
}
......@@ -855,6 +861,12 @@ sub doifconfig (;$)
my $routearg = inet_ntoa(inet_aton($inet) & inet_aton($mask));
if (my $iface = findiface($mac)) {
print XIFS "$iface\n";
if (JAILED()) {
next;
}
my ($upline, $downline) =
os_ifconfig_line($iface, $inet,
$mask, $speed, $duplex, $aliases,$rtabid);
......@@ -888,8 +900,17 @@ sub doifconfig (;$)
my $pmac = $6;
my $routearg = inet_ntoa(inet_aton($inet) & inet_aton($mask));
if (JAILED()) {
if ($iface = findiface($vmac)) {
print XIFS "$iface\n";
}
next;
}
if ($pmac eq "none" ||
($iface = findiface($pmac))) {
print XIFS "$iface\n";
my ($upline, $downline) =
os_ifconfig_veth($iface, $inet, $mask, $id, $vmac,$rtabid);
......@@ -908,6 +929,11 @@ sub doifconfig (;$)
warn "*** WARNING: Bad ifconfig line: $_";
}
}
close(XIFS);
if (JAILED()) {
return 0;
}
#
# Local file into which we write ifconfig commands (as a shell script).
#
......@@ -1075,7 +1101,7 @@ sub dorouterconfig (;$)
# this work (i.e., to import existing kernel routes).
#
if ($usegated) {
$rcline = os_routing_enable_gated();
$rcline = gatedsetup();
print RC " $rcline\n";
}
print RC " ;;\n";
......@@ -1088,6 +1114,39 @@ sub dorouterconfig (;$)
return 0;
}
sub gatedsetup ()
{
my ($cnet, @xifs) = split('\n', `cat $BOOTDIR/tmcc.ifs`);
open(IFS, ">" . TMGATEDCONFIG)
or die("Could not open " . TMGATEDCONFIG . ": $!");
print IFS "# auto-generated by libsetup.pm, DO NOT EDIT\n\n";
#
# XXX hack: in a jail, the control net is an IP alias with a host mask.
# This blows gated out of the water, so we have to make the control
# interface appear to have a subnet mask.
#
if (JAILED() && -e "$BOOTDIR/myip") {
my $hostip = `cat $BOOTDIR/myip`;
chomp($hostip);
print IFS "interfaces {\n".
"\tdefine subnet local $hostip netmask 255.240.0.0;\n};\n";
}
print IFS "smux off;\nrip off;\nospf on {\n";
print IFS "\tbackbone {\n\t\tinterface $cnet { passive; };\n\t};\n";
print IFS "\tarea 0.0.0.2 {\n\t\tauthtype none;\n";
foreach my $xif (@xifs) {
print IFS "\t\tinterface $xif { priority 1; };\n";
}
print IFS "\t};\n};\n";
close(IFS);
return os_routing_enable_gated(TMGATEDCONFIG);
}
#
# Host names configuration (/etc/hosts).
#
......@@ -1231,7 +1290,7 @@ sub doaccounts()
if (! MFS()) {
#
# One the MFS, these will just start out as empty hashes.
# On the MFS, these will just start out as empty hashes.
#
dbmopen(%PWDDB, TMPASSDB, 0660) or
die("Cannot open " . TMPASSDB . ": $!\n");
......@@ -2326,6 +2385,12 @@ sub jailsetup()
}
print STDOUT " Allocated! $pid/$eid/$vname\n";
#
# XXX just generates interface list for routing config
#
print STDOUT "Checking Testbed interface configuration ... \n";
doifconfig();
#
# Setup SFS hostid.
#
......
......@@ -114,9 +114,6 @@ script-install: dir-install
$(INSTALL) -m 755 $(SRCDIR)/nodetype $(BINDIR)/nodetype
$(INSTALL) -m 755 $(SRCDIR)/control_interface \
$(BINDIR)/control_interface
$(INSTALL) -m 644 $(SRCDIR)/gated_eth0.conf $(BINDIR)/gated_eth0.conf
$(INSTALL) -m 644 $(SRCDIR)/gated_eth2.conf $(BINDIR)/gated_eth2.conf
$(INSTALL) -m 644 $(SRCDIR)/gated_eth4.conf $(BINDIR)/gated_eth4.conf
sfs-install:
$(INSTALL) -m 755 -o root -g wheel -d $(DESTDIR)/etc/sfs
......
......@@ -295,14 +295,29 @@ sub os_routing_enable_forward()
return $cmd;
}
sub os_routing_enable_gated()
sub os_routing_enable_gated($)
{
my ($conffile) = @_;
my $cmd;
# XXX hack to avoid gated dying mysteriously with TCP/611 already in use
$cmd = "sleep 3\n ";
$cmd .= "(ps alxww ; netstat -na) > /tmp/gated.state\n ";
$cmd .= "$GATED -f $BINDIR/gated_`$BINDIR/control_interface`.conf";
#
# XXX hack to avoid gated dying with TCP/616 already in use.
#
# Apparently the port is used by something contacting ops's
# portmapper (i.e., NFS mounts) and probably only happens when
# there are a bazillion NFS mounts (i.e., an experiment in the
# testbed project).
#
$cmd = "for try in 1 2 3 4 5 6; do\n";
$cmd .= "\tif `cat /proc/net/tcp | ".
"grep -E -e '[0-9A-Z]{8}:0268 ' >/dev/null`; then\n";
$cmd .= "\t\techo 'gated GII port in use, sleeping...';\n";
$cmd .= "\t\tsleep 10;\n";
$cmd .= "\telse\n";
$cmd .= "\t\tbreak;\n";
$cmd .= "\tfi\n";
$cmd .= " done\n";
$cmd .= " $GATED -f $conffile";
return $cmd;
}
......
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