xref: /freebsd/libexec/rc/rc.d/routing (revision f99f0ee14e3af81c23150a6a340259ca8a33d01a)
10696600cSBjoern A. Zeeb#!/bin/sh
20696600cSBjoern A. Zeeb#
30696600cSBjoern A. Zeeb# Configure routing and miscellaneous network tunables
40696600cSBjoern A. Zeeb#
50696600cSBjoern A. Zeeb#
60696600cSBjoern A. Zeeb
70696600cSBjoern A. Zeeb# PROVIDE: routing
80696600cSBjoern A. Zeeb# REQUIRE: netif ppp stf
90696600cSBjoern A. Zeeb# KEYWORD: nojailvnet
100696600cSBjoern A. Zeeb
110696600cSBjoern A. Zeeb. /etc/rc.subr
120696600cSBjoern A. Zeeb. /etc/network.subr
130696600cSBjoern A. Zeeb
140696600cSBjoern A. Zeebname="routing"
150696600cSBjoern A. Zeebdesc="Routing setup"
160696600cSBjoern A. Zeebstart_cmd="routing_start doall"
170696600cSBjoern A. Zeebstop_cmd="routing_stop"
180696600cSBjoern A. Zeebextra_commands="options static"
190696600cSBjoern A. Zeebstatic_cmd="routing_start static"
200696600cSBjoern A. Zeeboptions_cmd="routing_start options"
210696600cSBjoern A. Zeeb
220696600cSBjoern A. ZeebROUTE_CMD="/sbin/route"
230696600cSBjoern A. Zeeb
240696600cSBjoern A. Zeebrouting_start()
250696600cSBjoern A. Zeeb{
260696600cSBjoern A. Zeeb	local _cmd _af _if _a _ret
270696600cSBjoern A. Zeeb	_cmd=$1
280696600cSBjoern A. Zeeb	_af=$2
290696600cSBjoern A. Zeeb	_if=$3
300696600cSBjoern A. Zeeb	_ret=0
310696600cSBjoern A. Zeeb
320696600cSBjoern A. Zeeb	case $_if in
330696600cSBjoern A. Zeeb	""|[Aa][Ll][Ll]|[Aa][Nn][Yy])	_if="" ;;
340696600cSBjoern A. Zeeb	esac
350696600cSBjoern A. Zeeb
360696600cSBjoern A. Zeeb	case $_af in
370696600cSBjoern A. Zeeb	""|[Aa][Ll][Ll]|[Aa][Nn][Yy])
380696600cSBjoern A. Zeeb		for _a in inet inet6; do
390696600cSBjoern A. Zeeb			afexists $_a || continue
400696600cSBjoern A. Zeeb			setroutes $_cmd $_a $_if || _ret=1
410696600cSBjoern A. Zeeb		done
420696600cSBjoern A. Zeeb	;;
430696600cSBjoern A. Zeeb	*)
440696600cSBjoern A. Zeeb		if afexists $_af; then
450696600cSBjoern A. Zeeb			setroutes $_cmd $_af $_if || _ret=1
460696600cSBjoern A. Zeeb		else
470696600cSBjoern A. Zeeb			err 1 "Unsupported address family: $_af."
480696600cSBjoern A. Zeeb		fi
490696600cSBjoern A. Zeeb	;;
500696600cSBjoern A. Zeeb	esac
510696600cSBjoern A. Zeeb
520696600cSBjoern A. Zeeb	return $_ret
530696600cSBjoern A. Zeeb}
540696600cSBjoern A. Zeeb
550696600cSBjoern A. Zeebrouting_stop()
560696600cSBjoern A. Zeeb{
570696600cSBjoern A. Zeeb	local _af _if _a
580696600cSBjoern A. Zeeb	_af=$1
590696600cSBjoern A. Zeeb	_if=$2
600696600cSBjoern A. Zeeb
610696600cSBjoern A. Zeeb	case $_if in
620696600cSBjoern A. Zeeb	""|[Aa][Ll][Ll]|[Aa][Nn][Yy])	_if="" ;;
630696600cSBjoern A. Zeeb	esac
640696600cSBjoern A. Zeeb
650696600cSBjoern A. Zeeb	case $_af in
660696600cSBjoern A. Zeeb	""|[Aa][Ll][Ll]|[Aa][Nn][Yy])
670696600cSBjoern A. Zeeb		for _a in inet inet6; do
680696600cSBjoern A. Zeeb			afexists $_a || continue
690696600cSBjoern A. Zeeb			eval static_${_a} delete $_if
700696600cSBjoern A. Zeeb			# When $_if is specified, do not flush routes.
710696600cSBjoern A. Zeeb			if ! [ -n "$_if" ]; then
720696600cSBjoern A. Zeeb				eval routing_stop_${_a}
730696600cSBjoern A. Zeeb			fi
740696600cSBjoern A. Zeeb		done
750696600cSBjoern A. Zeeb	;;
760696600cSBjoern A. Zeeb	*)
770696600cSBjoern A. Zeeb		if afexists $_af; then
780696600cSBjoern A. Zeeb			eval static_${_af} delete $_if
790696600cSBjoern A. Zeeb			# When $_if is specified, do not flush routes.
800696600cSBjoern A. Zeeb			if ! [ -n "$_if" ]; then
810696600cSBjoern A. Zeeb				eval routing_stop_${_af}
820696600cSBjoern A. Zeeb			fi
830696600cSBjoern A. Zeeb		else
840696600cSBjoern A. Zeeb			err 1 "Unsupported address family: $_af."
850696600cSBjoern A. Zeeb		fi
860696600cSBjoern A. Zeeb	;;
870696600cSBjoern A. Zeeb	esac
880696600cSBjoern A. Zeeb}
890696600cSBjoern A. Zeeb
900696600cSBjoern A. Zeebsetroutes()
910696600cSBjoern A. Zeeb{
920696600cSBjoern A. Zeeb	local _ret
930696600cSBjoern A. Zeeb	_ret=0
940696600cSBjoern A. Zeeb	case $1 in
950696600cSBjoern A. Zeeb	static)
960696600cSBjoern A. Zeeb		static_$2 add $3
970696600cSBjoern A. Zeeb		_ret=$?
980696600cSBjoern A. Zeeb		;;
990696600cSBjoern A. Zeeb	options)
1000696600cSBjoern A. Zeeb		options_$2
1010696600cSBjoern A. Zeeb		;;
1020696600cSBjoern A. Zeeb	doall)
1030696600cSBjoern A. Zeeb		static_$2 add $3
1040696600cSBjoern A. Zeeb		_ret=$?
1050696600cSBjoern A. Zeeb		options_$2
1060696600cSBjoern A. Zeeb		;;
1070696600cSBjoern A. Zeeb	esac
1080696600cSBjoern A. Zeeb	return $_ret
1090696600cSBjoern A. Zeeb}
1100696600cSBjoern A. Zeeb
1110696600cSBjoern A. Zeebrouting_stop_inet()
1120696600cSBjoern A. Zeeb{
1130696600cSBjoern A. Zeeb	${ROUTE_CMD} -n flush -inet
1140696600cSBjoern A. Zeeb}
1150696600cSBjoern A. Zeeb
1160696600cSBjoern A. Zeebrouting_stop_inet6()
1170696600cSBjoern A. Zeeb{
1180696600cSBjoern A. Zeeb	local i
1190696600cSBjoern A. Zeeb
1200696600cSBjoern A. Zeeb	${ROUTE_CMD} -n flush -inet6
1210696600cSBjoern A. Zeeb	for i in `list_net_interfaces`; do
1220696600cSBjoern A. Zeeb		if ipv6if $i; then
1230696600cSBjoern A. Zeeb			ifconfig $i inet6 -defaultif
1240696600cSBjoern A. Zeeb		fi
1250696600cSBjoern A. Zeeb	done
1260696600cSBjoern A. Zeeb}
1270696600cSBjoern A. Zeeb
1280696600cSBjoern A. Zeebget_fibmod()
1290696600cSBjoern A. Zeeb{
1300696600cSBjoern A. Zeeb	local _fibs
1310696600cSBjoern A. Zeeb
1320696600cSBjoern A. Zeeb	_fibs=$((`${SYSCTL_N} net.fibs` - 1))
1330696600cSBjoern A. Zeeb	if [ ${_fibs} -gt 0 ]; then
1340696600cSBjoern A. Zeeb		echo "-fib 0-${_fibs}"
1350696600cSBjoern A. Zeeb	else
1360696600cSBjoern A. Zeeb		echo
1370696600cSBjoern A. Zeeb	fi
1380696600cSBjoern A. Zeeb}
1390696600cSBjoern A. Zeeb
1400696600cSBjoern A. Zeebstatic_inet()
1410696600cSBjoern A. Zeeb{
14230659d1dSAndrew Fengler	local _action _if _skip _fibmod _fibs
1430696600cSBjoern A. Zeeb	_action=$1
1440696600cSBjoern A. Zeeb	_if=$2
1450696600cSBjoern A. Zeeb
1460696600cSBjoern A. Zeeb	_fibmod=`get_fibmod`
14730659d1dSAndrew Fengler	_fibs=$((`${SYSCTL_N} net.fibs` - 1))
1480696600cSBjoern A. Zeeb
1490696600cSBjoern A. Zeeb	# Provide loopback route in all routing tables.  This has to come
1500696600cSBjoern A. Zeeb	# first so that any following routes can be added.
1510696600cSBjoern A. Zeeb	static_routes="_loopback ${static_routes}"
1520696600cSBjoern A. Zeeb	route__loopback="-inet 127.0.0.1 -iface lo0 ${_fibmod}"
1530696600cSBjoern A. Zeeb
1540696600cSBjoern A. Zeeb	# Add default route.
1550696600cSBjoern A. Zeeb	case ${defaultrouter} in
1560696600cSBjoern A. Zeeb	[Nn][Oo] | '')
1570696600cSBjoern A. Zeeb		;;
1580696600cSBjoern A. Zeeb	*)
1590696600cSBjoern A. Zeeb		static_routes="${static_routes} _default"
1600696600cSBjoern A. Zeeb		route__default="default ${defaultrouter}"
1610696600cSBjoern A. Zeeb		;;
1620696600cSBjoern A. Zeeb	esac
1630696600cSBjoern A. Zeeb
16430659d1dSAndrew Fengler	# Add default routes for fibs
16530659d1dSAndrew Fengler	if [ ${_fibs} -gt 0 ]; then
16630659d1dSAndrew Fengler		for _fibnum in `jot ${_fibs}` ; do
16730659d1dSAndrew Fengler			eval _fib_gw=\${defaultrouter_fib${_fibnum}}
16830659d1dSAndrew Fengler			case ${_fib_gw} in
16930659d1dSAndrew Fengler			[Nn][Oo] | '')
17030659d1dSAndrew Fengler				;;
17130659d1dSAndrew Fengler			*)
17230659d1dSAndrew Fengler				static_routes="${static_routes} _default_fib${_fibnum}"
173f81be7a8SAndrew Fengler				eval route__default_fib${_fibnum}="'default ${_fib_gw} -fib ${_fibnum}'"
17430659d1dSAndrew Fengler				;;
17530659d1dSAndrew Fengler			esac
17630659d1dSAndrew Fengler		done
17730659d1dSAndrew Fengler	fi
17830659d1dSAndrew Fengler
17930659d1dSAndrew Fengler
1800696600cSBjoern A. Zeeb	# Install configured routes.
1810696600cSBjoern A. Zeeb	if [ -n "${static_routes}" ]; then
1820696600cSBjoern A. Zeeb		for i in ${static_routes}; do
1830696600cSBjoern A. Zeeb			_skip=0
1840696600cSBjoern A. Zeeb			if [ -n "$_if" ]; then
1850696600cSBjoern A. Zeeb				case $i in
1860696600cSBjoern A. Zeeb				*:$_if)	;;
1870696600cSBjoern A. Zeeb				*)	_skip=1 ;;
1880696600cSBjoern A. Zeeb				esac
1890696600cSBjoern A. Zeeb			fi
1900696600cSBjoern A. Zeeb			if [ $_skip = 0 ]; then
1910696600cSBjoern A. Zeeb				route_args=`get_if_var ${i%:*} route_IF`
1920696600cSBjoern A. Zeeb				if [ -n "$route_args" ]; then
1930696600cSBjoern A. Zeeb					${ROUTE_CMD} ${_action} ${route_args}
1940696600cSBjoern A. Zeeb				else
1950696600cSBjoern A. Zeeb					warn "route_${i%:*} not found."
1960696600cSBjoern A. Zeeb				fi
1970696600cSBjoern A. Zeeb			fi
1980696600cSBjoern A. Zeeb		done
1990696600cSBjoern A. Zeeb	fi
2000696600cSBjoern A. Zeeb}
2010696600cSBjoern A. Zeeb
2020696600cSBjoern A. Zeebstatic_inet6()
2030696600cSBjoern A. Zeeb{
20430659d1dSAndrew Fengler	local _action _if _skip fibmod _fibs
2050696600cSBjoern A. Zeeb	_action=$1
2060696600cSBjoern A. Zeeb	_if=$2
2070696600cSBjoern A. Zeeb
2080696600cSBjoern A. Zeeb	fibmod=`get_fibmod`
20930659d1dSAndrew Fengler	_fibs=$((`${SYSCTL_N} net.fibs` - 1))
2100696600cSBjoern A. Zeeb
2110696600cSBjoern A. Zeeb	# Add pre-defined static routes first.
2120696600cSBjoern A. Zeeb	ipv6_static_routes="_v4mapped _v4compat ${ipv6_static_routes}"
2130696600cSBjoern A. Zeeb	ipv6_static_routes="_lla _llma ${ipv6_static_routes}"
2140696600cSBjoern A. Zeeb	ipv6_static_routes="_loopback ${ipv6_static_routes}"
2150696600cSBjoern A. Zeeb
2160696600cSBjoern A. Zeeb	# disallow "internal" addresses to appear on the wire
2170696600cSBjoern A. Zeeb	ipv6_route__v4mapped="::ffff:0.0.0.0 -prefixlen 96 ::1 -reject ${fibmod}"
2180696600cSBjoern A. Zeeb	ipv6_route__v4compat="::0.0.0.0 -prefixlen 96 ::1 -reject ${fibmod}"
2190696600cSBjoern A. Zeeb
2200696600cSBjoern A. Zeeb	# Create a loopback route in every fib
2210696600cSBjoern A. Zeeb	ipv6_route__loopback="::1 -prefixlen 128 -iface lo0 ${fibmod}"
2220696600cSBjoern A. Zeeb
2230696600cSBjoern A. Zeeb	# Disallow link-local unicast packets without outgoing scope
2240696600cSBjoern A. Zeeb	# identifiers.  However, if you set "ipv6_default_interface",
2250696600cSBjoern A. Zeeb	# for the host case, you will allow to omit the identifiers.
2260696600cSBjoern A. Zeeb	# Under this configuration, the packets will go to the default
2270696600cSBjoern A. Zeeb	# interface.
2280696600cSBjoern A. Zeeb	ipv6_route__lla="fe80:: -prefixlen 10 ::1 -reject ${fibmod}"
2290696600cSBjoern A. Zeeb	ipv6_route__llma="ff02:: -prefixlen 16 ::1 -reject ${fibmod}"
2300696600cSBjoern A. Zeeb
2310696600cSBjoern A. Zeeb	# Add default route.
2320696600cSBjoern A. Zeeb	case ${ipv6_defaultrouter} in
2330696600cSBjoern A. Zeeb	[Nn][Oo] | '')
2340696600cSBjoern A. Zeeb		;;
2350696600cSBjoern A. Zeeb	*)
2360696600cSBjoern A. Zeeb		ipv6_static_routes="${ipv6_static_routes} _default"
2370696600cSBjoern A. Zeeb		ipv6_route__default="default ${ipv6_defaultrouter}"
2380696600cSBjoern A. Zeeb		;;
2390696600cSBjoern A. Zeeb	esac
2400696600cSBjoern A. Zeeb
24130659d1dSAndrew Fengler	# Add default routes for fibs
24230659d1dSAndrew Fengler	if [ ${_fibs} -gt 0 ]; then
24330659d1dSAndrew Fengler		for _fibnum in `jot ${_fibs}` ; do
24430659d1dSAndrew Fengler			eval _fib_gw=\${ipv6_defaultrouter_fib${_fibnum}}
24530659d1dSAndrew Fengler			case ${_fib_gw} in
24630659d1dSAndrew Fengler			[Nn][Oo] | '')
24730659d1dSAndrew Fengler				;;
24830659d1dSAndrew Fengler			*)
249f81be7a8SAndrew Fengler				ipv6_static_routes="${ipv6_static_routes} _default_fib${_fibnum}"
250f81be7a8SAndrew Fengler				eval ipv6_route__default_fib${_fibnum}="'default ${_fib_gw} -fib ${_fibnum}'"
25130659d1dSAndrew Fengler				;;
25230659d1dSAndrew Fengler			esac
25330659d1dSAndrew Fengler		done
25430659d1dSAndrew Fengler	fi
25530659d1dSAndrew Fengler
25630659d1dSAndrew Fengler
2570696600cSBjoern A. Zeeb	# Install configured routes.
2580696600cSBjoern A. Zeeb	if [ -n "${ipv6_static_routes}" ]; then
2590696600cSBjoern A. Zeeb		for i in ${ipv6_static_routes}; do
2600696600cSBjoern A. Zeeb			_skip=0
2610696600cSBjoern A. Zeeb			if [ -n "$_if" ]; then
2620696600cSBjoern A. Zeeb				case $i in
2630696600cSBjoern A. Zeeb				*:$_if)	;;
2640696600cSBjoern A. Zeeb				*)	_skip=1 ;;
2650696600cSBjoern A. Zeeb				esac
2660696600cSBjoern A. Zeeb			fi
2670696600cSBjoern A. Zeeb			if [ $_skip = 0 ]; then
2680696600cSBjoern A. Zeeb				ipv6_route_args=`get_if_var ${i%:*} ipv6_route_IF`
2690696600cSBjoern A. Zeeb				if [ -n "$ipv6_route_args" ]; then
2700696600cSBjoern A. Zeeb					${ROUTE_CMD} ${_action} \
2710696600cSBjoern A. Zeeb						-inet6 ${ipv6_route_args}
2720696600cSBjoern A. Zeeb				else
2730696600cSBjoern A. Zeeb					warn "route_${i%:*} not found"
2740696600cSBjoern A. Zeeb				fi
2750696600cSBjoern A. Zeeb			fi
2760696600cSBjoern A. Zeeb		done
2770696600cSBjoern A. Zeeb	fi
2780696600cSBjoern A. Zeeb
2790696600cSBjoern A. Zeeb	# Install the "default interface" to kernel, which will be used
2800696600cSBjoern A. Zeeb	# as the default route when there's no router.
2810696600cSBjoern A. Zeeb
2820696600cSBjoern A. Zeeb	# Disable installing the default interface when we act
2830696600cSBjoern A. Zeeb	# as router to avoid conflict between the default
2840696600cSBjoern A. Zeeb	# router list and the manual configured default route.
2850696600cSBjoern A. Zeeb	if checkyesno ipv6_gateway_enable; then
2860696600cSBjoern A. Zeeb		return
2870696600cSBjoern A. Zeeb	fi
2880696600cSBjoern A. Zeeb
2890696600cSBjoern A. Zeeb	case "${ipv6_default_interface}" in
2900696600cSBjoern A. Zeeb	[Nn][Oo] | [Nn][Oo][Nn][Ee])
2910696600cSBjoern A. Zeeb		return
2920696600cSBjoern A. Zeeb		;;
2930696600cSBjoern A. Zeeb	[Aa][Uu][Tt][Oo] | "")
2940696600cSBjoern A. Zeeb		for i in ${ipv6_network_interfaces}; do
2950696600cSBjoern A. Zeeb			case $i in
2960696600cSBjoern A. Zeeb			[Nn][Oo][Nn][Ee])
2970696600cSBjoern A. Zeeb				return
2980696600cSBjoern A. Zeeb				;;
2990696600cSBjoern A. Zeeb			lo0)
3000696600cSBjoern A. Zeeb				continue
3010696600cSBjoern A. Zeeb				;;
3020696600cSBjoern A. Zeeb			esac
3030696600cSBjoern A. Zeeb			laddr=`network6_getladdr $i exclude_tentative`
3040696600cSBjoern A. Zeeb			case ${laddr} in
3050696600cSBjoern A. Zeeb			'')
3060696600cSBjoern A. Zeeb				;;
3070696600cSBjoern A. Zeeb			*)
3080696600cSBjoern A. Zeeb				ipv6_default_interface=$i
3090696600cSBjoern A. Zeeb				break
3100696600cSBjoern A. Zeeb				;;
3110696600cSBjoern A. Zeeb			esac
3120696600cSBjoern A. Zeeb		done
3130696600cSBjoern A. Zeeb		;;
3140696600cSBjoern A. Zeeb	esac
3150696600cSBjoern A. Zeeb
3160696600cSBjoern A. Zeeb	ifconfig ${ipv6_default_interface} inet6 defaultif
3170696600cSBjoern A. Zeeb	${SYSCTL} net.inet6.ip6.use_defaultzone=1 > /dev/null
3180696600cSBjoern A. Zeeb}
3190696600cSBjoern A. Zeeb
3200696600cSBjoern A. Zeebropts_init()
3210696600cSBjoern A. Zeeb{
3220696600cSBjoern A. Zeeb	if [ -z "${_ropts_initdone}" ]; then
3230696600cSBjoern A. Zeeb		echo -n "Additional $1 routing options:"
3240696600cSBjoern A. Zeeb		_ropts_initdone=yes
3250696600cSBjoern A. Zeeb	fi
3260696600cSBjoern A. Zeeb}
3270696600cSBjoern A. Zeeb
3287119cdc2SAlexander V. Chernikov_check_dynamicrouting()
3297119cdc2SAlexander V. Chernikov{
3307119cdc2SAlexander V. Chernikov	local skip file name rcvar
3317119cdc2SAlexander V. Chernikov
3327119cdc2SAlexander V. Chernikov	# copied from /etc/rc
3337119cdc2SAlexander V. Chernikov	skip="-s nostart"
3347119cdc2SAlexander V. Chernikov	if [ `/sbin/sysctl -n security.jail.jailed` -eq 1 ]; then
3357119cdc2SAlexander V. Chernikov		skip="$skip -s nojail"
3367119cdc2SAlexander V. Chernikov	fi
3377119cdc2SAlexander V. Chernikov	[ -n "$local_startup" ] && find_local_scripts_new
338f55ef857SBrooks Davis	[ -n "$system_rc" ] && find_system_scripts
3397119cdc2SAlexander V. Chernikov
340f55ef857SBrooks Davis	for file in $( rcorder ${skip} ${system_rc} ${local_rc} 2>/dev/null |
3417119cdc2SAlexander V. Chernikov		       xargs grep -lE '^# PROVIDE:.*\<dynamicrouting\>' ); do
3427119cdc2SAlexander V. Chernikov		(set -- enabled; . $file) && return 0;
3437119cdc2SAlexander V. Chernikov	done
3447119cdc2SAlexander V. Chernikov
3457119cdc2SAlexander V. Chernikov	return 1
3467119cdc2SAlexander V. Chernikov}
3477119cdc2SAlexander V. Chernikov
3480696600cSBjoern A. Zeeboptions_inet()
3490696600cSBjoern A. Zeeb{
3507119cdc2SAlexander V. Chernikov	local _icmp_drop_redirect
3517119cdc2SAlexander V. Chernikov
3520696600cSBjoern A. Zeeb	_ropts_initdone=
3530696600cSBjoern A. Zeeb	if checkyesno icmp_bmcastecho; then
3540696600cSBjoern A. Zeeb		ropts_init inet
3550696600cSBjoern A. Zeeb		echo -n ' broadcast ping responses=YES'
3560696600cSBjoern A. Zeeb		${SYSCTL} net.inet.icmp.bmcastecho=1 > /dev/null
3570696600cSBjoern A. Zeeb	else
3580696600cSBjoern A. Zeeb		${SYSCTL} net.inet.icmp.bmcastecho=0 > /dev/null
3590696600cSBjoern A. Zeeb	fi
3600696600cSBjoern A. Zeeb
3617119cdc2SAlexander V. Chernikov	_icmp_drop_redirect="${icmp_drop_redirect}"
3627119cdc2SAlexander V. Chernikov	case "${_icmp_drop_redirect}" in
3637119cdc2SAlexander V. Chernikov	[Aa][Uu][Tt][Oo] | "")
3647119cdc2SAlexander V. Chernikov		if _check_dynamicrouting; then
3657119cdc2SAlexander V. Chernikov			_icmp_drop_redirect="yes"
3667119cdc2SAlexander V. Chernikov		else
3677119cdc2SAlexander V. Chernikov			_icmp_drop_redirect="no"
3687119cdc2SAlexander V. Chernikov		fi
3697119cdc2SAlexander V. Chernikov		;;
3707119cdc2SAlexander V. Chernikov	esac
3717119cdc2SAlexander V. Chernikov	if checkyesno _icmp_drop_redirect; then
3720696600cSBjoern A. Zeeb		ropts_init inet
3730696600cSBjoern A. Zeeb		echo -n ' ignore ICMP redirect=YES'
3740696600cSBjoern A. Zeeb		${SYSCTL} net.inet.icmp.drop_redirect=1 > /dev/null
3750696600cSBjoern A. Zeeb	else
3760696600cSBjoern A. Zeeb		${SYSCTL} net.inet.icmp.drop_redirect=0 > /dev/null
3770696600cSBjoern A. Zeeb	fi
3780696600cSBjoern A. Zeeb
3790696600cSBjoern A. Zeeb	if checkyesno icmp_log_redirect; then
3800696600cSBjoern A. Zeeb		ropts_init inet
3810696600cSBjoern A. Zeeb		echo -n ' log ICMP redirect=YES'
3820696600cSBjoern A. Zeeb		${SYSCTL} net.inet.icmp.log_redirect=1 > /dev/null
3830696600cSBjoern A. Zeeb	else
3840696600cSBjoern A. Zeeb		${SYSCTL} net.inet.icmp.log_redirect=0 > /dev/null
3850696600cSBjoern A. Zeeb	fi
3860696600cSBjoern A. Zeeb
3870696600cSBjoern A. Zeeb	if checkyesno gateway_enable; then
3880696600cSBjoern A. Zeeb		ropts_init inet
3890696600cSBjoern A. Zeeb		echo -n ' gateway=YES'
3900696600cSBjoern A. Zeeb		${SYSCTL} net.inet.ip.forwarding=1 > /dev/null
3910696600cSBjoern A. Zeeb	else
3920696600cSBjoern A. Zeeb		${SYSCTL} net.inet.ip.forwarding=0 > /dev/null
3930696600cSBjoern A. Zeeb	fi
3940696600cSBjoern A. Zeeb
3950696600cSBjoern A. Zeeb	if checkyesno forward_sourceroute; then
3960696600cSBjoern A. Zeeb		ropts_init inet
3970696600cSBjoern A. Zeeb		echo -n ' do source routing=YES'
3980696600cSBjoern A. Zeeb		${SYSCTL} net.inet.ip.sourceroute=1 > /dev/null
3990696600cSBjoern A. Zeeb	else
4000696600cSBjoern A. Zeeb		${SYSCTL} net.inet.ip.sourceroute=0 > /dev/null
4010696600cSBjoern A. Zeeb	fi
4020696600cSBjoern A. Zeeb
4030696600cSBjoern A. Zeeb	if checkyesno accept_sourceroute; then
4040696600cSBjoern A. Zeeb		ropts_init inet
4050696600cSBjoern A. Zeeb		echo -n ' accept source routing=YES'
4060696600cSBjoern A. Zeeb		${SYSCTL} net.inet.ip.accept_sourceroute=1 > /dev/null
4070696600cSBjoern A. Zeeb	else
4080696600cSBjoern A. Zeeb		${SYSCTL} net.inet.ip.accept_sourceroute=0 > /dev/null
4090696600cSBjoern A. Zeeb	fi
4100696600cSBjoern A. Zeeb
4110696600cSBjoern A. Zeeb	if checkyesno arpproxy_all; then
4120696600cSBjoern A. Zeeb		ropts_init inet
4130696600cSBjoern A. Zeeb		echo -n ' ARP proxyall=YES'
4140696600cSBjoern A. Zeeb		${SYSCTL} net.link.ether.inet.proxyall=1 > /dev/null
4150696600cSBjoern A. Zeeb	else
4160696600cSBjoern A. Zeeb		${SYSCTL} net.link.ether.inet.proxyall=0 > /dev/null
4170696600cSBjoern A. Zeeb	fi
4180696600cSBjoern A. Zeeb
4190696600cSBjoern A. Zeeb	[ -n "${_ropts_initdone}" ] && echo '.'
4200696600cSBjoern A. Zeeb}
4210696600cSBjoern A. Zeeb
4220696600cSBjoern A. Zeeboptions_inet6()
4230696600cSBjoern A. Zeeb{
4240696600cSBjoern A. Zeeb	_ropts_initdone=
4250696600cSBjoern A. Zeeb
4260696600cSBjoern A. Zeeb	if checkyesno ipv6_gateway_enable; then
4270696600cSBjoern A. Zeeb		ropts_init inet6
4280696600cSBjoern A. Zeeb		echo -n ' gateway=YES'
4290696600cSBjoern A. Zeeb		${SYSCTL} net.inet6.ip6.forwarding=1 > /dev/null
4300696600cSBjoern A. Zeeb	else
4310696600cSBjoern A. Zeeb		${SYSCTL} net.inet6.ip6.forwarding=0 > /dev/null
4320696600cSBjoern A. Zeeb	fi
4330696600cSBjoern A. Zeeb
4340696600cSBjoern A. Zeeb	[ -n "${_ropts_initdone}" ] && echo '.'
4350696600cSBjoern A. Zeeb}
4360696600cSBjoern A. Zeeb
4370696600cSBjoern A. Zeebload_rc_config $name
438*f99f0ee1SAlexander Leidinger
439*f99f0ee1SAlexander Leidinger# doesn't make sense to run in a svcj: config setting
440*f99f0ee1SAlexander Leidingerrouting_svcj="NO"
441*f99f0ee1SAlexander Leidinger
4420696600cSBjoern A. Zeebrun_rc_command "$@"
443