Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Jan 2013 07:24:35 +0200
From:      Kimmo Paasiala <kpaasial@gmail.com>
To:        Phil Kulin <schors@gmail.com>
Cc:        FreeBSD current <freebsd-current@freebsd.org>, freebsd-stable@freebsd.org
Subject:   Re: ipv6_addrs_IF aliases in rc.conf(5)
Message-ID:  <CA%2B7WWSe26yVGvikjs98A136U02L=ECvnuLE%2BZAj6M6=ufFacxg@mail.gmail.com>
In-Reply-To: <CAK=u2EV8gSW-mDv4o1VHUPL=%2BQ=RL7jAEuAjC%2B5%2BnKSqu%2BGhzQ@mail.gmail.com>
References:  <50D1C553.9060100@wasikowski.net> <CA%2B7WWSewg%2BQqcn1L508tAiBY1zLQfne6AC6w7oAco3y=efcX9w@mail.gmail.com> <CA%2B7WWSeibFGNSwtjUeK-U6irj6axGftAHJC2eYU3tQoeM0JRpA@mail.gmail.com> <20121220132750.GB99616@stack.nl> <CA%2B7WWSdqjkZq1y0dyxV9LiycNA0V%2BCyEKt9x0d%2BWJaaWC4SXSg@mail.gmail.com> <CA%2B7WWSc-VwdmYBEtZwO03x-p2o7-eUr9bWrhMhjBCUSah_0v_A@mail.gmail.com> <50D4F2E4.7020600@wasikowski.net> <CA%2B7WWSc9sR74RT=oMT8uSBmNYrK-80t7Y8KKZx9JxuVE4drXBA@mail.gmail.com> <CA%2B7WWSdM=45i5knYHUa_Nq=2dta4ek8Q%2Bp3g_Bf697d7_i__QA@mail.gmail.com> <CA%2B7WWSc9ORJQnvaVA0QVnwf4i=wEJ-%2BcYiOqQK3wDUDzL=TGTA@mail.gmail.com> <20121222171400.GA2399@anubis.morrow.me.uk> <50D5F296.9050109@wasikowski.net> <CA%2B7WWSdUFc1Xp-KikDjk2yRHP7S41Uxy3SdOrKZyP%2BcR7mp0KA@mail.gmail.com> <CA%2B7WWSfx2UO=yC25aaSWeGVPr2qtr-dkumH8Jxa7BiY7Xqarng@mail.gmail.com> <CAK=u2EV8gSW-mDv4o1VHUPL=%2BQ=RL7jAEuAjC%2B5%2BnKSqu%2BGhzQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Dec 27, 2012 at 11:42 PM, Phil Kulin <schors@gmail.com> wrote:
> 2012/12/26 Kimmo Paasiala <kpaasial@gmail.com>:
>
>> I've revised the patch again and updated it at gihub,
>> https://gist.github.com/4362018.  It can now be applied at top level
>> of sources (/usr/src typically). It now does the deconfiguration in
>> reverse order of the configuration, meaning the aliases configured
>> with ipv6_addrs_IF are removed before the ones configured with
>> ifconfig_IF_aliasN="inet6 ...".
>
> Adapted for FreeBSD 8.2, works fine:
>
> --- network.subr.orig   2011-02-17 05:19:39.000000000 +0300
> +++ network.subr        2012-12-28 00:46:38.000000000 +0400
> @@ -312,6 +312,12 @@ afexists()
>  #      1 otherwise.
>  ipv6if()
>  {
> +       # 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
>         if ! checkyesno ipv6_enable; then
>                 return 1
>         fi
> @@ -948,7 +954,12 @@ network6_interface_setup()
>                         rtsol_interface=no
>                         ifconfig $i inet6 ${ipv6_ifconfig} alias
>                 fi
> -
> +               ipv6_addrs=`get_if_var $i ipv6_addrs_IF`
> +               if [ -n "${ipv6_addrs}" ]; then
> +                       rtsol_available=no
> +                       rtsol_interface=no
> +                       ipv6_addrs_common ${i} alias
> +               fi
>                 # Wireless NIC cards are virtualized through the wlan interface
>                 if ! is_wired_interface ${i}; then
>                         case "${i}" in
> @@ -1178,3 +1189,39 @@ network6_getladdr()
>                 esac
>         done
>  }
> +
> +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
> +}
>
>
> --
> Non nobis Domine non nobis sed Nomini Tuo da gloriam
> Phil Kulin

I don't have an 8.X system to test but I guess it's fine.

Any more interest in this? I'd love to see this added, not because I
wrote it but because I want to contribute in any way I can.

-Kimmo



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2B7WWSe26yVGvikjs98A136U02L=ECvnuLE%2BZAj6M6=ufFacxg>