Re: ipv6_addrs_IF aliases in rc.conf(5)

2013-07-16 Thread Łukasz Wąsikowski
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

W dniu 2013-07-12 09:03, Hiroki Sato pisze:

> Please let me know if the existing configurations and/or the new 
> formats do not work.  The following is a summary of the supported 
> rc.conf variables, FYI:
> 
> Hiroki Sato  wrote in
> <201306200229.r5k2tnfr085...@svn.freebsd.org>:
> 

[...]

What is the current, non deprecated way, to configure IP addresses in
rc.conf? Let's say for a dual stack, multi IP box I need to set:

10.0.0.66/28 and 10.0.0.67-78 as aliases and
fdda:5cc1:23:4::1/48 and fdda:5cc1:23:4::2-f as aliases

What is the best way to accomplish it?

- -- 
best regards,
Lukasz Wasikowski
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlHlKqQACgkQXlaUxx+udUUtnwCfc74UJLDPnCjec+v8TP0d8ceV
Pz4AnA6Nd5rwO5HL/LYdaJiPmBC1ENxC
=bzG8
-END PGP SIGNATURE-
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2013-07-12 Thread Hiroki Sato
Michael Grimm  wrote
  in <4c07217dc9200841dfd065a6d5284...@mx1.enfer-du-nord.net>:

tr> On 2013-07-12 6:56, Hiroki Sato wrote:
tr> > Kevin Oberman  wrote
tr> >   in :
tr> > rk> On Wed, Jul 10, 2013 at 4:46 AM, Mark Felder  wrote:
tr> > rk>
tr> > rk> > On Wed, 10 Jul 2013 06:44:12 -0500, Michael Grimm <
tr> > rk> > trash...@odo.in-berlin.de> wrote:
tr> > rk> >
tr> > rk> >  Will that patch make it into 9.2? If I am not mistaken, that patch 
isn't
tr> > rk> >> in stable yet.
tr> > rk> >>
tr> > rk> >
tr> > rk> > I would also like to see this patch hit 9.x sooner than later. It's 
so
tr> > rk> > painful when someone forgets to fix the alias numbering on servers 
with
tr> > rk> > many, many IPv4 and IPv6 addresses...
tr> > rk> >
tr> > rk>
tr> > rk> Please, please, please, please, ...!
tr> > rk>
tr> > rk> Freeze is only two days away, so time for 9.2 is almost over and I 
can see
tr> > rk> no good reason NOT to get this done.
tr> >  r252015 was merged to stable/9 today.
tr>
tr> Thanks! This is highly appreciated. A first glance at network.subr tells me 
that
tr> much more has been modified/simplified regarding alias definitions, great.

 Please let me know if the existing configurations and/or the new
 formats do not work.  The following is a summary of the supported
 rc.conf variables, FYI:

Hiroki Sato  wrote
  in <201306200229.r5k2tnfr085...@svn.freebsd.org>:

hr>   A summary of the supported ifconfig_* variables is as follows:
hr>
hr># IPv4 configuration.
hr>ifconfig_em0="inet 192.168.0.1"
hr># IPv6 configuration.
hr>ifconfig_em0_ipv6="inet6 2001:db8::1/64"
hr># IPv4 address range spec.  Now deprecated.
hr>ipv4_addr_em0="10.2.1.1-10"
hr># IPv6 alias.
hr>ifconfig_em0_alias0="inet6 2001:db8:5::1 prefixlen 70"
hr># IPv4 alias.
hr>ifconfig_em0_alias1="inet 10.2.2.1/24"
hr># IPv4 alias with range spec w/o AF keyword (backward compat).
hr>ifconfig_em0_alias2="10.3.1.1-10/32"
hr># IPv6 alias with range spec.
hr>ifconfig_em0_alias3="inet6 2001:db8:20-2f::1/64"
hr># ifconfig_IF_aliases is just like ifconfig_IF_aliasN.
hr>ifconfig_em0_aliases="inet 10.3.3.201-204/24 inet6 
2001:db8:210-213::1/64 inet 10.1.1.1/24"
hr># IPv6 alias (backward compat)
hr>ipv6_ifconfig_em0_alias0="inet6 2001:db8:f::1/64"
hr># IPv6 alias w/o AF keyword (backward compat)
hr>ipv6_ifconfig_em0_alias1="2001:db8:f:1::1/64"
hr># IPv6 prefix.
hr>ipv6_prefix_em0="2001:db8::/64"

-- Hiroki


pgphvaD2aj_hG.pgp
Description: PGP signature


Re: ipv6_addrs_IF aliases in rc.conf(5)

2013-07-11 Thread Michael Grimm

On 2013-07-12 6:56, Hiroki Sato wrote:

Kevin Oberman  wrote
  in 
:


rk> On Wed, Jul 10, 2013 at 4:46 AM, Mark Felder  wrote:
rk>
rk> > On Wed, 10 Jul 2013 06:44:12 -0500, Michael Grimm <
rk> > trash...@odo.in-berlin.de> wrote:
rk> >
rk> >  Will that patch make it into 9.2? If I am not mistaken, that 
patch isn't

rk> >> in stable yet.
rk> >>
rk> >
rk> > I would also like to see this patch hit 9.x sooner than later. 
It's so
rk> > painful when someone forgets to fix the alias numbering on 
servers with

rk> > many, many IPv4 and IPv6 addresses...
rk> >
rk>
rk> Please, please, please, please, ...!
rk>
rk> Freeze is only two days away, so time for 9.2 is almost over and I 
can see

rk> no good reason NOT to get this done.

 r252015 was merged to stable/9 today.


Thanks! This is highly appreciated. A first glance at network.subr tells 
me that
much more has been modified/simplified regarding alias definitions, 
great.


Regards, Michael

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2013-07-11 Thread Kevin Oberman
On Thu, Jul 11, 2013 at 9:56 PM, Hiroki Sato  wrote:

> Kevin Oberman  wrote
>   in :
>
> rk> On Wed, Jul 10, 2013 at 4:46 AM, Mark Felder  wrote:
> rk>
> rk> > On Wed, 10 Jul 2013 06:44:12 -0500, Michael Grimm <
> rk> > trash...@odo.in-berlin.de> wrote:
> rk> >
> rk> >  Will that patch make it into 9.2? If I am not mistaken, that patch
> isn't
> rk> >> in stable yet.
> rk> >>
> rk> >
> rk> > I would also like to see this patch hit 9.x sooner than later. It's
> so
> rk> > painful when someone forgets to fix the alias numbering on servers
> with
> rk> > many, many IPv4 and IPv6 addresses...
> rk> >
> rk>
> rk> Please, please, please, please, ...!
> rk>
> rk> Freeze is only two days away, so time for 9.2 is almost over and I can
> see
> rk> no good reason NOT to get this done.
>
>  r252015 was merged to stable/9 today.
>
> -- Hiroki
>

