summaryrefslogtreecommitdiffstats
path: root/etc/rc.d
diff options
context:
space:
mode:
authorasomers <asomers@FreeBSD.org>2016-05-27 22:40:40 +0000
committerasomers <asomers@FreeBSD.org>2016-05-27 22:40:40 +0000
commit6ee222024200d765a4edfcb4b56cd92bb23695a6 (patch)
tree124891ce998f33a0d677a11ee5af0dfb8c273fe1 /etc/rc.d
parent6836baf662813f5f6bc11a32238e3f6a6fb3680e (diff)
downloadFreeBSD-src-6ee222024200d765a4edfcb4b56cd92bb23695a6.zip
FreeBSD-src-6ee222024200d765a4edfcb4b56cd92bb23695a6.tar.gz
Always create loopback routes on every fib
Always create loopback routes on every fib, for both IPv4 and IPv6 etc/rc.d/routing Create loopback IPv4 and IPv6 routes on every fib at boot. Revert 278302; now that all FIBs have IPv6 loopback routes, the "route add -reject" commands won't fail. tests/etc/rc.d/routing_test.sh Greatly simplify static_ipv6_loopback_route_for_each_fib. It was written under the assumption that loopback routes would be added to a given fib by the kernel as soon as an interface is configured on that fib. However, the logic can be much simpler now that we simply add loopback routes to all fibs at boot. This also removes the need to run the test as root, removes the restriction that net.add_addr_allfibs=0, and removes the need to configure fibs in kyua.conf. Also, add a test case for IPv4 loopback routes Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D6582
Diffstat (limited to 'etc/rc.d')
-rwxr-xr-xetc/rc.d/routing36
1 files changed, 26 insertions, 10 deletions
diff --git a/etc/rc.d/routing b/etc/rc.d/routing
index 5924486..3d3f5a5 100755
--- a/etc/rc.d/routing
+++ b/etc/rc.d/routing
@@ -126,12 +126,31 @@ routing_stop_atm()
return 0
}
+get_fibmod()
+{
+ local _fibs
+
+ _fibs=$((`${SYSCTL_N} net.fibs` - 1))
+ if [ ${_fibs} -gt 0 ]; then
+ echo "-fib 0-${_fibs}"
+ else
+ echo
+ fi
+}
+
static_inet()
{
- local _action _if _skip
+ local _action _if _skip _fibmod
_action=$1
_if=$2
+ _fibmod=`get_fibmod`
+
+ # Provide loopback route in all routing tables. This has to come
+ # first so that any following routes can be added.
+ static_routes="_loopback ${static_routes}"
+ route__loopback="-inet 127.0.0.1 -iface lo0 ${_fibmod}"
+
# Add default route.
case ${defaultrouter} in
[Nn][Oo] | '')
@@ -166,27 +185,24 @@ static_inet()
static_inet6()
{
- local _action _if _skip fibmod fibs allfibs
+ local _action _if _skip fibmod allfibs
_action=$1
_if=$2
- # get the number of FIBs supported.
- fibs=$((`${SYSCTL_N} net.fibs` - 1))
- allfibs=`${SYSCTL_N} net.add_addr_allfibs`
- if [ "$fibs" -gt 0 ] && [ "$allfibs" -ne 0 ]; then
- fibmod="-fib 0-$fibs"
- else
- fibmod=
- fi
+ fibmod=`get_fibmod`
# Add pre-defined static routes first.
ipv6_static_routes="_v4mapped _v4compat ${ipv6_static_routes}"
ipv6_static_routes="_lla _llma ${ipv6_static_routes}"
+ ipv6_static_routes="_loopback ${ipv6_static_routes}"
# disallow "internal" addresses to appear on the wire
ipv6_route__v4mapped="::ffff:0.0.0.0 -prefixlen 96 ::1 -reject ${fibmod}"
ipv6_route__v4compat="::0.0.0.0 -prefixlen 96 ::1 -reject ${fibmod}"
+ # Create a loopback route in every fib
+ ipv6_route__loopback="::1 -prefixlen 128 -iface lo0 ${fibmod}"
+
# Disallow link-local unicast packets without outgoing scope
# identifiers. However, if you set "ipv6_default_interface",
# for the host case, you will allow to omit the identifiers.
OpenPOWER on IntegriCloud