Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 May 2010 00:43:49 +0000 (UTC)
From:      Doug Barton <dougb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r208126 - in projects/etc_ipv6: . defaults rc.d
Message-ID:  <201005160043.o4G0hnKV039088@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 "$@"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201005160043.o4G0hnKV039088>