Just under the wire! I'm sure that I am not the only one who appreciates it.

-- 
R. Kevin Oberman, Network Engineer
E-mail: rkober...@gmail.com
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2013-07-11 Thread Hiroki Sato
Kevin Oberman  wrote
  in :

rk> On Wed, Jul 10, 2013 at 4:46 AM, Mark Felder  wrote:
rk>
rk> > On Wed, 10 Jul 2013 06:44:12 -0500, Michael Grimm <
rk> > trash...@odo.in-berlin.de> wrote:
rk> >
rk> >  Will that patch make it into 9.2? If I am not mistaken, that patch isn't
rk> >> in stable yet.
rk> >>
rk> >
rk> > I would also like to see this patch hit 9.x sooner than later. It's so
rk> > painful when someone forgets to fix the alias numbering on servers with
rk> > many, many IPv4 and IPv6 addresses...
rk> >
rk>
rk> Please, please, please, please, ...!
rk>
rk> Freeze is only two days away, so time for 9.2 is almost over and I can see
rk> no good reason NOT to get this done.

 r252015 was merged to stable/9 today.

-- Hiroki


pgpwhHHP9UTVY.pgp
Description: PGP signature


Re: ipv6_addrs_IF aliases in rc.conf(5)

2013-07-11 Thread Łukasz Wąsikowski
W dniu 2013-07-10 17:52, Kevin Oberman pisze:

> On Wed, Jul 10, 2013 at 4:46 AM, Mark Felder  wrote:
> 
>> On Wed, 10 Jul 2013 06:44:12 -0500, Michael Grimm <
>> trash...@odo.in-berlin.de> wrote:
>>
>>  Will that patch make it into 9.2? If I am not mistaken, that patch isn't
>>> in stable yet.
>>>
>>
>> I would also like to see this patch hit 9.x sooner than later. It's so
>> painful when someone forgets to fix the alias numbering on servers with
>> many, many IPv4 and IPv6 addresses...
>>
> 
> Please, please, please, please, ...!
> 
> Freeze is only two days away, so time for 9.2 is almost over and I can see
> no good reason NOT to get this done.

+1 to that, please commit it.

-- 
best regards,
Lukasz Wasikowski
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2013-07-10 Thread Kevin Oberman
On Wed, Jul 10, 2013 at 4:46 AM, Mark Felder  wrote:

> On Wed, 10 Jul 2013 06:44:12 -0500, Michael Grimm <
> trash...@odo.in-berlin.de> wrote:
>
>  Will that patch make it into 9.2? If I am not mistaken, that patch isn't
>> in stable yet.
>>
>
> I would also like to see this patch hit 9.x sooner than later. It's so
> painful when someone forgets to fix the alias numbering on servers with
> many, many IPv4 and IPv6 addresses...
>

Please, please, please, please, ...!

Freeze is only two days away, so time for 9.2 is almost over and I can see
no good reason NOT to get this done.
-- 
R. Kevin Oberman, Network Engineer
E-mail: rkober...@gmail.com
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2013-07-10 Thread Mark Felder
On Wed, 10 Jul 2013 06:44:12 -0500, Michael Grimm  
 wrote:


Will that patch make it into 9.2? If I am not mistaken, that patch isn't  
in stable yet.


I would also like to see this patch hit 9.x sooner than later. It's so  
painful when someone forgets to fix the alias numbering on servers with  
many, many IPv4 and IPv6 addresses...

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2013-07-10 Thread Michael Grimm

Hi --

[Upcoming code freeze in stable]

On 2013-04-13 22:15, Michael Grimm wrote:

On 13.04.2013, at 14:29, Kimmo Paasiala  wrote:



[great deal of simplification by ipv6_addrs_IF]


Sorry to resurrect this thread but since nothing has happened in about
three months I have to ask: What can I do to have this commited to
HEAD?


+1

Nowadays -where IPv6 becomes more and more available by ISPs- I 
*really*

would like to see this simplification implemented, soon, very soon. The
current scheme is way to much error prone, and, its a pain in the ass!

Thanks for the patch,
Michael


Will that patch make it into 9.2? If I am not mistaken, that patch isn't 
in stable yet.


Regards,
Michael

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2013-04-21 Thread Łukasz Wąsikowski
W dniu 2013-04-13 22:15, Michael Grimm pisze:

> On 13.04.2013, at 14:29, Kimmo Paasiala  wrote:
> 
> [great deal of simplification by ipv6_addrs_IF]
> 
>> Sorry to resurrect this thread but since nothing has happened in about
>> three months I have to ask: What can I do to have this commited to
>> HEAD?
> 
> +1
> 
> Nowadays -where IPv6 becomes more and more available by ISPs- I *really*
> would like to see this simplification implemented, soon, very soon. The
> current scheme is way to much error prone, and, its a pain in the ass!

Kimmo's patch worked for me. It would be great to have ipv6_addrs_if out
of the box.

-- 
best regards,
Lukasz Wasikowski
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2013-04-14 Thread Mark Felder
I would also like to see this committed. I started on my own patch about
4 months ago but got sidetracked. This would be very, very valuable to
the sysadmins at my workplace.
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2013-04-13 Thread Michael Grimm
Hi --

On 13.04.2013, at 14:29, Kimmo Paasiala  wrote:

[great deal of simplification by ipv6_addrs_IF]

> Sorry to resurrect this thread but since nothing has happened in about
> three months I have to ask: What can I do to have this commited to
> HEAD?

+1

Nowadays -where IPv6 becomes more and more available by ISPs- I *really*
would like to see this simplification implemented, soon, very soon. The
current scheme is way to much error prone, and, its a pain in the ass!

Thanks for the patch,
Michael

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2013-04-13 Thread Kimmo Paasiala
On Thu, Jan 17, 2013 at 7:24 AM, Kimmo Paasiala  wrote:
> On Thu, Dec 27, 2012 at 11:42 PM, Phil Kulin  wrote:
>> 2012/12/26 Kimmo Paasiala :
>>
>>> 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.0 +0300
>> +++ network.subr2012-12-28 00:46:38.0 +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

Sorry to resurrect this thread but since nothing has happened in about
three months I have to ask: What can I do to have this commited to
HEAD? I'd be even willing to become a src committer if that's what is
required. I feel that I'm compentent enough. Who can I contact?

-Kimmo
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2013-01-16 Thread Kimmo Paasiala
On Thu, Dec 27, 2012 at 11:42 PM, Phil Kulin  wrote:
> 2012/12/26 Kimmo Paasiala :
>
>> 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.0 +0300
> +++ network.subr2012-12-28 00:46:38.0 +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
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2012-12-27 Thread Phil Kulin
2012/12/26 Kimmo Paasiala :

