Commit 1fe4bff3 authored by Mike Hibler's avatar Mike Hibler

Client support for manual routing (should work for static routing as well).

Removed rc.route script which is now generated automatically by libsetup
doroutingconfig code.

Random: removed some unused variables from freebsd/liblocsetup
(IFACE, CTLIFACENUM, CTLIFACE) which collectively hardwired the control net,
probably haven't been used in a while.
parent 6e515ed8
...@@ -62,7 +62,7 @@ sub TMNICKNAME() { "$SETUPDIR/nickname"; } ...@@ -62,7 +62,7 @@ sub TMNICKNAME() { "$SETUPDIR/nickname"; }
sub FINDIF() { "$SETUPDIR/findif"; } sub FINDIF() { "$SETUPDIR/findif"; }
sub HOSTSFILE() { "/etc/hosts"; } sub HOSTSFILE() { "/etc/hosts"; }
sub TMMOUNTDB() { "$SETUPDIR/mountdb"; } sub TMMOUNTDB() { "$SETUPDIR/mountdb"; }
sub TMROUTECONFIG() { "$SETUPDIR/router.conf"; } sub TMROUTECONFIG() { "$SETUPDIR/rc.route"; }
sub TMTRAFFICCONFIG() { "$SETUPDIR/rc.traffic"; } sub TMTRAFFICCONFIG() { "$SETUPDIR/rc.traffic"; }
# #
...@@ -452,11 +452,64 @@ sub dorouterconfig () ...@@ -452,11 +452,64 @@ sub dorouterconfig ()
open(RC, ">" . TMROUTECONFIG) open(RC, ">" . TMROUTECONFIG)
or die("Could not open " . TMROUTECONFIG . ": $!"); or die("Could not open " . TMROUTECONFIG . ": $!");
print RC "#!/bin/sh\n";
print RC "# auto-generated by libsetup.pm, DO NOT EDIT\n";
#
# First turn on IP forwarding
#
my $rcline = os_routing_enable_forward();
print RC "$rcline\n";
#
# Now convert static route info into OS route commands
# Also check for use of gated and remember it.
#
my $usegated = 0;
my $pat;
#
# ROUTERTYPE=manual
# ROUTE DEST=192.168.2.3 DESTTYPE=host DESTMASK=255.255.255.0 \
# NEXTHOP=192.168.1.3 COST=0
#
$pat = q(ROUTE DEST=([0-9\.]*) DESTTYPE=(\w*) DESTMASK=([0-9\.]*) );
$pat .= q(NEXTHOP=([0-9\.]*) COST=([0-9]*));
my $usemanual = 0;
foreach my $line (@stuff) { foreach my $line (@stuff) {
print STDOUT " $line"; if ($line =~ /ROUTERTYPE=(gated|ospf)/) {
print RC "$line"; $usegated = 1;
} elsif ($line =~ /ROUTERTYPE=(manual|static)/) {
$usemanual = 1;
} elsif ($usemanual && $line =~ /$pat/) {
my $dip = $1;
my $rtype = $2;
my $dmask = $3;
my $gate = $4;
my $cost = $5;
$rcline = os_routing_add_manual($rtype, $dip, $dmask, $gate, $cost);
print RC "$rcline\n";
} else {
warn "*** WARNING: Bad routing line: $line\n";
}
} }
#
# Finally, enable gated if desired.
#
# Note that we allow both manually-specified static routes and gated
# though more work may be needed on the gated config files to make
# this work (i.e., to import existing kernel routes).
#
if ($usegated) {
$rcline = os_routing_enable_gated();
print RC "$rcline\n";
}
close(RC); close(RC);
chmod(0755, TMROUTECONFIG);
return 0; return 0;
} }
......
...@@ -72,7 +72,6 @@ script-install: dir-install ...@@ -72,7 +72,6 @@ script-install: dir-install
$(INSTALL) -m 755 $(SRCDIR)/start_if.fxp1 $(ETCDIR)/start_if.fxp1 $(INSTALL) -m 755 $(SRCDIR)/start_if.fxp1 $(ETCDIR)/start_if.fxp1
$(INSTALL) -m 755 $(SRCDIR)/start_if.fxp4 $(ETCDIR)/start_if.fxp4 $(INSTALL) -m 755 $(SRCDIR)/start_if.fxp4 $(ETCDIR)/start_if.fxp4
$(INSTALL) -m 755 $(SRCDIR)/start_if.xl0 $(ETCDIR)/start_if.xl0 $(INSTALL) -m 755 $(SRCDIR)/start_if.xl0 $(ETCDIR)/start_if.xl0
$(INSTALL) -m 755 $(SRCDIR)/rc.route $(INSTALL_DIR)/rc.route
$(INSTALL) -m 644 $(SRCDIR)/gated_fxp0.conf $(INSTALL_DIR)/gated_fxp0.conf $(INSTALL) -m 644 $(SRCDIR)/gated_fxp0.conf $(INSTALL_DIR)/gated_fxp0.conf
$(INSTALL) -m 644 $(SRCDIR)/gated_fxp1.conf $(INSTALL_DIR)/gated_fxp1.conf $(INSTALL) -m 644 $(SRCDIR)/gated_fxp1.conf $(INSTALL_DIR)/gated_fxp1.conf
$(INSTALL) -m 644 $(SRCDIR)/gated_fxp4.conf $(INSTALL_DIR)/gated_fxp4.conf $(INSTALL) -m 644 $(SRCDIR)/gated_fxp4.conf $(INSTALL_DIR)/gated_fxp4.conf
...@@ -10,7 +10,8 @@ use Exporter; ...@@ -10,7 +10,8 @@ use Exporter;
qw ( $CP $EGREP $MOUNT $UMOUNT $TMPASSWD qw ( $CP $EGREP $MOUNT $UMOUNT $TMPASSWD
os_cleanup_node os_ifconfig_line os_etchosts_line os_cleanup_node os_ifconfig_line os_etchosts_line
os_setup os_groupadd os_useradd os_userdel os_usermod os_mkdir os_setup os_groupadd os_useradd os_userdel os_usermod os_mkdir
os_rpminstall_line update_delays enable_ipod os_rpminstall_line update_delays
os_routing_enable_forward os_routing_enable_gated os_routing_add_manual
); );
# Must come after package declaration! # Must come after package declaration!
...@@ -47,6 +48,8 @@ my $IFC_10MBS = "media 10baseT/UTP"; ...@@ -47,6 +48,8 @@ my $IFC_10MBS = "media 10baseT/UTP";
my $IFC_FDUPLEX = "mediaopt full-duplex"; my $IFC_FDUPLEX = "mediaopt full-duplex";
my $RPMINSTALL = "/usr/local/bin/rpm -i %s"; my $RPMINSTALL = "/usr/local/bin/rpm -i %s";
my $MKDIR = "/bin/mkdir"; my $MKDIR = "/bin/mkdir";
my $GATED = "/usr/local/sbin/gated";
my $ROUTE = "/sbin/route";
# #
# Delay node configuration goop. # Delay node configuration goop.
...@@ -56,9 +59,6 @@ my $KERNEL1000 = "/kernel.1000HZ"; ...@@ -56,9 +59,6 @@ my $KERNEL1000 = "/kernel.1000HZ";
my $KERNEL10000 = "/kernel.10000HZ"; my $KERNEL10000 = "/kernel.10000HZ";
my @KERNELS = ($KERNEL100, $KERNEL1000, $KERNEL10000); my @KERNELS = ($KERNEL100, $KERNEL1000, $KERNEL10000);
my $kernel = $KERNEL100; my $kernel = $KERNEL100;
my $IFACE = "fxp";
my $CTLIFACENUM = "4";
my $CTLIFACE = "${IFACE}${CTLIFACENUM}";
my $TMDELAY = "$SETUPDIR/rc.delay"; my $TMDELAY = "$SETUPDIR/rc.delay";
my $TMDELMAP = "$SETUPDIR/delay_mapping"; my $TMDELMAP = "$SETUPDIR/delay_mapping";
my $TMCCCMD_DELAY = "delay"; my $TMCCCMD_DELAY = "delay";
...@@ -519,4 +519,42 @@ sub dodelays () ...@@ -519,4 +519,42 @@ sub dodelays ()
return 0; return 0;
} }
#
# OS dependent, routing-related commands
#
sub os_routing_enable_forward()
{
my $cmd;
$cmd = "sysctl -w net.inet.ip.forwarding=1\n";
$cmd .= "sysctl -w net.inet.ip.fastforwarding=1";
return $cmd;
}
sub os_routing_enable_gated()
{
my $cmd;
$cmd = "$GATED -f $SETUPDIR/gated_`$SETUPDIR/control_interface`.conf";
return $cmd;
}
sub os_routing_add_manual($$$$$)
{
my ($routetype, $destip, $destmask, $gate, $cost) = @_;
my $cmd;
if ($routetype eq "host") {
$cmd = "$ROUTE add -host $destip $gate";
} elsif ($routetype eq "net") {
$cmd = "$ROUTE add -net $destip $gate $destmask";
} else {
warn "*** WARNING: bad routing entry type: $routetype\n";
$cmd = "";
}
return $cmd;
}
1; 1;
#!/bin/sh
# We only handle gated right now
case $1 in
ROUTERTYPE=gated | ROUTERTYPE=ospf)
;;
*)
echo "WARNING bad TMCD routing info, gated not started"
exit 0
;;
esac
# Must know the control net
if [ -x /etc/testbed/control_interface ]
then
CIF=`/etc/testbed/control_interface`
else
echo "WARNING cannot determine control interface, gated not started"
exit 0
fi
if [ ! -x /usr/local/sbin/gated ]
then
echo "WARNING gated not installed, gated not started"
exit 0
fi
if [ ! -r /etc/testbed/gated_$CIF.conf ]
then
echo "WARNING no gated config for interface $CIF, gated not started"
exit 0
fi
sysctl -w net.inet.ip.forwarding=1
sysctl -w net.inet.ip.fastforwarding=1
/usr/local/sbin/gated -f /etc/testbed/gated_$CIF.conf
exit 0
...@@ -27,9 +27,9 @@ fi ...@@ -27,9 +27,9 @@ fi
if [ -x /etc/testbed/rc.delay ]; then if [ -x /etc/testbed/rc.delay ]; then
echo "Setting up Testbed delay configuration ..." echo "Setting up Testbed delay configuration ..."
/etc/testbed/rc.delay /etc/testbed/rc.delay
elif [ -x /etc/testbed/rc.route -a -r /etc/testbed/router.conf ]; then elif [ -x /etc/testbed/rc.route ]; then
echo "Setting up Testbed interface routing ..." echo "Setting up Testbed interface routing ..."
/etc/testbed/rc.route `cat /etc/testbed/router.conf` /etc/testbed/rc.route
fi fi
if [ -x /etc/testbed/rc.rpm ]; then if [ -x /etc/testbed/rc.rpm ]; then
......
...@@ -62,7 +62,7 @@ sub TMNICKNAME() { "$SETUPDIR/nickname"; } ...@@ -62,7 +62,7 @@ sub TMNICKNAME() { "$SETUPDIR/nickname"; }
sub FINDIF() { "$SETUPDIR/findif"; } sub FINDIF() { "$SETUPDIR/findif"; }
sub HOSTSFILE() { "/etc/hosts"; } sub HOSTSFILE() { "/etc/hosts"; }
sub TMMOUNTDB() { "$SETUPDIR/mountdb"; } sub TMMOUNTDB() { "$SETUPDIR/mountdb"; }
sub TMROUTECONFIG() { "$SETUPDIR/router.conf"; } sub TMROUTECONFIG() { "$SETUPDIR/rc.route"; }
sub TMTRAFFICCONFIG() { "$SETUPDIR/rc.traffic"; } sub TMTRAFFICCONFIG() { "$SETUPDIR/rc.traffic"; }
# #
...@@ -452,11 +452,64 @@ sub dorouterconfig () ...@@ -452,11 +452,64 @@ sub dorouterconfig ()
open(RC, ">" . TMROUTECONFIG) open(RC, ">" . TMROUTECONFIG)
or die("Could not open " . TMROUTECONFIG . ": $!"); or die("Could not open " . TMROUTECONFIG . ": $!");
print RC "#!/bin/sh\n";
print RC "# auto-generated by libsetup.pm, DO NOT EDIT\n";
#
# First turn on IP forwarding
#
my $rcline = os_routing_enable_forward();
print RC "$rcline\n";
#
# Now convert static route info into OS route commands
# Also check for use of gated and remember it.
#
my $usegated = 0;
my $pat;
#
# ROUTERTYPE=manual
# ROUTE DEST=192.168.2.3 DESTTYPE=host DESTMASK=255.255.255.0 \
# NEXTHOP=192.168.1.3 COST=0
#
$pat = q(ROUTE DEST=([0-9\.]*) DESTTYPE=(\w*) DESTMASK=([0-9\.]*) );
$pat .= q(NEXTHOP=([0-9\.]*) COST=([0-9]*));
my $usemanual = 0;
foreach my $line (@stuff) { foreach my $line (@stuff) {
print STDOUT " $line"; if ($line =~ /ROUTERTYPE=(gated|ospf)/) {
print RC "$line"; $usegated = 1;
} elsif ($line =~ /ROUTERTYPE=(manual|static)/) {
$usemanual = 1;
} elsif ($usemanual && $line =~ /$pat/) {
my $dip = $1;
my $rtype = $2;
my $dmask = $3;
my $gate = $4;
my $cost = $5;
$rcline = os_routing_add_manual($rtype, $dip, $dmask, $gate, $cost);
print RC "$rcline\n";
} else {
warn "*** WARNING: Bad routing line: $line\n";
}
} }
#
# Finally, enable gated if desired.
#
# Note that we allow both manually-specified static routes and gated
# though more work may be needed on the gated config files to make
# this work (i.e., to import existing kernel routes).
#
if ($usegated) {
$rcline = os_routing_enable_gated();
print RC "$rcline\n";
}
close(RC); close(RC);
chmod(0755, TMROUTECONFIG);
return 0; return 0;
} }
......
...@@ -66,7 +66,6 @@ script-install: dir-install ...@@ -66,7 +66,6 @@ script-install: dir-install
$(INSTALL) -m 755 $(SRCDIR)/ifcfg-eth2 /etc/sysconfig/network-scripts/ifcfg-eth2 $(INSTALL) -m 755 $(SRCDIR)/ifcfg-eth2 /etc/sysconfig/network-scripts/ifcfg-eth2
$(INSTALL) -m 755 $(SRCDIR)/ifcfg-eth3 /etc/sysconfig/network-scripts/ifcfg-eth3 $(INSTALL) -m 755 $(SRCDIR)/ifcfg-eth3 /etc/sysconfig/network-scripts/ifcfg-eth3
$(INSTALL) -m 755 $(SRCDIR)/ifcfg-eth4 /etc/sysconfig/network-scripts/ifcfg-eth4 $(INSTALL) -m 755 $(SRCDIR)/ifcfg-eth4 /etc/sysconfig/network-scripts/ifcfg-eth4
$(INSTALL) -m 755 $(SRCDIR)/rc.route $(INSTALL_DIR)/rc.route
$(INSTALL) -m 644 $(SRCDIR)/gated_eth0.conf $(INSTALL_DIR)/gated_eth0.conf $(INSTALL) -m 644 $(SRCDIR)/gated_eth0.conf $(INSTALL_DIR)/gated_eth0.conf
$(INSTALL) -m 644 $(SRCDIR)/gated_eth2.conf $(INSTALL_DIR)/gated_eth2.conf $(INSTALL) -m 644 $(SRCDIR)/gated_eth2.conf $(INSTALL_DIR)/gated_eth2.conf
$(INSTALL) -m 644 $(SRCDIR)/gated_eth4.conf $(INSTALL_DIR)/gated_eth4.conf $(INSTALL) -m 644 $(SRCDIR)/gated_eth4.conf $(INSTALL_DIR)/gated_eth4.conf
......
...@@ -11,6 +11,7 @@ use Exporter; ...@@ -11,6 +11,7 @@ use Exporter;
os_cleanup_node os_ifconfig_line os_etchosts_line os_cleanup_node os_ifconfig_line os_etchosts_line
os_setup os_groupadd os_useradd os_userdel os_usermod os_mkdir os_setup os_groupadd os_useradd os_userdel os_usermod os_mkdir
os_rpminstall_line enable_ipod os_rpminstall_line enable_ipod
os_routing_enable_forward os_routing_enable_gated os_routing_add_manual
); );
# Must come after package declaration! # Must come after package declaration!
...@@ -49,6 +50,8 @@ my $IFC_HDUPLEX = "HD"; ...@@ -49,6 +50,8 @@ my $IFC_HDUPLEX = "HD";
my $RPMINSTALL = "/bin/rpm -i %s"; my $RPMINSTALL = "/bin/rpm -i %s";
my @LOCKFILES = ("/etc/group.lock", "/etc/gshadow.lock"); my @LOCKFILES = ("/etc/group.lock", "/etc/gshadow.lock");
my $MKDIR = "/bin/mkdir"; my $MKDIR = "/bin/mkdir";
my $GATED = "/usr/sbin/gated";
my $ROUTE = "/sbin/route";
# #
# OS dependent part of cleanup node state. # OS dependent part of cleanup node state.
...@@ -223,6 +226,10 @@ sub os_setup() ...@@ -223,6 +226,10 @@ sub os_setup()
return 0; return 0;
} }
#
# OS dependent "ICMP Ping of Death" support
#
use Socket; use Socket;
sub enable_ipod() sub enable_ipod()
...@@ -253,4 +260,41 @@ sub enable_ipod() ...@@ -253,4 +260,41 @@ sub enable_ipod()
return 0; return 0;
} }
#
# OS dependent, routing-related commands
#
sub os_routing_enable_forward()
{
my $cmd;
$cmd = "sysctl -w net.ipv4.conf.all.forwarding=1";
return $cmd;
}
sub os_routing_enable_gated()
{
my $cmd;
$cmd = "$GATED -f $SETUPDIR/gated_`$SETUPDIR/control_interface`.conf";
return $cmd;
}
sub os_routing_add_manual($$$$$)
{
my ($routetype, $destip, $destmask, $gate, $cost) = @_;
my $cmd;
if ($routetype eq "host") {
$cmd = "$ROUTE add -host $destip gw $gate";
} elsif ($routetype eq "net") {
$cmd = "$ROUTE add -net $destip netmask $destmask gw $gate";
} else {
warn "*** WARNING: bad routing entry type: $routetype\n";
$cmd = "";
}
return $cmd;
}
1; 1;
#!/bin/sh
# We only handle gated right now
case $1 in
ROUTERTYPE=gated | ROUTERTYPE=ospf)
;;
*)
echo "WARNING bad TMCD routing info, gated not started"
exit 0
;;
esac
# Must know the control net
if [ -x /etc/testbed/control_interface ]
then
CIF=`/etc/testbed/control_interface`
else
echo "WARNING cannot determine control interface, gated not started"
exit 0
fi
if [ ! -x /usr/sbin/gated ]
then
echo "WARNING gated not installed, gated not started"
exit 0
fi
if [ ! -r /etc/testbed/gated_$CIF.conf ]
then
echo "WARNING no gated config for interface $CIF, gated not started"
exit 0
fi
sysctl -w net.ipv4.conf.all.forwarding=1
/usr/sbin/gated -f /etc/testbed/gated_$CIF.conf
exit 0
...@@ -18,9 +18,9 @@ if [ -x /etc/rc.d/testbed/rc.ifc ]; then ...@@ -18,9 +18,9 @@ if [ -x /etc/rc.d/testbed/rc.ifc ]; then
/etc/rc.d/testbed/rc.ifc /etc/rc.d/testbed/rc.ifc
fi fi
if [ -x /etc/testbed/rc.route -a -r /etc/testbed/router.conf ]; then if [ -x /etc/rc.d/testbed/rc.route ]; then
echo "Setting up Testbed interface routing ..." echo "Setting up Testbed interface routing ..."
/etc/testbed/rc.route `cat /etc/testbed/router.conf` /etc/rc.d/testbed/rc.route
fi fi
if [ -x /etc/rc.d/testbed/rc.rpm ]; then if [ -x /etc/rc.d/testbed/rc.rpm ]; then
......
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