summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/routing
diff options
context:
space:
mode:
authorhrs <hrs@FreeBSD.org>2009-10-02 02:28:59 +0000
committerhrs <hrs@FreeBSD.org>2009-10-02 02:28:59 +0000
commita8f54fa5ca180238d20d58265286a9b1261e5c98 (patch)
treedd3136ddcb6c0700fffd6985f6654b39a7a34970 /etc/rc.d/routing
parentffdfe7e99092d7e5b5c7d403a8a3fcd996888a4c (diff)
downloadFreeBSD-src-a8f54fa5ca180238d20d58265286a9b1261e5c98.zip
FreeBSD-src-a8f54fa5ca180238d20d58265286a9b1261e5c98.tar.gz
- Split routing_*() and option_*() to *_AF() and add afexists() check
for each address family. Replace AF_static() with static_AF() for consistency. - Display a message only if the user sets a non-default value, and set a sysctl explicitly even if it is the default value.
Diffstat (limited to 'etc/rc.d/routing')
-rwxr-xr-xetc/rc.d/routing140
1 files changed, 85 insertions, 55 deletions
diff --git a/etc/rc.d/routing b/etc/rc.d/routing
index 3b39988..7edc3ba 100755
--- a/etc/rc.d/routing
+++ b/etc/rc.d/routing
@@ -27,8 +27,24 @@ routing_start()
routing_stop()
{
+ local _af
+
static_stop "$@"
- route -n flush
+ for _af in inet inet6; do
+ afexists ${_af} && eval routing_stop_${_af}
+ done
+}
+
+routing_stop_inet()
+{
+ route -n flush -inet
+}
+
+routing_stop_inet6()
+{
+ local i
+
+ route -n flush -inet6
for i in ${ipv6_network_interfaces}; do
ifconfig $i inet6 -defaultif
done
@@ -40,21 +56,11 @@ static_start()
_af=$1
case ${_af} in
- inet)
- do_static inet add
+ inet|inet6|atm)
+ do_static add ${_af}
;;
- inet6)
- do_static inet6 add
- ;;
- atm)
- do_static atm add
- ;;
- *)
- do_static inet add
- if afexists inet6; then
- do_static inet6 add
- fi
- do_static atm add
+ "")
+ do_static add inet inet6 atm
;;
esac
}
@@ -65,21 +71,11 @@ static_stop()
_af=$1
case ${_af} in
- inet)
- do_static inet delete
- ;;
- inet6)
- do_static inet6 delete
+ inet|inet6|atm)
+ do_static delete ${_af}
;;
- atm)
- do_static atm delete
- ;;
- *)
- do_static inet delete
- if afexists inet6; then
- do_static inet6 delete
- fi
- do_static atm delete
+ "")
+ do_static delete inet inet6 atm
;;
esac
}
@@ -87,13 +83,15 @@ static_stop()
do_static()
{
local _af _action
- _af=$1
- _action=$2
+ _action=$1
- eval $1_static $2
+ shift
+ for _af in "$@"; do
+ afexists ${_af} && eval static_${_af} ${_action}
+ done
}
-inet_static()
+static_inet()
{
local _action
_action=$1
@@ -115,7 +113,7 @@ inet_static()
fi
}
-inet6_static()
+static_inet6()
{
local _action i
_action=$1
@@ -222,9 +220,9 @@ inet6_static()
esac
}
-atm_static()
+static_atm()
{
- local _action i
+ local _action i route_args
_action=$1
if [ -n "${natm_static_routes}" ]; then
@@ -246,61 +244,93 @@ ropts_init()
options_start()
{
+ local _af
+
+ for _af in inet inet6 ipx; do
+ afexists ${_af} && eval options_${_af}
+ done
+ [ -n "${_ropts_initdone}" ] && echo '.'
+}
+
+options_inet()
+{
if checkyesno icmp_bmcastecho; then
ropts_init
echo -n ' broadcast ping responses=YES'
- sysctl net.inet.icmp.bmcastecho=1 >/dev/null
+ ${SYSCTL_W} net.inet.icmp.bmcastecho=1 > /dev/null
+ else
+ ${SYSCTL_W} net.inet.icmp.bmcastecho=0 > /dev/null
fi
if checkyesno icmp_drop_redirect; then
ropts_init
echo -n ' ignore ICMP redirect=YES'
- sysctl net.inet.icmp.drop_redirect=1 >/dev/null
+ ${SYSCTL_W} net.inet.icmp.drop_redirect=1 > /dev/null
+ else
+ ${SYSCTL_W} net.inet.icmp.drop_redirect=0 > /dev/null
fi
if checkyesno icmp_log_redirect; then
ropts_init
echo -n ' log ICMP redirect=YES'
- sysctl net.inet.icmp.log_redirect=1 >/dev/null
+ ${SYSCTL_W} net.inet.icmp.log_redirect=1 > /dev/null
+ else
+ ${SYSCTL_W} net.inet.icmp.log_redirect=0 > /dev/null
fi
if checkyesno gateway_enable; then
ropts_init
echo -n ' IPv4 gateway=YES'
- sysctl net.inet.ip.forwarding=1 >/dev/null
- fi
-
- if checkyesno ipv6_gateway_enable; then
- ropts_init
- echo -n ' IPv6 gateway=YES'
- sysctl net.inet6.ip6.forwarding=1 >/dev/null
+ ${SYSCTL_W} net.inet.ip.forwarding=1 > /dev/null
+ else
+ ${SYSCTL_W} net.inet.ip.forwarding=0 > /dev/null
fi
if checkyesno forward_sourceroute; then
ropts_init
echo -n ' do source routing=YES'
- sysctl net.inet.ip.sourceroute=1 >/dev/null
+ ${SYSCTL_W} net.inet.ip.sourceroute=1 > /dev/null
+ else
+ ${SYSCTL_W} net.inet.ip.sourceroute=0 > /dev/null
fi
if checkyesno accept_sourceroute; then
ropts_init
echo -n ' accept source routing=YES'
- sysctl net.inet.ip.accept_sourceroute=1 >/dev/null
+ ${SYSCTL_W} net.inet.ip.accept_sourceroute=1 > /dev/null
+ else
+ ${SYSCTL_W} net.inet.ip.accept_sourceroute=0 > /dev/null
fi
- if checkyesno ipxgateway_enable; then
+ if checkyesno arpproxy_all; then
ropts_init
- echo -n ' IPX gateway=YES'
- sysctl net.ipx.ipx.ipxforwarding=1 >/dev/null
+ echo -n ' ARP proxyall=YES'
+ ${SYSCTL_W} net.link.ether.inet.proxyall=1 > /dev/null
+ else
+ ${SYSCTL_W} net.link.ether.inet.proxyall=0 > /dev/null
fi
+}
- if checkyesno arpproxy_all; then
+options_inet6()
+{
+ if checkyesno ipv6_gateway_enable; then
ropts_init
- echo -n ' ARP proxyall=YES'
- sysctl net.link.ether.inet.proxyall=1 >/dev/null
+ echo -n ' IPv6 gateway=YES'
+ ${SYSCTL_W} net.inet6.ip6.forwarding=1 > /dev/null
+ else
+ ${SYSCTL_W} net.inet6.ip6.forwarding=0 > /dev/null
fi
+}
- [ -n "${_ropts_initdone}" ] && echo '.'
+options_ipx()
+{
+ if checkyesno ipxgateway_enable; then
+ ropts_init
+ echo -n ' IPX gateway=YES'
+ ${SYSCTL_W} net.ipx.ipx.ipxforwarding=1 > /dev/null
+ else
+ ${SYSCTL_W} net.ipx.ipx.ipxforwarding=0 > /dev/null
+ fi
}
load_rc_config $name
OpenPOWER on IntegriCloud