> 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.0 +0300
+++ network.subr2012-12-28 00:46:38.0 +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
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2012-12-26 Thread Thomas Steen Rasmussen
On 26-12-2012 10:33, Kimmo Paasiala wrote:
> Now, is there any interest in seeing this feature as part of future
> versions of FreeBSD? Could it be incorporated to HEAD and then MFC'ed
> to 9-STABLE  if it turns out it's seen as a useful feature?

Yes please! I've been waiting for this for a while, as it will greatly
simplify my rc.conf on a whole bunch of jail hosts. I've spoken with
bz@ about this at eurobsdcon in November 2011 and he agreed that it
is a missing feature, so I suspect it is a matter of time before your
patch is picked up by a committer. Thank you for your work!


Best regards

Thomas Steen Rasmussen

ps. bz@ cc'ed so he sees this thread

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2012-12-26 Thread Kimmo Paasiala
On Mon, Dec 24, 2012 at 6:07 AM, Kimmo Paasiala  wrote:
> On Sat, Dec 22, 2012 at 7:49 PM, Łukasz Wąsikowski
>  wrote:
>> W dniu 2012-12-22 18:14, Ben Morrow pisze:
>>> Quoth =?UTF-8?B?xYF1a2FzeiBXxIVzaWtvd3NraQ==?= :
 W dniu 2012-12-22 04:41, Kimmo Paasiala pisze:

> Yeah, this is problem in network.subr. An interface is not recognized
> as IPv6 capable if the interface is not in "ipv6_network_interfaces"
> and there's no "ifconfig_IF_ipv6" in rc.conf(5), bummer. For IPv4 it
> "just works" because the interface is always assumed to be IPv4
> capable.

 Ok, I used ifconfig_em0_ipv6="up" and it worked. So it looks like this:
>>>
>>> The documented way to do this is to just set the link-local address in
>>> ifconfig_IF_ipv6, since an interface is required to have a link-local
>>> address. Either configure an fe80:: address explicitly or set
>>>
>>> ifconfig_em0_ipv6="inet6 auto_linklocal"
>>>
>>> Alternatively, if you set ipv6_activate_all_interfaces all interfaces
>>> will be considered IPv6-capable.
>>
>> link-local address is assigned by default, even with ifconfig_IF_ipv6="up".
>>
>> root@freebsd:~ # grep -Ev '^[[:space:]]*#|^$' /etc/rc.conf ; ifconfig
>> em0 | grep -E '^[[:space:]]*inet6' | head -2
>> hostname="freebsd"
>> ifconfig_em0="up"
>> ipv4_addrs_em0="192.168.168.20-24/24"
>> defaultrouter="192.168.168.1"
>> ipv6_network_interfaces="em0"
>> ipv6_defaultrouter="2001:6a0:1cb::"
>> ifconfig_em0_ipv6="up"
>> ipv6_addrs_em0="2001:6a0:1cb::1-e/128"
>> sshd_enable="YES"
>> dumpdev="NO"
>> named_enable="YES"
>> inet6 fe80::a00:27ff:fe02:8371%em0 prefixlen 64 scopeid 0x1
>> inet6 2001:6a0:1cb::1 prefixlen 128
>>
>> Of course using "inet6 auto_linklocal" instead of "up" seems a better
>> way to do it, thank you for this tip.
>>
>> --
>> best regards,
>> Lukasz Wasikowski
>
>
> I have put up the patch at github as:
>
> https://gist.github.com/4362018
>
> This version should work with just the ipv6_addrs_IF in rc.conf(5). I
> changed the detection of ipv6 interfaces so that just having the
> ipv6_addrs_IF line is enough.
>
> -Kimmo

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 ...".

Also as noted in my previous message it's possible to configure all
IPv6 addresses with a single ipv6_addrs_IF line in rc.conf:

ipv6_addrs_re0="2001:db8::::1-4/64"


I consider this version of the patch pretty much completed work. It
applies cleanly to HEAD version r244694 and I don't see why it
wouldn't work in HEAD as well.

Now, is there any interest in seeing this feature as part of future
versions of FreeBSD? Could it be incorporated to HEAD and then MFC'ed
to 9-STABLE  if it turns out it's seen as a useful feature?

Regards,

Kimmo Paasiala
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: ipv6_addrs_IF aliases in rc.conf(5)

2012-12-23 Thread Kimmo Paasiala
On Sat, Dec 22, 2012 at 7:49 PM, Łukasz Wąsikowski
 wrote:
> W dniu 2012-12-22 18:14, Ben Morrow pisze:
>> Quoth =?UTF-8?B?xYF1a2FzeiBXxIVzaWtvd3NraQ==?= :
>>> W dniu 2012-12-22 04:41, Kimmo Paasiala pisze:
>>>
 Yeah, this is problem in network.subr. An interface is not recognized
 as IPv6 capable if the interface is not in "ipv6_network_interfaces"
 and there's no "ifconfig_IF_ipv6" in rc.conf(5), bummer. For IPv4 it
 "just works" because the interface is always assumed to be IPv4
 capable.
>>>
>>> Ok, I used ifconfig_em0_ipv6="up" and it worked. So it looks like this:
>>
>> The documented way to do this is to just set the link-local address in
>> ifconfig_IF_ipv6, since an interface is required to have a link-local
>> address. Either configure an fe80:: address explicitly or set
>>
>> ifconfig_em0_ipv6="inet6 auto_linklocal"
>>
>> Alternatively, if you set ipv6_activate_all_interfaces all interfaces
>> will be considered IPv6-capable.
>
> link-local address is assigned by default, even with ifconfig_IF_ipv6="up".
>
> root@freebsd:~ # grep -Ev '^[[:space:]]*#|^$' /etc/rc.conf ; ifconfig
> em0 | grep -E '^[[:space:]]*inet6' | head -2
> hostname="freebsd"
> ifconfig_em0="up"
> ipv4_addrs_em0="192.168.168.20-24/24"
> defaultrouter="192.168.168.1"
> ipv6_network_interfaces="em0"
> ipv6_defaultrouter="2001:6a0:1cb::"
> ifconfig_em0_ipv6="up"
> ipv6_addrs_em0="2001:6a0:1cb::1-e/128"
> sshd_enable="YES"
> dumpdev="NO"
> named_enable="YES"
> inet6 fe80::a00:27ff:fe02:8371%em0 prefixlen 64 scopeid 0x1
> inet6 2001:6a0:1cb::1 prefixlen 128
>
> Of course using "inet6 auto_linklocal" instead of "up" seems a better
> way to do it, thank you for this tip.
>
> --
> best regards,
> Lukasz Wasikowski


