]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - etc/rc.d/network_ipv6
MFC r231852,232127:
[FreeBSD/stable/8.git] / etc / rc.d / network_ipv6
1 #!/bin/sh
2 #
3 # Copyright (c) 2000  The KAME Project
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 #    notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 #    notice, this list of conditions and the following disclaimer in the
13 #    documentation and/or other materials provided with the distribution.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 # SUCH DAMAGE.
26 #
27 # $FreeBSD$
28 #       From: src/etc/rc.network6,v 1.29 2002/04/06 15:15:43
29 #
30
31 # PROVIDE: network_ipv6
32 # REQUIRE: routing
33 # KEYWORD: nojail
34
35 . /etc/rc.subr
36 . /etc/network.subr
37
38 name="network_ipv6"
39 rcvar="ipv6_enable"
40 start_cmd="network_ipv6_start"
41
42 network_ipv6_start()
43 {
44
45         case ${ipv6_network_interfaces} in
46         [Aa][Uu][Tt][Oo])
47                 # Get a list of network interfaces
48                 ipv6_network_interfaces="`ifconfig -l`"
49                 ;;
50         [Nn][Oo][Nn][Ee])
51                 ipv6_network_interfaces=''
52                 ;;
53         esac
54
55         if checkyesno ipv6_gateway_enable; then
56                 # act as a router
57                 ${SYSCTL_W} net.inet6.ip6.forwarding=1
58                 ${SYSCTL_W} net.inet6.ip6.accept_rtadv=0
59
60                 # wait for DAD
61                 for i in $ipv6_network_interfaces; do
62                         ifconfig $i up
63                 done
64                 sleep `${SYSCTL_N} net.inet6.ip6.dad_count`
65                 sleep 1
66         else
67                 # act as endhost - start with manual configuration
68                 # Setup of net.inet6.ip6.accept_rtadv is done later by
69                 # network6_interface_setup.
70                 ${SYSCTL_W} net.inet6.ip6.forwarding=0
71         fi
72
73         if [ -n "${ipv6_network_interfaces}" ]; then
74                 # Setup the interfaces
75                 network6_interface_setup $ipv6_network_interfaces
76
77                 # wait for DAD's completion (for global addrs)
78                 sleep `${SYSCTL_N} net.inet6.ip6.dad_count`
79                 sleep 1
80         fi
81
82         # Filter out interfaces on which IPv6 initialization failed.
83         if checkyesno ipv6_gateway_enable; then
84                 ipv6_working_interfaces=""
85                 for i in ${ipv6_network_interfaces}; do
86                         laddr=`network6_getladdr $i exclude_tentative`
87                         case ${laddr} in
88                         '')
89                                 ;;
90                         *)
91                                 ipv6_working_interfaces="$i \
92                                     ${ipv6_working_interfaces}"
93                                 ;;
94                         esac
95                 done
96                 ipv6_network_interfaces=${ipv6_working_interfaces}
97         fi
98
99         # Setup IPv6 to IPv4 mapping
100         network6_stf_setup
101
102         # Install the "default interface" to kernel, which will be used
103         # as the default route when there's no router.
104         network6_default_interface_setup
105
106         # Setup static routes
107         network6_static_routes_setup
108
109         # Setup faith
110         network6_faith_setup
111
112         # Support for IPv4 address tacked onto an IPv6 address
113         if checkyesno ipv6_ipv4mapping; then
114                 echo 'IPv4 mapped IPv6 address support=YES'
115                 ${SYSCTL_W} net.inet6.ip6.v6only=0 >/dev/null
116         else
117                 echo 'IPv4 mapped IPv6 address support=NO'
118                 ${SYSCTL_W} net.inet6.ip6.v6only=1 >/dev/null
119         fi
120 }
121
122 load_rc_config $name
123 run_rc_command "$1"