From owner-svn-src-projects@FreeBSD.ORG Sun May 16 00:43:50 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 69D86106566B; Sun, 16 May 2010 00:43:50 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (unknown [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5A5FD8FC18; Sun, 16 May 2010 00:43:50 +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 o4G0hoGR039092; Sun, 16 May 2010 00:43:50 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o4G0hnKV039088; Sun, 16 May 2010 00:43:49 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201005160043.o4G0hnKV039088@svn.freebsd.org> From: Doug Barton Date: Sun, 16 May 2010 00:43:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r208126 - in projects/etc_ipv6: . defaults rc.d X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2010 00:43:50 -0000 Author: dougb Date: Sun May 16 00:43:49 2010 New Revision: 208126 URL: http://svn.freebsd.org/changeset/base/208126 Log: Add support for ipv6_prefer=AUTO. If there is no external IPv6 interface configured then IPv4 will always be preferred. If there is, then v6 will be preferred. The yes/no options will continue to work as before. While I'm here, in ifconfig_up(): 1. Only create the v6-related local variables if we're going to use them 2. In the case of ipv6_autoconfif but no (other) ifconfig line we need to set _cfg=0. Currently this is a no-op, but if there were no IPv4 configuration for the same interface it wouldn't come up otherwise. Modified: projects/etc_ipv6/defaults/rc.conf projects/etc_ipv6/network.subr projects/etc_ipv6/rc.d/ip6addrctl Modified: projects/etc_ipv6/defaults/rc.conf ============================================================================== --- projects/etc_ipv6/defaults/rc.conf Sat May 15 23:27:23 2010 (r208125) +++ projects/etc_ipv6/defaults/rc.conf Sun May 16 00:43:49 2010 (r208126) @@ -447,7 +447,7 @@ icmp_bmcastecho="NO" # respond to broadc ### IPv6 options: ### ipv6_network_interfaces="AUTO" # List of IPv6 network interfaces -ipv6_prefer="YES" # Use IPv6 when both IPv4 and IPv6 can be used +ipv6_prefer="AUTO" # Use IPv6 when both IPv4 and IPv6 can be used ipv6_privacy="NO" # Use privacy addresses with RTADV (RFC 4193) ipv6_defaultrouter="NO" # Set to IPv6 default gateway (or NO). #ipv6_defaultrouter="2002:c058:6301::" # Use this for 6to4 (RFC 3068) Modified: projects/etc_ipv6/network.subr ============================================================================== --- projects/etc_ipv6/network.subr Sat May 15 23:27:23 2010 (r208125) +++ projects/etc_ipv6/network.subr Sun May 16 00:43:49 2010 (r208126) @@ -83,7 +83,7 @@ ifn_stop() # ifconfig_up() { - local _cfg _ipv6_opts ifconfig_args + local _cfg ifconfig_args _cfg=1 # ifconfig_IF @@ -95,12 +95,16 @@ ifconfig_up() # inet6 specific if afexists inet6; then + local _ipv6_opts _ipv6_prefer + if ipv6if $1; then # Implicitly handles ipv6_gateway_enable _ipv6_opts='-ifdisabled -accept_rtadv' if ipv6_autoconfif $1; then _ipv6_opts='-ifdisabled accept_rtadv' + _ipv6_prefer=yes + _cfg=0 fi ifconfig $1 inet6 $_ipv6_opts @@ -111,6 +115,7 @@ ifconfig_up() if [ -n "$ifconfig_args" ]; then ifconfig $1 $ifconfig_args _cfg=0 + [ "$1" != 'lo0' ] && _ipv6_prefer=yes fi else # Remove in FreeBSD 10.x @@ -123,6 +128,14 @@ ifconfig_up() ifconfig $1 inet6 ifdisabled fi + + case "$ipv6_prefer" in + [Aa][Uu][Tt][Oo]) + if [ -n "$_ipv6_prefer" ]; then + /etc/rc.d/ip6addrctl start yes + fi + ;; + esac fi if [ ${_cfg} -eq 0 ]; then Modified: projects/etc_ipv6/rc.d/ip6addrctl ============================================================================== --- projects/etc_ipv6/rc.d/ip6addrctl Sat May 15 23:27:23 2010 (r208125) +++ projects/etc_ipv6/rc.d/ip6addrctl Sun May 16 00:43:49 2010 (r208126) @@ -56,6 +56,18 @@ ip6addrctl_start() ip6addrctl install /etc/ip6addrctl.conf checkyesno ip6addrctl_verbose && ip6addrctl else + case "$ipv6_prefer" in + [Aa][Uu][Tt][Oo]) + if [ "$1" = 'yes' ]; then + ip6addrctl_prefer_ipv6 + else + ip6addrctl_prefer_ipv4 + fi + + return 0 + ;; + esac + if checkyesno ipv6_prefer; then ip6addrctl_prefer_ipv6 else @@ -72,4 +84,4 @@ ip6addrctl_stop() } load_rc_config $name -run_rc_command "$1" +run_rc_command "$@"