blob: 914ca8ca6ece5c6d04280b1755bc12dc309774dc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: ip6addrctl
# REQUIRE: FILESYSTEMS
# BEFORE: netif
# KEYWORD: nojail
. /etc/rc.subr
. /etc/network.subr
name="ip6addrctl"
rcvar="ip6addrctl_enable"
start_cmd="ip6addrctl_start"
stop_cmd="ip6addrctl_stop"
extra_commands="status prefer_ipv6 prefer_ipv4"
status_cmd="ip6addrctl"
prefer_ipv6_cmd="ip6addrctl_prefer_ipv6"
prefer_ipv4_cmd="ip6addrctl_prefer_ipv4"
config_file="/etc/ip6addrctl.conf"
set_rcvar_obsolete ipv6_enable ipv6_activate_all_interfaces
set_rcvar_obsolete ipv6_prefer ip6addrctl_policy
ip6addrctl_prefer_ipv6()
{
afexists inet6 || return 0
ip6addrctl flush >/dev/null 2>&1
ip6addrctl add ::1/128 50 0
ip6addrctl add ::/0 40 1
ip6addrctl add ::ffff:0:0/96 35 4
ip6addrctl add 2002::/16 30 2
ip6addrctl add 2001::/32 5 5
ip6addrctl add fc00::/7 3 13
ip6addrctl add ::/96 1 3
ip6addrctl add fec0::/10 1 11
ip6addrctl add 3ffe::/16 1 12
checkyesno ip6addrctl_verbose && ip6addrctl
}
ip6addrctl_prefer_ipv4()
{
afexists inet6 || return 0
ip6addrctl flush >/dev/null 2>&1
ip6addrctl add ::1/128 50 0
ip6addrctl add ::/0 40 1
ip6addrctl add ::ffff:0:0/96 100 4
ip6addrctl add 2002::/16 30 2
ip6addrctl add 2001::/32 5 5
ip6addrctl add fc00::/7 3 13
ip6addrctl add ::/96 1 3
ip6addrctl add fec0::/10 1 11
ip6addrctl add 3ffe::/16 1 12
checkyesno ip6addrctl_verbose && ip6addrctl
}
ip6addrctl_start()
{
afexists inet6 || return 0
# install the policy of the address selection algorithm.
case "${ip6addrctl_policy}" in
[Aa][Uu][Tt][Oo])
if [ -r "${config_file}" -a -s "${config_file}" ]; then
ip6addrctl flush >/dev/null 2>&1
ip6addrctl install "${config_file}"
checkyesno ip6addrctl_verbose && ip6addrctl
else
if checkyesno ipv6_activate_all_interfaces; then
ip6addrctl_prefer_ipv6
else
ip6addrctl_prefer_ipv4
fi
fi
;;
ipv4_prefer)
ip6addrctl_prefer_ipv4
;;
ipv6_prefer)
ip6addrctl_prefer_ipv6
;;
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
# Backward compatibility when ipv6_prefer=YES
ip6addrctl_prefer_ipv6
;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
# Backward compatibility when ipv6_prefer=NO
ip6addrctl_prefer_ipv4
;;
[Nn][Oo][Nn][Ee])
ip6addrctl flush >/dev/null 2>&1
;;
*)
warn "\$ip6addrctl_policy is invalid: ${ip6addrctl_policy}. " \
" \"ipv4_prefer\" is used instead."
ip6addrctl_prefer_ipv4
;;
esac
}
ip6addrctl_stop()
{
afexists inet6 || return 0
ip6addrctl flush >/dev/null 2>&1
}
load_rc_config $name
run_rc_command "$1"
|