kernel - Fix issue w/ buffer ortation when doing non-blocking read from bpf
[dragonfly.git] / etc / rc.d / network_ipv6
blobaf5e7193e709ae8b5b4772c7748f3ea08001a4f1
1 #!/bin/sh
3 # Copyright (c) 2000 The KAME Project
4 # All rights reserved.
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.
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.
27 # $FreeBSD: src/etc/rc.d/network_ipv6,v 1.35 2003/06/29 05:15:57 mtm Exp $
28 # From: src/etc/rc.network6,v 1.29 2002/04/06 15:15:43
29 # $DragonFly: src/etc/rc.d/network_ipv6,v 1.3 2005/11/19 21:47:32 swildner Exp $
32 # PROVIDE: network_ipv6
33 # REQUIRE: routing
35 . /etc/rc.subr
36 . /etc/network.subr
38 name="network_ipv6"
39 rcvar=`set_rcvar ipv6`
40 start_cmd="network_ipv6_start"
42 network_ipv6_start()
44 # disallow "internal" addresses to appear on the wire
45 route add -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject
46 route add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject
48 case ${ipv6_network_interfaces} in
49 [Aa][Uu][Tt][Oo])
50 # Get a list of network interfaces
51 ipv6_network_interfaces="`ifconfig -l`"
53 [Nn][Oo][Nn][Ee])
54 ipv6_network_interfaces=''
56 esac
58 if checkyesno ipv6_gateway_enable; then
59 # act as a router
60 ${SYSCTL_W} net.inet6.ip6.forwarding=1
61 ${SYSCTL_W} net.inet6.ip6.accept_rtadv=0
63 # wait for DAD
64 for i in $ipv6_network_interfaces; do
65 ifconfig $i up
66 done
67 sleep `${SYSCTL_N} net.inet6.ip6.dad_count`
68 sleep 1
69 else
70 # act as endhost - start with manual configuration
71 # Setup of net.inet6.ip6.accept_rtadv is done later by
72 # network6_interface_setup.
73 ${SYSCTL_W} net.inet6.ip6.forwarding=0
76 if [ -n "${ipv6_network_interfaces}" ]; then
77 # Setup the interfaces
78 network6_interface_setup $ipv6_network_interfaces
80 # wait for DAD's completion (for global addrs)
81 sleep `${SYSCTL_N} net.inet6.ip6.dad_count`
82 sleep 1
85 # Filter out interfaces on which IPv6 initialization failed.
86 if checkyesno ipv6_gateway_enable; then
87 ipv6_working_interfaces=""
88 for i in ${ipv6_network_interfaces}; do
89 laddr=`network6_getladdr $i exclude_tentative`
90 case ${laddr} in
91 '')
94 ipv6_working_interfaces="$i \
95 ${ipv6_working_interfaces}"
97 esac
98 done
99 ipv6_network_interfaces=${ipv6_working_interfaces}
102 # Setup IPv6 to IPv4 mapping
103 network6_stf_setup
105 # Install the "default interface" to kernel, which will be used
106 # as the default route when there's no router.
107 network6_default_interface_setup
109 # Setup static routes
110 network6_static_routes_setup
112 # Setup faith
113 network6_faith_setup
115 # Support for IPv4 address tacked onto an IPv6 address
116 if checkyesno ipv6_ipv4mapping; then
117 echo 'IPv4 mapped IPv6 address support=YES'
118 ${SYSCTL_W} net.inet6.ip6.v6only=0 >/dev/null
119 else
120 echo 'IPv4 mapped IPv6 address support=NO'
121 ${SYSCTL_W} net.inet6.ip6.v6only=1 >/dev/null
125 load_rc_config $name
126 run_rc_command "$1"