Last active
December 10, 2015 01:48
-
-
Save kpaasial/4362018 to your computer and use it in GitHub Desktop.
Patch against stable/9/etc/network.subr to add support for ipv6_addrs_IF in rc.conf(5).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: etc/network.subr | |
=================================================================== | |
--- etc/network.subr (revision 244687) | |
+++ etc/network.subr (working copy) | |
@@ -438,6 +438,13 @@ | |
;; | |
esac | |
+ # Test for $ipv6_addrs_IF. If it exists then the | |
+ # interface should be configured for IPv6 | |
+ _tmpargs=$(get_if_var $_if ipv6_addrs_IF) | |
+ if [ -n "${_tmpargs}" ]; then | |
+ return 0 | |
+ fi | |
+ | |
case "${ipv6_network_interfaces}" in | |
$_if|"$_if "*|*" $_if"|*" $_if "*|[Aa][Uu][Tt][Oo]) | |
# True if $ifconfig_IF_ipv6 is defined. | |
@@ -562,6 +569,7 @@ | |
fi | |
ifalias_up ${_if} inet6 && _ret=0 | |
+ ipv6_addrs_common ${_if} alias && _ret=0 | |
ipv6_prefix_hostid_addr_common ${_if} alias && _ret=0 | |
ipv6_accept_rtadv_up ${_if} && _ret=0 | |
@@ -619,6 +627,7 @@ | |
ipv6_accept_rtadv_down ${_if} && _ret=0 | |
ipv6_prefix_hostid_addr_common ${_if} -alias && _ret=0 | |
+ ipv6_addrs_common ${_if} -alias && _ret=0 | |
ifalias_down ${_if} inet6 && _ret=0 | |
inetList="`ifconfig ${_if} | grep 'inet6 ' | tr "\n" "$_ifs"`" | |
@@ -684,6 +693,49 @@ | |
return $_ret | |
} | |
+ | |
+ipv6_addrs_common() | |
+{ | |
+ local _ret _if _action _ip6prefix _ip6prefixes | |
+ local _ip6addr _prefixlen | |
+ local _range _ip6net _ip6low _ip6high | |
+ _ret=1 | |
+ _if=$1 | |
+ _action=$2 | |
+ | |
+# get the prefixes from ipv6_addrs_IF variable | |
+ _ip6prefixes=`get_if_var $_if ipv6_addrs_IF` | |
+ for _ip6prefix in ${_ip6prefixes}; do | |
+ _ip6addr=${_ip6prefix%%/*} | |
+ _prefixlen=${_ip6prefix##*/} | |
+ _range=${_ip6addr##*:} | |
+ _ip6net=${_ip6addr%:*} | |
+ _ip6low=${_range%-*} | |
+ _ip6high=${_range#*-} | |
+ | |
+# If deleting an alias, set _prefixlen to null string. | |
+ if [ "${_action}" = "-alias" ]; then | |
+ _prefixlen="" | |
+ else | |
+ _prefixlen="prefixlen $_prefixlen" | |
+ fi | |
+ | |
+ _ip6high=$(("0x${_ip6high}")) | |
+ _ip6count=$(("0x${_ip6low}")) | |
+ while [ "${_ip6count}" -le "${_ip6high}" ]; do | |
+ # Re-uses the _ip6addr variable from above | |
+ _ip6addr=$(printf "%x" "${_ip6count}") | |
+ eval "ifconfig ${_if} inet6 ${_ip6net}:${_ip6addr} ${_prefixlen} ${_action}" | |
+ _ip6count=$((${_ip6count}+1)) | |
+ _ret=0 | |
+ done | |
+ done | |
+ | |
+ return $_ret | |
+} | |
+ | |
+ | |
+ | |
# ifalias_up if af | |
# Configure aliases for network interface $if. | |
# It returns 0 if at least one alias was configured or |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment