Changeset View
Changeset View
Standalone View
Standalone View
libexec/rc/network.subr
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | ifn_start() | ||||
ifn="$1" | ifn="$1" | ||||
cfg=1 | cfg=1 | ||||
[ -z "$ifn" ] && err 1 "ifn_start called without an interface" | [ -z "$ifn" ] && err 1 "ifn_start called without an interface" | ||||
ifscript_up ${ifn} && cfg=0 | ifscript_up ${ifn} && cfg=0 | ||||
ifconfig_up ${ifn} && cfg=0 | ifconfig_up ${ifn} && cfg=0 | ||||
if ! noafif $ifn; then | if ! noafif $ifn; then | ||||
afexists inet && ipv4_up ${ifn} && cfg=0 | |||||
afexists inet6 && ipv6_up ${ifn} && cfg=0 | afexists inet6 && ipv6_up ${ifn} && cfg=0 | ||||
afexists inet && ipv4_up ${ifn} && cfg=0 | |||||
bz: This is unrelated for this and should be a follow-up to an old commit I once did ... (lookup… | |||||
fi | fi | ||||
childif_create ${ifn} && cfg=0 | childif_create ${ifn} && cfg=0 | ||||
return $cfg | return $cfg | ||||
} | } | ||||
# ifn_stop ifn | # ifn_stop ifn | ||||
# Shutdown and de-configure an interface. If action is taken, | # Shutdown and de-configure an interface. If action is taken, | ||||
▲ Show 20 Lines • Show All 1,681 Lines • ▼ Show 20 Lines | |||||
# Echo link-local address from $if if any. | # Echo link-local address from $if if any. | ||||
# If flag is defined, tentative ones will be excluded. | # If flag is defined, tentative ones will be excluded. | ||||
network6_getladdr() | network6_getladdr() | ||||
{ | { | ||||
local _if _flag proto addr rest | local _if _flag proto addr rest | ||||
_if=$1 | _if=$1 | ||||
_flag=$2 | _flag=$2 | ||||
${IFCONFIG_CMD} $_if 2>/dev/null | while read proto addr rest; do | ${IFCONFIG_CMD} $_if inet6 2>/dev/null | while read proto addr rest; do | ||||
bzAuthorUnsubmitted Done Inline ActionsThis should be done separately as well; we are only interested in inet6 addresses so avoid printing a load of other stuff. bz: This should be done separately as well; we are only interested in inet6 addresses so avoid… | |||||
case "${proto}/${addr}/${_flag}/${rest}" in | case "${proto}/${addr}/${_flag}/${rest}" in | ||||
inet6/fe80::*//*) | inet6/fe80::*//*) | ||||
echo ${addr} | echo ${addr} | ||||
;; | ;; | ||||
inet6/fe80:://*tentative*) # w/o flag | inet6/fe80:://*tentative*) # w/o flag | ||||
sleep `${SYSCTL_N} net.inet6.ip6.dad_count` | sleep `${SYSCTL_N} net.inet6.ip6.dad_count` | ||||
network6_getladdr $_if $_flags | network6_getladdr $_if $_flags | ||||
;; | ;; | ||||
inet6/fe80::/*/*tentative*) # w/ flag | inet6/fe80::/*/*tentative*) # w/ flag | ||||
echo ${addr} | echo ${addr} | ||||
;; | ;; | ||||
*) | *) | ||||
continue | continue | ||||
;; | ;; | ||||
esac | esac | ||||
return | return | ||||
done | |||||
} | |||||
# network6_gettentative if | |||||
# Check if there are any tentative IPv6 addresses on $if. | |||||
# Returns the number of tentative addresses found. | |||||
network6_gettentative() | |||||
{ | |||||
local _if proto addr rest count | |||||
_if=$1 | |||||
count=0 | |||||
while read proto addr rest; do | |||||
case "${proto}/${addr}/${rest}" in | |||||
inet6/*/*tentative*) | |||||
count=$((count + 1)) | |||||
;; | |||||
esac | |||||
done <<EOI | |||||
`${IFCONFIG_CMD} $_if inet6 2>/dev/null` | |||||
EOI | |||||
return ${count} | |||||
} | |||||
# network6_gettentative if | |||||
# Wait for "tentative" addresses to clear on $_ifnlist. | |||||
# Returns with timeout or when all tentative flags are gone. | |||||
network6_waitdad() | |||||
{ | |||||
local _ifnlist _if count iter | |||||
_ifnlist="$1" | |||||
count=1 | |||||
iter=0 | |||||
# We should never need more than 2 iterations unless someone | |||||
# adds more addresses while we sleep. | |||||
while test ${count} -gt 0 -a ${iter} -lt 2; do | |||||
sleep `${SYSCTL_N} net.inet6.ip6.dad_count` | |||||
count=0 | |||||
for _if in ${_ifnlist}; do | |||||
if ! network6_gettentative ${_if} ; then | |||||
count=1 | |||||
fi | |||||
done | |||||
iter=$((iter + 1)) | |||||
done | done | ||||
} | } |
This is unrelated for this and should be a follow-up to an old commit I once did ... (lookup hash and factor out here). Should not matter anyway.