I have put up the patch at github as:

https://gist.github.com/4362018

This version should work with just the ipv6_addrs_IF in rc.conf(5). I
changed the detection of ipv6 interfaces so that just having the
ipv6_addrs_IF line is enough.

-Kimmo
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: ipv6_addrs_IF aliases in rc.conf(5)

2012-12-22 Thread Kimmo Paasiala
On Sat, Dec 22, 2012 at 4:25 PM, Łukasz Wąsikowski
 wrote:
> W dniu 2012-12-22 04:41, Kimmo Paasiala pisze:
>
 It looks like the reason for the difference to ipv4_addrs_IF is that
 the "alias" parameter for ifconfig(8) operates differently for IPv6
 addresses, the first address of an interface can't be added with
 "alias", for IPv4 it does not care. I'll have to dig deeper but that's
 what the problem seems to be.

 -Kimmo
>>>
>>> The 'alias' parameter of ifconfig(8) is not the problem on the first
>>> ipv6 address, I have verified that. However, there's probably
>>> something in network.subr or /etc/rc.d/netif that I have overlooked
>>> and causes my code to be skipped if there's no ifconfig_IF_ipv6
>>> variable defined in rc.conf(5).
>>>
>>> -Kimmo
>>
>> Yeah, this is problem in network.subr. An interface is not recognized
>> as IPv6 capable if the interface is not in "ipv6_network_interfaces"
>> and there's no "ifconfig_IF_ipv6" in rc.conf(5), bummer. For IPv4 it
>> "just works" because the interface is always assumed to be IPv4
>> capable.
>
> Ok, I used ifconfig_em0_ipv6="up" and it worked. So it looks like this:
>
> ipv6_activate_all_interfaces="NO"
> ipv6_network_interfaces="em0"
> ifconfig_em0_ipv6="up"
> ipv6_addrs_em0="2001:6a0:1cb::1-ff/64"
> ipv6_defaultrouter="2001:6a0:1cb::"
>
> Good job, thank you! :)
>
> --
> best regards,
> Lukasz Wasikowski

I'm looking into fixing the issue so you could just have the
ipv6_addrs_em0 line in rc.conf. However I don't want to flood the PR
and this mailing list with different versions of the patch. I want to
get it right next time. Stay tuned.

-Kimmo
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: ipv6_addrs_IF aliases in rc.conf(5)

2012-12-22 Thread Łukasz Wąsikowski
W dniu 2012-12-22 04:41, Kimmo Paasiala pisze:

>>> It looks like the reason for the difference to ipv4_addrs_IF is that
>>> the "alias" parameter for ifconfig(8) operates differently for IPv6
>>> addresses, the first address of an interface can't be added with
>>> "alias", for IPv4 it does not care. I'll have to dig deeper but that's
>>> what the problem seems to be.
>>>
>>> -Kimmo
>>
>> The 'alias' parameter of ifconfig(8) is not the problem on the first
>> ipv6 address, I have verified that. However, there's probably
>> something in network.subr or /etc/rc.d/netif that I have overlooked
>> and causes my code to be skipped if there's no ifconfig_IF_ipv6
>> variable defined in rc.conf(5).
>>
>> -Kimmo
> 
> Yeah, this is problem in network.subr. An interface is not recognized
> as IPv6 capable if the interface is not in "ipv6_network_interfaces"
> and there's no "ifconfig_IF_ipv6" in rc.conf(5), bummer. For IPv4 it
> "just works" because the interface is always assumed to be IPv4
> capable.

Ok, I used ifconfig_em0_ipv6="up" and it worked. So it looks like this:

ipv6_activate_all_interfaces="NO"
ipv6_network_interfaces="em0"
ifconfig_em0_ipv6="up"
ipv6_addrs_em0="2001:6a0:1cb::1-ff/64"
ipv6_defaultrouter="2001:6a0:1cb::"

Good job, thank you! :)

-- 
best regards,
Lukasz Wasikowski
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2012-12-21 Thread Kimmo Paasiala
On Sat, Dec 22, 2012 at 5:09 AM, Kimmo Paasiala  wrote:
> On Sat, Dec 22, 2012 at 3:19 AM, Kimmo Paasiala  wrote:
>> On Sat, Dec 22, 2012 at 1:38 AM, Łukasz Wąsikowski
>>  wrote:
>>> W dniu 2012-12-21 13:23, Kimmo Paasiala pisze:
 On Fri, Dec 21, 2012 at 5:43 AM, Kimmo Paasiala  wrote:
