Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 294039 Details for
Bug 392223
sys-apps/openrc: Add 6rd support
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
6rd net module
ip6rd.sh (text/plain), 3.47 KB, created by
Christopher Byrne
on 2011-11-28 09:15:37 UTC
(
hide
)
Description:
6rd net module
Filename:
MIME Type:
Creator:
Christopher Byrne
Created:
2011-11-28 09:15:37 UTC
Size:
3.47 KB
patch
obsolete
>_config_vars="$_config_vars link prefix ipv4mask suffix relay" > >ip6rd_inet_atoi() >{ > local IFS="${IFS}." ipi=0 j=3 > for i in $1 ; do > ipi=$(( ipi | i << 8*j-- )) > done > echo ${ipi} >} > >ip6rd_inet_itoa() >{ > local ipi=$1 > for i in 0 1 2 3; do > if [ $i != 3 ] ; then > printf "%d." $(( (ipi & ~((1<<24)-1)) >> 24 )) > ipi=$(( (ipi & ((1<<24)-1)) << 8)) > else > printf "%d\n" $(( (ipi & ~((1<<24)-1)) >> 24 )) > fi > done >} > >ip6rd_inet_get_network() >{ > echo ip6rd_inet_itoa $(( ($(ip6rd_inet_atoi $1) & ((1<<32-$2)-1)) << $2 )) >} > >ip6rd_inet_is_private_network() >{ > if [ "$(ip6rd_inet_get_network $1 24)" = "192.168.0.0" ]\ > || [ "$(ip6rd_inet_get_network $1 8)" = "10.0.0.0" ]\ > || [ "$(ip6rd_inet_get_network $1 12)" = "172.16.0.0" ]\ > || [ "$(ip6rd_inet_get_network $1 16)" = "169.254.0.0" ] > then > return 0; > fi > return 1; >} > >ip6rd_prefix_shave_bits() >{ > local ipi= > ipi=$(( ($(ip6rd_inet_atoi $1) & (1<<(32-$2))-1) << $2)) > if [ $2 -le 16 ] > then > printf "%04x:%0$(( (16-$2>>2)+(($2%4)?1:0) ))x" \ > $((ipi >> 16)) $((ipi & (1<<(16-$2))-1)) > elif [ $2 -lt 32 ] > then > printf "%0$(( (32-$2>>2)+(($2%4)?1:0) ))x" \ > $((ipi >> 16)) > fi >} > >ip6rd_depend() >{ > after interface > after dhcp >} > >ip6rd_start() >{ > case "${MODULES}" in > *" ifconfig "*) > eerror "ifconfig is not supported for 6rd" > eerror "Please emerge sys-apps/iproute2" > return 1 > esac > > if [ "${IFACE}" == "sit0" ]; then > error "sit0 cannot be a 6rd tunnel. Please choose another name" > return 1 > fi > > local host= prefix= suffix= addr= iface=${IFACE} new= localip= relay= ipv4mask= > > eval host=\$link_${IFVAR} > eval prefix=\${prefix_${IFVAR}} > eval ipv4mask=\${ipv4mask_${IFVAR}:0} > eval suffix=\${suffix_${IFVAR}:-1} > eval relay=\${relay_${IFVAR}} > > if [ -z "${host}" ]; then > eerror "link_${IFVAR} not set" > return 1 > fi > > if [ -z "${relay}" ]; then > # TODO: support getting 6rd parameters vis DHCP (option 212) > eerror "relay_${IFVAR} not set" > return 1 > fi > > IFACE=${host} > addrs=$(_get_inet_addresses) > IFACE=${iface} > if [ -z "${addrs}" ]; then > eerror "${host} is not configured with an IPv4 address" > return 1 > fi > > for addr in ${addrs}; do > local ip="${addr%/*}" subnet=${addr#*/} > > # We don't work on private IPv4 addresses > if ip6rd_inet_is_private_network ${ip} > then > continue > fi > > veinfo "IPv4 address on ${host}: ${ip}/${subnet}" > local ip6= ip6_prefix="${prefix%::/*}" ip6_subnet="${prefix#*/}" > ip6_subnet=$((ip6_subnet + (32-ipv4mask))) > eval ip6="$(printf "${ip6_prefix}:%s::%s" \ > $(ip6rd_prefix_shave_bits ${ip} ${ipv4mask}) ${suffix})" > veinfo "Derived IPv6 address: ${ip6}" > > # Now apply our IPv6 address to our config > new="${new}${new:+ }${ip6}/${ip6_subnet}" > > if [ -n "${localip}" ]; then > localip="any" > else > localip="${ip}" > fi > done > > if [ -z "${new}" ]; then > eerror "No global IPv4 addresses found on interface ${host}" > return 1 > fi > > ebegin "Creating 6rd tunnel on ${IFACE}" > _tunnel add 6rd mode sit local "${localip}" ttl 255 > _tunnel 6rd dev "${IFACE}" 6rd-prefix ${prefix} > eend $? || return 1 > _up > > # Now apply our config > eval config_${config_index}=\'"${new}"\' > : $(( config_index -= 1 )) > > # Add a route for us, ensuring we don't delete anything else > local routes="$(_get_array "routes_${IFVAR}") >2003::/3 via ::${relay} metric 2147483647" > eval routes_${IFVAR}=\$routes >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 392223
:
294007
|
294039
|
295781
|
297257
|
297261
|
297265
|
297277