freebsd-skq/etc/rc.d/routing
brooks fc75339619 Move the wait for a default route to rc.d/routing. Once we test for
non-dhcp interfaces to negotiate/associate this will make more sense.

This also correctly gets run after both devd and netif are run so it has
a chance of working.
2008-05-18 02:57:54 +00:00

151 lines
2.8 KiB
Bash

#!/bin/sh
#
# Configure routing and miscellaneous network tunables
#
# $FreeBSD$
#
# PROVIDE: routing
# REQUIRE: devd netif ppp
# KEYWORD: nojail
. /etc/rc.subr
. /etc/network.subr
name="routing"
start_cmd="routing_start"
stop_cmd="routing_stop"
extra_commands="options static"
static_cmd="static_start"
options_cmd="options_start"
routing_start()
{
static_start
options_start
# Return without waiting if we don't have dhcp interfaces.
# Once we can test that the link is actually up, we should
# remove this test and always wait.
dhcp_interfaces=`list_net_interfaces dhcp`
[ -z "`list_net_interfaces dhcp`" ] && return
# Wait for a default route
delay=${if_up_delay}
while [ ${delay} -gt 0 ]; do
defif=`get_default_if -inet`
if [ -n "${defif}" ]; then
if [ ${delay} -ne ${if_up_delay} ]; then
echo "($defif)"
fi
break
fi
if [ ${delay} -eq ${if_up_delay} ]; then
echo -n "Waiting ${delay}s for an interface to come up: "
else
echo -n .
fi
sleep 1
delay=`expr $delay - 1`
done
}
routing_stop()
{
route -n flush
}
static_start()
{
case ${defaultrouter} in
[Nn][Oo] | '')
;;
*)
static_routes="default ${static_routes}"
route_default="default ${defaultrouter}"
;;
esac
# Setup static routes. This should be done before router discovery.
#
if [ -n "${static_routes}" ]; then
for i in ${static_routes}; do
eval route_args=\$route_${i}
route add ${route_args}
done
fi
# Now ATM static routes
#
if [ -n "${natm_static_routes}" ]; then
for i in ${natm_static_routes}; do
eval route_args=\$route_${i}
atmconfig natm add ${route_args}
done
fi
}
options_start()
{
echo -n 'Additional routing options:'
case ${icmp_bmcastecho} in
[Yy][Ee][Ss])
echo -n ' broadcast ping responses=YES'
sysctl net.inet.icmp.bmcastecho=1 >/dev/null
;;
esac
case ${icmp_drop_redirect} in
[Yy][Ee][Ss])
echo -n ' ignore ICMP redirect=YES'
sysctl net.inet.icmp.drop_redirect=1 >/dev/null
;;
esac
case ${icmp_log_redirect} in
[Yy][Ee][Ss])
echo -n ' log ICMP redirect=YES'
sysctl net.inet.icmp.log_redirect=1 >/dev/null
;;
esac
case ${gateway_enable} in
[Yy][Ee][Ss])
echo -n ' IP gateway=YES'
sysctl net.inet.ip.forwarding=1 >/dev/null
;;
esac
case ${forward_sourceroute} in
[Yy][Ee][Ss])
echo -n ' do source routing=YES'
sysctl net.inet.ip.sourceroute=1 >/dev/null
;;
esac
case ${accept_sourceroute} in
[Yy][Ee][Ss])
echo -n ' accept source routing=YES'
sysctl net.inet.ip.accept_sourceroute=1 >/dev/null
;;
esac
case ${ipxgateway_enable} in
[Yy][Ee][Ss])
echo -n ' IPX gateway=YES'
sysctl net.ipx.ipx.ipxforwarding=1 >/dev/null
;;
esac
case ${arpproxy_all} in
[Yy][Ee][Ss])
echo -n ' ARP proxyall=YES'
sysctl net.link.ether.inet.proxyall=1 >/dev/null
;;
esac
echo '.'
}
load_rc_config $name
run_rc_command "$1"