> On Thu, Dec 20, 2012 at 3:27 PM, Jilles Tjoelker  wrote:
>> On Thu, Dec 20, 2012 at 01:04:34PM +0200, Kimmo Paasiala wrote:
>>> A question related to this for those who have been doing work on the
>>> rc(8) scripts. Can I assume that /usr/bin is available when
>>> network.subr functions are used? Doing calculations on hexadecimal
>>> numbers is going to be very awkward if I can't use for example bc(1).
>>
>> You cannot assume that /usr/bin is available when setting up the
>> network. It may be that /usr is mounted via NFS.
>>
>> You can use hexadecimal numbers (prefixed with 0x) in $((...))
>> expressions. In FreeBSD 9.0 or newer, sh has a printf builtin you can
>> use; in older versions you can use hexdigit and hexprint from
>> network.subr.
>>
>> --
>> Jilles Tjoelker
>
> Thanks, I've rewitten my patch to support ranges. It is attached in
> this message.
>
> Again it's against a very recent 9-STABLE, I still haven't found time
> to see if it applies to CURRENT.
>
> It does allow you to do crazy stuff like
>
> ipv6_addrs_re0="2001:db8::::1-/64"
>
> However I didn't find anything to limit the number of aliases in the
> ipv4 version of the function either.
>
> Please test it :)
>
>
> Then a question about the PR
> (http://www.freebsd.org/cgi/query-pr.cgi?pr=174225) I wrote, how can I
> attach this new patch to it? The submit follow up -button fires up my
> email client and I'm not so sure how to submit a new patch for the PR
> in an email in such a way that it appears properly formatted in the
> PR.
>
> Regards,
>
> Kimmo Paasiala

 PR updated with the new patch.
>>>
>>> Your patch applied cleanly, but it's not working or I am doing something
>>> wrong.
>>>
>>> root@freebsd:~ # uname -a
>>> FreeBSD freebsd 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #1 r244567: Fri
>>> Dec 21 23:57:28 CET 2012 root@freebsd:/usr/obj/usr/src/sys/GENERIC
>>> amd64
>>>
>>> root@freebsd:~ # grep -Ev '^[[:space:]]*#|^$' /etc/rc.conf
>>> hostname="freebsd"
>>> ifconfig_em0="up"
>>> ipv4_addrs_em0="192.168.168.20-24/24"
>>> defaultrouter="192.168.168.1"
>>> ipv6_activate_all_interfaces="YES"
>>> ipv6_addrs_em0="2001:6a0:1cb::1-6/64"
>>> ipv6_defaultrouter="2001:6a0:1cb::"
>>> sshd_enable="YES"
>>> dumpdev="NO"
>>> named_enable="YES"
>>>
>>> root@freebsd:~ # ifconfig
>>> em0: flags=8843 metric 0 mtu 1500
>>> options=9b
>>> ether 08:00:27:02:83:71
>>> inet6 fe80::a00:27ff:fe02:8371%em0 prefixlen 64 scopeid 0x1
>>> inet 192.168.168.20 netmask 0xff00 broadcast 192.168.168.255
>>> inet 192.168.168.21 netmask 0x broadcast 192.168.168.21
>>> inet 192.168.168.22 netmask 0x broadcast 192.168.168.22
>>> inet 192.168.168.23 netmask 0x broadcast 192.168.168.23
>>> inet 192.168.168.24 netmask 0x broadcast 192.168.168.24
>>> nd6 options=21
>>> media: Ethernet autoselect (1000baseT )
>>> status: active
>>> lo0: flags=8049 metric 0 mtu 16384
>>> options=63
>>> inet6 ::1 prefixlen 128
>>> inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
>>> inet 127.0.0.1 netmask 0xff00
>>> nd6 options=21
>>>
>>> --
>>> best regards,
>>> Lukasz Wasikowski
>>
>> You need to first add a single ipv6 address using the
>> ifconfig_em0_ipv6 -syntax.
>>
>> ifconfig_em0_ipv6="2001:6a0:1cb::1/64"
>>
>> And then this should add the rest of the addresses
>>
>> ipv6_addrs_em0="2001:6a0:1cb::2-6/64"
>>
>> It looks like the reason for the difference to ipv4_addrs_IF is that
>> the "alias" parameter for ifconfig(8) operates differently for IPv6
>> addresses, the first address of an interface can't be added with
>> "alias", for IPv4 it does not care. I'll have to dig deeper but that's
>> what the problem seems to be.
>>
>> -Kimmo
>
> The 'alias' parameter of ifconfig(8) is not the problem on the first
> ipv6 address, I have verified that. However, there's probably
> something in network.subr or /etc/rc.d/netif that I have overlooked
> and causes my code to be skipped if there's no ifconfig_IF_ipv6
> variable defined in rc.conf(5).
>
> -Kimmo

Yeah, this is problem in network.subr. An interface is not recognized
as IPv6 capable if the interface is not in "ipv6_network_interfaces"
and there's no "ifconfig_IF_ipv6" in rc.conf(5), bummer. For IPv4 it
"just works" because the interface is always assumed to be IPv4
capable.

-Kimmo
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.or

Re: ipv6_addrs_IF aliases in rc.conf(5)

2012-12-21 Thread Kimmo Paasiala
On Sat, Dec 22, 2012 at 3:19 AM, Kimmo Paasiala  wrote:
> On Sat, Dec 22, 2012 at 1:38 AM, Łukasz Wąsikowski
>  wrote:
>> W dniu 2012-12-21 13:23, Kimmo Paasiala pisze:
>>> On Fri, Dec 21, 2012 at 5:43 AM, Kimmo Paasiala  wrote:
 On Thu, Dec 20, 2012 at 3:27 PM, Jilles Tjoelker  wrote:
> On Thu, Dec 20, 2012 at 01:04:34PM +0200, Kimmo Paasiala wrote:
>> A question related to this for those who have been doing work on the
>> rc(8) scripts. Can I assume that /usr/bin is available when
>> network.subr functions are used? Doing calculations on hexadecimal
>> numbers is going to be very awkward if I can't use for example bc(1).
>
> You cannot assume that /usr/bin is available when setting up the
> network. It may be that /usr is mounted via NFS.
>
> You can use hexadecimal numbers (prefixed with 0x) in $((...))
> expressions. In FreeBSD 9.0 or newer, sh has a printf builtin you can
> use; in older versions you can use hexdigit and hexprint from
> network.subr.
>
> --
> Jilles Tjoelker

 Thanks, I've rewitten my patch to support ranges. It is attached in
 this message.

 Again it's against a very recent 9-STABLE, I still haven't found time
 to see if it applies to CURRENT.

 It does allow you to do crazy stuff like

 ipv6_addrs_re0="2001:db8::::1-/64"

 However I didn't find anything to limit the number of aliases in the
 ipv4 version of the function either.

 Please test it :)


 Then a question about the PR
 (http://www.freebsd.org/cgi/query-pr.cgi?pr=174225) I wrote, how can I
 attach this new patch to it? The submit follow up -button fires up my
 email client and I'm not so sure how to submit a new patch for the PR
 in an email in such a way that it appears properly formatted in the
 PR.

 Regards,

 Kimmo Paasiala
>>>
>>> PR updated with the new patch.
>>
>> Your patch applied cleanly, but it's not working or I am doing something
>> wrong.
>>
>> root@freebsd:~ # uname -a
>> FreeBSD freebsd 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #1 r244567: Fri
>> Dec 21 23:57:28 CET 2012 root@freebsd:/usr/obj/usr/src/sys/GENERIC
>> amd64
>>
>> root@freebsd:~ # grep -Ev '^[[:space:]]*#|^$' /etc/rc.conf
>> hostname="freebsd"
>> ifconfig_em0="up"
>> ipv4_addrs_em0="192.168.168.20-24/24"
>> defaultrouter="192.168.168.1"
>> ipv6_activate_all_interfaces="YES"
>> ipv6_addrs_em0="2001:6a0:1cb::1-6/64"
>> ipv6_defaultrouter="2001:6a0:1cb::"
>> sshd_enable="YES"
>> dumpdev="NO"
>> named_enable="YES"
>>
>> root@freebsd:~ # ifconfig
>> em0: flags=8843 metric 0 mtu 1500
>> options=9b
>> ether 08:00:27:02:83:71
>> inet6 fe80::a00:27ff:fe02:8371%em0 prefixlen 64 scopeid 0x1
>> inet 192.168.168.20 netmask 0xff00 broadcast 192.168.168.255
>> inet 192.168.168.21 netmask 0x broadcast 192.168.168.21
>> inet 192.168.168.22 netmask 0x broadcast 192.168.168.22
>> inet 192.168.168.23 netmask 0x broadcast 192.168.168.23
>> inet 192.168.168.24 netmask 0x broadcast 192.168.168.24
>> nd6 options=21
>> media: Ethernet autoselect (1000baseT )
>> status: active
>> lo0: flags=8049 metric 0 mtu 16384
>> options=63
>> inet6 ::1 prefixlen 128
>> inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
>> inet 127.0.0.1 netmask 0xff00
>> nd6 options=21
>>
>> --
>> best regards,
>> Lukasz Wasikowski
>
> You need to first add a single ipv6 address using the
> ifconfig_em0_ipv6 -syntax.
>
> ifconfig_em0_ipv6="2001:6a0:1cb::1/64"
>
> And then this should add the rest of the addresses
>
> ipv6_addrs_em0="2001:6a0:1cb::2-6/64"
>
> It looks like the reason for the difference to ipv4_addrs_IF is that
> the "alias" parameter for ifconfig(8) operates differently for IPv6
> addresses, the first address of an interface can't be added with
> "alias", for IPv4 it does not care. I'll have to dig deeper but that's
> what the problem seems to be.
>
> -Kimmo

The 'alias' parameter of ifconfig(8) is not the problem on the first
ipv6 address, I have verified that. However, there's probably
something in network.subr or /etc/rc.d/netif that I have overlooked
and causes my code to be skipped if there's no ifconfig_IF_ipv6
variable defined in rc.conf(5).

-Kimmo
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: ipv6_addrs_IF aliases in rc.conf(5)

2012-12-21 Thread Kimmo Paasiala
On Sat, Dec 22, 2012 at 1:38 AM, Łukasz Wąsikowski
 wrote:
> W dniu 2012-12-21 13:23, Kimmo Paasiala pisze:
>> On Fri, Dec 21, 2012 at 5:43 AM, Kimmo Paasiala  wrote:
>>> On Thu, Dec 20, 2012 at 3:27 PM, Jilles Tjoelker  wrote:
 On Thu, Dec 20, 2012 at 01:04:34PM +0200, Kimmo Paasiala wrote:
> A question related to this for those who have been doing work on the
> rc(8) scripts. Can I assume that /usr/bin is available when
> network.subr functions are used? Doing calculations on hexadecimal
> numbers is going to be very awkward if I can't use for example bc(1).

 You cannot assume that /usr/bin is available when setting up the
 network. It may be that /usr is mounted via NFS.

 You can use hexadecimal numbers (prefixed with 0x) in $((...))
 expressions. In FreeBSD 9.0 or newer, sh has a printf builtin you can
 use; in older versions you can use hexdigit and hexprint from
 network.subr.

 --
 Jilles Tjoelker
>>>
>>> Thanks, I've rewitten my patch to support ranges. It is attached in
>>> this message.
>>>
>>> Again it's against a very recent 9-STABLE, I still haven't found time
>>> to see if it applies to CURRENT.
>>>
>>> It does allow you to do crazy stuff like
>>>
>>> ipv6_addrs_re0="2001:db8::::1-/64"
>>>
>>> However I didn't find anything to limit the number of aliases in the
>>> ipv4 version of the function either.
>>>
>>> Please test it :)
>>>
>>>
>>> Then a question about the PR
>>> (http://www.freebsd.org/cgi/query-pr.cgi?pr=174225) I wrote, how can I
>>> attach this new patch to it? The submit follow up -button fires up my
>>> email client and I'm not so sure how to submit a new patch for the PR
>>> in an email in such a way that it appears properly formatted in the
>>> PR.
>>>
>>> Regards,
>>>
>>> Kimmo Paasiala
>>
>> PR updated with the new patch.
>
> Your patch applied cleanly, but it's not working or I am doing something
> wrong.
>
> root@freebsd:~ # uname -a
> FreeBSD freebsd 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #1 r244567: Fri
> Dec 21 23:57:28 CET 2012 root@freebsd:/usr/obj/usr/src/sys/GENERIC
> amd64
>
> root@freebsd:~ # grep -Ev '^[[:space:]]*#|^$' /etc/rc.conf
> hostname="freebsd"
> ifconfig_em0="up"
> ipv4_addrs_em0="192.168.168.20-24/24"
> defaultrouter="192.168.168.1"
> ipv6_activate_all_interfaces="YES"
> ipv6_addrs_em0="2001:6a0:1cb::1-6/64"
> ipv6_defaultrouter="2001:6a0:1cb::"
> sshd_enable="YES"
> dumpdev="NO"
> named_enable="YES"
>
> root@freebsd:~ # ifconfig
> em0: flags=8843 metric 0 mtu 1500
> options=9b
> ether 08:00:27:02:83:71
> inet6 fe80::a00:27ff:fe02:8371%em0 prefixlen 64 scopeid 0x1
> inet 192.168.168.20 netmask 0xff00 broadcast 192.168.168.255
> inet 192.168.168.21 netmask 0x broadcast 192.168.168.21
> inet 192.168.168.22 netmask 0x broadcast 192.168.168.22
> inet 192.168.168.23 netmask 0x broadcast 192.168.168.23
> inet 192.168.168.24 netmask 0x broadcast 192.168.168.24
> nd6 options=21
> media: Ethernet autoselect (1000baseT )
> status: active
> lo0: flags=8049 metric 0 mtu 16384
> options=63
> inet6 ::1 prefixlen 128
> inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
> inet 127.0.0.1 netmask 0xff00
> nd6 options=21
>
> --
> best regards,
> Lukasz Wasikowski

You need to first add a single ipv6 address using the
ifconfig_em0_ipv6 -syntax.

ifconfig_em0_ipv6="2001:6a0:1cb::1/64"

And then this should add the rest of the addresses

ipv6_addrs_em0="2001:6a0:1cb::2-6/64"

It looks like the reason for the difference to ipv4_addrs_IF is that
the "alias" parameter for ifconfig(8) operates differently for IPv6
addresses, the first address of an interface can't be added with
"alias", for IPv4 it does not care. I'll have to dig deeper but that's
what the problem seems to be.

-Kimmo
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: ipv6_addrs_IF aliases in rc.conf(5)

2012-12-21 Thread Łukasz Wąsikowski
W dniu 2012-12-21 13:23, Kimmo Paasiala pisze:
> On Fri, Dec 21, 2012 at 5:43 AM, Kimmo Paasiala  wrote:
>> On Thu, Dec 20, 2012 at 3:27 PM, Jilles Tjoelker  wrote:
>>> On Thu, Dec 20, 2012 at 01:04:34PM +0200, Kimmo Paasiala wrote:
 A question related to this for those who have been doing work on the
 rc(8) scripts. Can I assume that /usr/bin is available when
 network.subr functions are used? Doing calculations on hexadecimal
 numbers is going to be very awkward if I can't use for example bc(1).
>>>
>>> You cannot assume that /usr/bin is available when setting up the
>>> network. It may be that /usr is mounted via NFS.
>>>
>>> You can use hexadecimal numbers (prefixed with 0x) in $((...))
>>> expressions. In FreeBSD 9.0 or newer, sh has a printf builtin you can
>>> use; in older versions you can use hexdigit and hexprint from
>>> network.subr.
>>>
>>> --
>>> Jilles Tjoelker
>>
>> Thanks, I've rewitten my patch to support ranges. It is attached in
>> this message.
>>
>> Again it's against a very recent 9-STABLE, I still haven't found time
>> to see if it applies to CURRENT.
>>
>> It does allow you to do crazy stuff like
>>
>> ipv6_addrs_re0="2001:db8::::1-/64"
>>
>> However I didn't find anything to limit the number of aliases in the
>> ipv4 version of the function either.
>>
>> Please test it :)
>>
>>
>> Then a question about the PR
>> (http://www.freebsd.org/cgi/query-pr.cgi?pr=174225) I wrote, how can I
>> attach this new patch to it? The submit follow up -button fires up my
>> email client and I'm not so sure how to submit a new patch for the PR
>> in an email in such a way that it appears properly formatted in the
>> PR.
>>
>> Regards,
>>
>> Kimmo Paasiala
> 
> PR updated with the new patch.

Your patch applied cleanly, but it's not working or I am doing something
wrong.

root@freebsd:~ # uname -a
FreeBSD freebsd 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #1 r244567: Fri
Dec 21 23:57:28 CET 2012 root@freebsd:/usr/obj/usr/src/sys/GENERIC
amd64

root@freebsd:~ # grep -Ev '^[[:space:]]*#|^$' /etc/rc.conf
hostname="freebsd"
ifconfig_em0="up"
ipv4_addrs_em0="192.168.168.20-24/24"
defaultrouter="192.168.168.1"
ipv6_activate_all_interfaces="YES"
ipv6_addrs_em0="2001:6a0:1cb::1-6/64"
ipv6_defaultrouter="2001:6a0:1cb::"
sshd_enable="YES"
dumpdev="NO"
named_enable="YES"

root@freebsd:~ # ifconfig
em0: flags=8843 metric 0 mtu 1500
options=9b
ether 08:00:27:02:83:71
inet6 fe80::a00:27ff:fe02:8371%em0 prefixlen 64 scopeid 0x1
inet 192.168.168.20 netmask 0xff00 broadcast 192.168.168.255
inet 192.168.168.21 netmask 0x broadcast 192.168.168.21
inet 192.168.168.22 netmask 0x broadcast 192.168.168.22
inet 192.168.168.23 netmask 0x broadcast 192.168.168.23
inet 192.168.168.24 netmask 0x broadcast 192.168.168.24
nd6 options=21
media: Ethernet autoselect (1000baseT )
status: active
lo0: flags=8049 metric 0 mtu 16384
options=63
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
inet 127.0.0.1 netmask 0xff00
nd6 options=21

-- 
best regards,
Lukasz Wasikowski
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2012-12-21 Thread Kimmo Paasiala
On Fri, Dec 21, 2012 at 5:43 AM, Kimmo Paasiala  wrote:
> On Thu, Dec 20, 2012 at 3:27 PM, Jilles Tjoelker  wrote:
>> On Thu, Dec 20, 2012 at 01:04:34PM +0200, Kimmo Paasiala wrote:
>>> A question related to this for those who have been doing work on the
>>> rc(8) scripts. Can I assume that /usr/bin is available when
>>> network.subr functions are used? Doing calculations on hexadecimal
>>> numbers is going to be very awkward if I can't use for example bc(1).
>>
>> You cannot assume that /usr/bin is available when setting up the
>> network. It may be that /usr is mounted via NFS.
>>
>> You can use hexadecimal numbers (prefixed with 0x) in $((...))
>> expressions. In FreeBSD 9.0 or newer, sh has a printf builtin you can
>> use; in older versions you can use hexdigit and hexprint from
>> network.subr.
>>
>> --
>> Jilles Tjoelker
>
> Thanks, I've rewitten my patch to support ranges. It is attached in
> this message.
>
> Again it's against a very recent 9-STABLE, I still haven't found time
> to see if it applies to CURRENT.
>
> It does allow you to do crazy stuff like
>
> ipv6_addrs_re0="2001:db8::::1-/64"
>
> However I didn't find anything to limit the number of aliases in the
> ipv4 version of the function either.
>
> Please test it :)
>
>
> Then a question about the PR
> (http://www.freebsd.org/cgi/query-pr.cgi?pr=174225) I wrote, how can I
> attach this new patch to it? The submit follow up -button fires up my
> email client and I'm not so sure how to submit a new patch for the PR
> in an email in such a way that it appears properly formatted in the
> PR.
>
> Regards,
>
> Kimmo Paasiala

PR updated with the new patch.

-Kimmo
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2012-12-20 Thread Kimmo Paasiala
On Thu, Dec 20, 2012 at 3:27 PM, Jilles Tjoelker  wrote:
> On Thu, Dec 20, 2012 at 01:04:34PM +0200, Kimmo Paasiala wrote:
>> A question related to this for those who have been doing work on the
>> rc(8) scripts. Can I assume that /usr/bin is available when
>> network.subr functions are used? Doing calculations on hexadecimal
>> numbers is going to be very awkward if I can't use for example bc(1).
>
> You cannot assume that /usr/bin is available when setting up the
> network. It may be that /usr is mounted via NFS.
>
> You can use hexadecimal numbers (prefixed with 0x) in $((...))
> expressions. In FreeBSD 9.0 or newer, sh has a printf builtin you can
> use; in older versions you can use hexdigit and hexprint from
> network.subr.
>
> --
> Jilles Tjoelker

Thanks, I've rewitten my patch to support ranges. It is attached in
this message.

Again it's against a very recent 9-STABLE, I still haven't found time
to see if it applies to CURRENT.

It does allow you to do crazy stuff like

ipv6_addrs_re0="2001:db8::::1-/64"

However I didn't find anything to limit the number of aliases in the
ipv4 version of the function either.

Please test it :)


