From owner-svn-src-all@FreeBSD.ORG Sat Sep 26 18:59:01 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2F073106566B; Sat, 26 Sep 2009 18:59:01 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1CD5A8FC12; Sat, 26 Sep 2009 18:59:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8QIx1GB067494; Sat, 26 Sep 2009 18:59:01 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8QIx1MU067487; Sat, 26 Sep 2009 18:59:01 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <200909261859.n8QIx1MU067487@svn.freebsd.org> From: Hiroki Sato Date: Sat, 26 Sep 2009 18:59:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197526 - in head: . etc etc/rc.d sbin/ifconfig share/man/man5 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Sep 2009 18:59:01 -0000 Author: hrs Date: Sat Sep 26 18:59:00 2009 New Revision: 197526 URL: http://svn.freebsd.org/changeset/base/197526 Log: Fix several logic bugs in the previous IPv6 variable change and re-add $ipv6_enable support for backward compatibility. From UPDATING: 1. To use IPv6, simply define $ifconfig_IF_ipv6 like $ifconfig_IF for IPv4. For aliases, $ifconfig_IF_aliasN should be used. Note that both variables need the "inet6" keyword at the head. Do not set $ipv6_network_interfaces manually if you do not understand what you are doing. It is not needed in most cases. $ipv6_ifconfig_IF and $ipv6_ifconfig_IF_aliasN still work, but they are obsolete. 2. $ipv6_enable is obsolete. Use $ipv6_prefer and/or "inet6 accept_rtadv" keyword in ifconfig(8) instead. If you define $ipv6_enable=YES, it means $ipv6_prefer=YES and all configured interfaces have "inet6 accept_rtadv" in the $ifconfig_IF_ipv6. These are for backward compatibility. 3. A new variable $ipv6_prefer has been added. If NO, IPv6 functionality of interfaces with no corresponding $ifconfig_IF_ipv6 is disabled by using "inet6 ifdisabled" flag, and the default address selection policy of ip6addrctl(8) is the IPv4-preferred one (see rc.d/ip6addrctl for more details). Note that if you want to configure IPv6 functionality on the disabled interfaces after boot, first you need to clear the flag by using ifconfig(8) like: ifconfig em0 inet6 -ifdisabled If YES, the default address selection policy is set as IPv6-preferred. The default value of $ipv6_prefer is NO. 4. If your system need to receive Router Advertisement messages, define "inet6 accept_rtadv" in $ifconfig_IF_ipv6. The rc(8) scripts automatically invoke rtsol(8) when the interface becomes UP. The Router Advertisement messages are used for SLAAC (State-Less Address AutoConfiguration). Modified: head/UPDATING head/etc/network.subr head/etc/rc.d/ip6addrctl head/etc/rc.d/netif head/sbin/ifconfig/ifconfig.8 head/share/man/man5/rc.conf.5 Modified: head/UPDATING ============================================================================== --- head/UPDATING Sat Sep 26 18:23:16 2009 (r197525) +++ head/UPDATING Sat Sep 26 18:59:00 2009 (r197526) @@ -22,10 +22,61 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9. machines to maximize performance. (To disable malloc debugging, run ln -s aj /etc/malloc.conf.) +20090926: + The rc.d/network_ipv6, IPv6 configuration script has been integrated + into rc.d/netif. The changes are the following: + + 1. To use IPv6, simply define $ifconfig_IF_ipv6 like $ifconfig_IF + for IPv4. For aliases, $ifconfig_IF_aliasN should be used. + Note that both variables need the "inet6" keyword at the head. + + Do not set $ipv6_network_interfaces manually if you do not + understand what you are doing. It is not needed in most cases. + + $ipv6_ifconfig_IF and $ipv6_ifconfig_IF_aliasN still work, but + they are obsolete. + + 2. $ipv6_enable is obsolete. Use $ipv6_prefer and + "inet6 accept_rtadv" keyword in ifconfig(8) instead. + + If you define $ipv6_enable=YES, it means $ipv6_prefer=YES and + all configured interfaces have "inet6 accept_rtadv" in the + $ifconfig_IF_ipv6. These are for backward compatibility. + + 3. A new variable $ipv6_prefer has been added. If NO, IPv6 + functionality of interfaces with no corresponding + $ifconfig_IF_ipv6 is disabled by using "inet6 ifdisabled" flag, + and the default address selection policy of ip6addrctl(8) + is the IPv4-preferred one (see rc.d/ip6addrctl for more details). + Note that if you want to configure IPv6 functionality on the + disabled interfaces after boot, first you need to clear the flag by + using ifconfig(8) like: + + ifconfig em0 inet6 -ifdisabled + + If YES, the default address selection policy is set as + IPv6-preferred. + + The default value of $ipv6_prefer is NO. + + 4. If your system need to receive Router Advertisement messages, + define "inet6 accept_rtadv" in $ifconfig_IF_ipv6. The rc(8) + scripts automatically invoke rtsol(8) when the interface becomes + UP. The Router Advertisement messages are used for SLAAC + (State-Less Address AutoConfiguration). + 20090922: 802.11s D3.03 support was committed. This is incompatible with the previous code, which was based on D3.0. +20090912: + A sysctl variable net.inet6.ip6.accept_rtadv now sets the default value + of a per-interface flag ND6_IFF_ACCEPT_RTADV, not a global knob to + control whether accepting Router Advertisement messages or not. + Also, a per-interface flag ND6_IFF_AUTO_LINKLOCAL has been added and + a sysctl variable net.inet6.ip6.auto_linklocal is its default value. + The ifconfig(8) utility now supports these flags. + 20090910: ZFS snapshots are now mounted with MNT_IGNORE flag. Use -v option for mount(8) and -a option for df(1) to see them. Modified: head/etc/network.subr ============================================================================== --- head/etc/network.subr Sat Sep 26 18:23:16 2009 (r197525) +++ head/etc/network.subr Sat Sep 26 18:59:00 2009 (r197526) @@ -97,15 +97,26 @@ ifconfig_up() if afexists inet6; then if ipv6if $1; then if checkyesno ipv6_gateway_enable; then - _ipv6_opts="-accept_rtadv auto_linklocal" - else - _ipv6_opts="auto_linklocal" + _ipv6_opts="-accept_rtadv" fi else - _ipv6_opts="-auto_linklocal ifdisabled" + if checkyesno ipv6_prefer; then + _ipv6_opts="-ifdisabled" + else + _ipv6_opts="ifdisabled" + fi + + # backward compatibility: $ipv6_enable + case $ipv6_enable in + [Yy][Ee][Ss]) + _ipv6_opts="${_ipv6_opts} accept_rtadv" + ;; + esac fi - ifconfig $1 inet6 ${_ipv6_opts} + if [ -n "${_ipv6_opts}" ]; then + ifconfig $1 inet6 ${_ipv6_opts} + fi # ifconfig_IF_ipv6 ifconfig_args=`ifconfig_getargs $1 ipv6` @@ -382,7 +393,7 @@ noafif() # 1 otherwise. ipv6if() { - local _if i + local _if _tmpargs i _if=$1 if ! afexists inet6; then @@ -396,6 +407,18 @@ ipv6if() ;; esac + # True if $ifconfig_IF_ipv6 is defined. + _tmpargs=`_ifconfig_getargs $_if ipv6` + if [ -n "${_tmpargs}" ]; then + return 0 + fi + + # backward compatibility: True if $ipv6_ifconfig_IF is defined. + _tmpargs=`get_if_var $_if ipv6_ifconfig_IF` + if [ -n "${_tmpargs}" ]; then + return 0 + fi + case "${ipv6_network_interfaces}" in [Aa][Uu][Tt][Oo]) return 0 @@ -431,17 +454,30 @@ ipv6_autoconfif() if checkyesno ipv6_gateway_enable; then return 1 fi + _tmpargs=`get_if_var $_if ipv6_prefix_IF` + if [ -n "${_tmpargs}" ]; then + return 1 + fi case $_if in lo0|\ stf[0-9]*|\ faith[0-9]*|\ lp[0-9]*|\ - sl[0-9]*) + sl[0-9]*|\ + pflog[0-9]*|\ + pfsync[0-9]*) return 1 ;; esac + # backward compatibility: $ipv6_enable + case $ipv6_enable in + [Yy][Ee][Ss]) + return 0 + ;; + esac + _tmpargs=`_ifconfig_getargs $_if ipv6` for _arg in $_tmpargs; do case $_arg in @@ -451,6 +487,16 @@ ipv6_autoconfif() esac done + # backward compatibility: $ipv6_ifconfig_IF + _tmpargs=`get_if_var $_if ipv6_ifconfig_IF` + for _arg in $_tmpargs; do + case $_arg in + accept_rtadv) + return 0 + ;; + esac + done + return 1 } @@ -691,7 +737,7 @@ ifalias_ipv6_up() ;; *) ifconfig $1 inet6 ${ifconfig_args} alias && _ret=0 - warn "\$ipv6_ifconfig_$1_alias${alias} is obsolete." + warn "\$ipv6_ifconfig_$1_alias${alias} is obsolete." \ " Use ifconfig_$1_aliasN instead." ;; esac @@ -773,6 +819,7 @@ ifalias_ipv6_down() done # backward compatibility: ipv6_ifconfig_IF_aliasN. + alias=0 while : ; do ifconfig_args=`get_if_var $1 ipv6_ifconfig_IF_alias${alias}` case "${ifconfig_args}" in @@ -780,13 +827,12 @@ ifalias_ipv6_down() break ;; *) - ifconfig $1 inet6 ${ifconfig_args} -alias - alias=$((${alias} + 1)) - warn "\$ipv6_ifconfig_$1_alias${alias} is obsolete." + ifconfig $1 inet6 ${ifconfig_args} -alias && _ret=0 + warn "\$ipv6_ifconfig_$1_alias${alias} is obsolete." \ " Use ifconfig_$1_aliasN instead." - _ret=0 ;; esac + alias=$((${alias} + 1)) done return $_ret Modified: head/etc/rc.d/ip6addrctl ============================================================================== --- head/etc/rc.d/ip6addrctl Sat Sep 26 18:23:16 2009 (r197525) +++ head/etc/rc.d/ip6addrctl Sat Sep 26 18:59:00 2009 (r197526) @@ -19,6 +19,8 @@ status_cmd="ip6addrctl" prefer_ipv6_cmd="ip6addrctl_prefer_ipv6" prefer_ipv4_cmd="ip6addrctl_prefer_ipv4" +set_rcvar_obsolete ipv6_enable ipv6_prefer + ip6addrctl_prefer_ipv6() { ip6addrctl flush >/dev/null 2>&1 Modified: head/etc/rc.d/netif ============================================================================== --- head/etc/rc.d/netif Sat Sep 26 18:23:16 2009 (r197525) +++ head/etc/rc.d/netif Sat Sep 26 18:59:00 2009 (r197526) @@ -41,7 +41,7 @@ clonedown_cmd="clone_down" extra_commands="cloneup clonedown" cmdifn= -set_rcvar_obsolete ipv6_enable +set_rcvar_obsolete ipv6_enable ipv6_prefer network_start() { Modified: head/sbin/ifconfig/ifconfig.8 ============================================================================== --- head/sbin/ifconfig/ifconfig.8 Sat Sep 26 18:23:16 2009 (r197525) +++ head/sbin/ifconfig/ifconfig.8 Sat Sep 26 18:59:00 2009 (r197526) @@ -28,7 +28,7 @@ .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" $FreeBSD$ .\" -.Dd September 2, 2009 +.Dd September 23, 2009 .Dt IFCONFIG 8 .Os .Sh NAME @@ -598,7 +598,10 @@ If the interface was reset when previous the hardware will be re-initialized. .El .Pp -The following parameters are for ICMPv6 Neightbor Discovery Protocol: +The following parameters are for ICMPv6 Neightbor Discovery Protocol. +Note that the address family keyword +.Dq Li inet6 +is needed for them: .Bl -tag -width indent .It Cm accept_rtadv Set a flag to enable accepting ICMPv6 Router Advertisement messages. @@ -619,7 +622,10 @@ Clear a flag .Cm defaultif . .It Cm ifdisabled Set a flag to disable all of IPv6 network communications on the -specified interface. +specified interface. Note that if there are already configured IPv6 +addresses on that interface, all of them are marked as +.Dq tentative +and DAD will be performed when this flag is cleared. .It Cm -ifdisabled Clear a flag .Cm ifdisabled . Modified: head/share/man/man5/rc.conf.5 ============================================================================== --- head/share/man/man5/rc.conf.5 Sat Sep 26 18:23:16 2009 (r197525) +++ head/share/man/man5/rc.conf.5 Sat Sep 26 18:59:00 2009 (r197526) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 17, 2009 +.Dd September 23, 2009 .Dt RC.CONF 5 .Os .Sh NAME @@ -1246,28 +1246,85 @@ It is also possible to rename interface ifconfig_ed0_name="net0" ifconfig_net0="inet 192.0.2.1 netmask 0xffffff00" .Ed +.It Va ipv6_enable +.Pq Vt bool +If the variable is +.Dq Li YES , +.Dq Li inet6 accept_rtadv +is added to all of +.Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6 +and the +.Va ipv6_prefer +is defined as +.Dq Li YES . +.Pp +This variable is deprecated. Use +.Va ipv6_prefer +and +.Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6 . +.It Va ipv6_prefer +.Pq Vt bool +This variable does the following: +.Pp +If the variable is +.Dq Li YES , +the default policy of the source address selection set by +.Xr ip6addrctl 8 +will be IPv6-preferred. +.Pp +If the variable is +.Dq Li NO , +the default policy of the source address selection set by +.Xr ip6addrctl 8 +will be IPv4-preferred, and all of interfaces which does not have the +corrsponding +.Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6 +variable will be marked as +.Dq Li IFDISABLED . +This means only IPv6 functionality on that interface is completely +disabled. For more details of +.Dq Li IFDISABLED +flag and keywords +.Dq Li inet6 ifdisabled , +see +.Xr ifconfig 8 . +.Pp .It Va ipv6_network_interfaces .Pq Vt str This is the IPv6 equivalent of .Va network_interfaces . -Instead of setting the ifconfig variables as -.Va ifconfig_ Ns Aq Ar interface -they should be set as -.Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6. -Aliases should be set as -.Va ifconfig_ Ns Ao Ar interface Ac Ns Va _alias Ns Aq Ar n . -.Va ipv6_prefix_ Ns Aq Ar interface -does something. -Interfaces that have a -.Fl accept_rtadv -flag in +Normally manual configuration of this variable is not needed. +.Pp +IPv6 functionality on an interface should be configured by +.Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6 , +instead of setting ifconfig parameters in +.Va ifconfig_ Ns Aq Ar interface . +Aliases should be set by +.Va ifconfig_ Ns Ao Ar interface Ac Ns Va _alias Ns Aq Ar n +with +.Dq Li inet6 +keyword. For example: +.Bd -literal +ifconfig_ed0_ipv6="inet6 2001:db8:1::1 prefixlen 64" +ifconfig_ed0_alias0="inet6 2001:db8:2::1 prefixlen 64" +.Ed +.Pp +Interfaces that have an +.Dq Li inet6 accept_rtadv +keyword in .Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6 setting will be automatically configured by -.Xr rtsol 8 -if the +.Xr rtsol 8 . +Note that this automatic configuration is disabled if the .Va ipv6_gateway_enable is set to -.Dq Li NO . +.Dq Li YES . +.It Va ipv6_prefix_ Ns Aq Ar interface +.Pq Vt str +If one or more prefixes are defined in +.Va ipv6_prefix_ Ns Aq Ar interface +addresses based on each prefix and the EUI-64 interface index will be +configured on that interface. .It Va ipv6_default_interface .Pq Vt str If not set to