Then a question about the PR
(http://www.freebsd.org/cgi/query-pr.cgi?pr=174225) I wrote, how can I
attach this new patch to it? The submit follow up -button fires up my
email client and I'm not so sure how to submit a new patch for the PR
in an email in such a way that it appears properly formatted in the
PR.

Regards,

Kimmo Paasiala
Index: network.subr
===
--- network.subr(revision 244523)
+++ network.subr(working copy)
@@ -562,6 +562,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
 
@@ -684,6 +685,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
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: ipv6_addrs_IF aliases in rc.conf(5)

2012-12-20 Thread Jilles Tjoelker
On Thu, Dec 20, 2012 at 01:04:34PM +0200, Kimmo Paasiala wrote:
> A question related to this for those who have been doing work on the
> rc(8) scripts. Can I assume that /usr/bin is available when
> network.subr functions are used? Doing calculations on hexadecimal
> numbers is going to be very awkward if I can't use for example bc(1).

You cannot assume that /usr/bin is available when setting up the
network. It may be that /usr is mounted via NFS.

You can use hexadecimal numbers (prefixed with 0x) in $((...))
expressions. In FreeBSD 9.0 or newer, sh has a printf builtin you can
use; in older versions you can use hexdigit and hexprint from
network.subr.

-- 
Jilles Tjoelker
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2012-12-20 Thread Kimmo Paasiala
On Wed, Dec 19, 2012 at 11:47 PM, Kimmo Paasiala  wrote:
> On Wed, Dec 19, 2012 at 3:46 PM, Łukasz Wąsikowski
>  wrote:
>> W dniu 2012-12-19 07:14, Kimmo Paasiala pisze:
>>
>>>> I wrote a small patch for /etc/network.subr to add support for
>>>> ipv6_addrs_IF aliases in rc.conf(5) to match the already existing
>>>> ipv4_addrs_IF aliases for ipv4 addresses. With this patch the ipv6
>>>> aliases can be written like:
>>
>> [...]
>>
>>> Did anyone try my patch? I thought it would be nice to have the
>>> ipv6_addrs_IF syntax supported to complement the existing
>>> ipv4_addrs_IF alias syntax.
>>
>> Can I use range syntax in it like in ipv4? I mean something like:
>>
>> ipv4_addrs_lagg0="x.x.x.10-30/22"
>>
>> That feature would be very nice to have for ipv6.
>>
>> --
>> best regards,
>> Lukasz Wasikowski
>
> I have to admit I overlooked the possibility to use ranges like that.
> It doesn't look too hard to add that feature as well for ipv6 aliases
> using the existing code for ipv4 aliases. I'll prepare a new patch and
> update the PR when I have it working.
>
> -Kimmo

A question related to this for those who have been doing work on the
rc(8) scripts. Can I assume that /usr/bin is available when
network.subr functions are used? Doing calculations on hexadecimal
numbers is going to be very awkward if I can't use for example bc(1).

-Kimmo
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: ipv6_addrs_IF aliases in rc.conf(5)

2012-12-19 Thread Kimmo Paasiala
On Wed, Dec 19, 2012 at 3:46 PM, Łukasz Wąsikowski
 wrote:
> W dniu 2012-12-19 07:14, Kimmo Paasiala pisze:
>
>>> I wrote a small patch for /etc/network.subr to add support for
>>> ipv6_addrs_IF aliases in rc.conf(5) to match the already existing
>>> ipv4_addrs_IF aliases for ipv4 addresses. With this patch the ipv6
>>> aliases can be written like:
>
> [...]
>
>> Did anyone try my patch? I thought it would be nice to have the
>> ipv6_addrs_IF syntax supported to complement the existing
>> ipv4_addrs_IF alias syntax.
>
> Can I use range syntax in it like in ipv4? I mean something like:
>
> ipv4_addrs_lagg0="x.x.x.10-30/22"
>
> That feature would be very nice to have for ipv6.
>
> --
> best regards,
> Lukasz Wasikowski

I have to admit I overlooked the possibility to use ranges like that.
It doesn't look too hard to add that feature as well for ipv6 aliases
using the existing code for ipv4 aliases. I'll prepare a new patch and
update the PR when I have it working.

-Kimmo
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: ipv6_addrs_IF aliases in rc.conf(5)

2012-12-19 Thread Łukasz Wąsikowski
W dniu 2012-12-19 07:14, Kimmo Paasiala pisze:

>> I wrote a small patch for /etc/network.subr to add support for
>> ipv6_addrs_IF aliases in rc.conf(5) to match the already existing
>> ipv4_addrs_IF aliases for ipv4 addresses. With this patch the ipv6
>> aliases can be written like:

[...]

> Did anyone try my patch? I thought it would be nice to have the
> ipv6_addrs_IF syntax supported to complement the existing
> ipv4_addrs_IF alias syntax.

Can I use range syntax in it like in ipv4? I mean something like:

ipv4_addrs_lagg0="x.x.x.10-30/22"

That feature would be very nice to have for ipv6.

-- 
best regards,
Lukasz Wasikowski
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: ipv6_addrs_IF aliases in rc.conf(5)

2012-12-18 Thread Kimmo Paasiala
On Fri, Dec 7, 2012 at 12:42 PM, Kimmo Paasiala  wrote:
> Hello,
>
> I wrote a small patch for /etc/network.subr to add support for
> ipv6_addrs_IF aliases in rc.conf(5) to match the already existing
> ipv4_addrs_IF aliases for ipv4 addresses. With this patch the ipv6
> aliases can be written like:
>
> ipv6_addrs_re0="2001:db8::::1/64 2001:db8::::2/64"
>
> Only this syntax is supported, it's not possible to use the "prefixlen
> nn" syntax in the list.
>
> The patch is against a recent 9-STABLE, last changed rev of
> network.subr on my SVN checkout is r242187. I don't have a CURRENT
> system to test if it applies to CURRENT as well.
>
> The patch can be found attached to a PR I sent:
>
> http://www.freebsd.org/cgi/query-pr.cgi?pr=174225
>
>
> I wrote this patch inspired by a question on the FreeBSD forums:
>
> http://forums.freebsd.org/showthread.php?t=36136
>
> Please test and report if it works for you :)
>
>
> Regards,
> Kimmo Paasiala

Hello,

Did anyone try my patch? I thought it would be nice to have the
ipv6_addrs_IF syntax supported to complement the existing
ipv4_addrs_IF alias syntax.

-Kimmo
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


ipv6_addrs_IF aliases in rc.conf(5)

2012-12-07 Thread Kimmo Paasiala
Hello,

I wrote a small patch for /etc/network.subr to add support for
ipv6_addrs_IF aliases in rc.conf(5) to match the already existing
ipv4_addrs_IF aliases for ipv4 addresses. With this patch the ipv6
aliases can be written like:

ipv6_addrs_re0="2001:db8::::1/64 2001:db8::::2/64"

Only this syntax is supported, it's not possible to use the "prefixlen
nn" syntax in the list.

The patch is against a recent 9-STABLE, last changed rev of
network.subr on my SVN checkout is r242187. I don't have a CURRENT
system to test if it applies to CURRENT as well.

The patch can be found attached to a PR I sent:

http://www.freebsd.org/cgi/query-pr.cgi?pr=174225


I wrote this patch inspired by a question on the FreeBSD forums:

http://forums.freebsd.org/showthread.php?t=36136

Please test and report if it works for you :)


Regards,
Kimmo Paasiala
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"