Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 20 Jul 2013 23:46:23 +0900 (JST)
From:      Hiroki Sato <hrs@FreeBSD.org>
To:        trashcan@odo.in-berlin.de
Cc:        freebsd-stable@FreeBSD.org
Subject:   Re: ipv6_addrs_IF aliases in rc.conf(5)
Message-ID:  <20130720.234623.829852506076930312.hrs@allbsd.org>
In-Reply-To: <20130718.123323.1730389945845032580.hrs@allbsd.org>
References:  <20130712.160358.1330135778606339435.hrs@allbsd.org> <EB3C4472-02BF-4415-BB2D-B4929063D796@odo.in-berlin.de> <20130718.123323.1730389945845032580.hrs@allbsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
----Security_Multipart0(Sat_Jul_20_23_46_23_2013_911)--
Content-Type: Multipart/Mixed;
 boundary="--Next_Part(Sat_Jul_20_23_46_23_2013_121)--"
Content-Transfer-Encoding: 7bit

----Next_Part(Sat_Jul_20_23_46_23_2013_121)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hiroki Sato <hrs@freebsd.org> wrote
  in <20130718.123323.1730389945845032580.hrs@allbsd.org>:

hr> Michael Grimm <trashcan@odo.in-berlin.de> wrote
hr>   in <EB3C4472-02BF-4415-BB2D-B4929063D796@odo.in-berlin.de>:
hr>
hr> tr> On 12.07.2013, at 09:03, Hiroki Sato <hrs@FreeBSD.org> wrote:
hr> tr>
hr> tr> > Please let me know if the existing configurations and/or the new
hr> tr> > formats do not work.
hr> tr>
hr> tr> First of all: great work! It is that much easier to deal with aliases, now.
hr> tr>
hr> tr> There is only one minor issue, if at all:
hr> tr>
hr> tr> rc.conf:
hr> tr> | ifconfig_em0_ipv6="inet6 dead:beef:1111:2222::1 prefixlen 56"
hr> tr> | ifconfig_em0_aliases="\
hr> tr> |         inet6 dead:beef:1111:2222::2-3 prefixlen 56 \
hr> tr> |         inet6 dead:beef:1111:2222::4 prefixlen 56 \
hr> tr> |         inet6 dead:beef:1111:2222::5-6/56"
hr> tr>
hr> tr> ifconfig:
hr> tr> |	inet6 dead:beef:1111:2222::1 prefixlen 56
hr> tr> |	inet6 dead:beef:1111:2222::2 prefixlen 64
hr> tr> |	inet6 dead:beef:1111:2222::3 prefixlen 64
hr> tr> |	inet6 dead:beef:1111:2222::4 prefixlen 56
hr> tr> |	inet6 dead:beef:1111:2222::5 prefixlen 56
hr> tr> |	inet6 dead:beef:1111:2222::6 prefixlen 56
hr> tr>
hr> tr> Any combination of a range definition (2-3) *and* "prefixlen 56" is ignored
hr> tr> whereas a range definition (5-6) *and* "/56" is interpreted as wanted.
hr> tr>
hr> tr> Well, that combination of a range and "prefix" isn't documented, thus I am
hr> tr> not sure if that's an issue or a feature?
hr>
hr>  It seems a bug.  Thank you for your report.  I am investigating it now.

 Can you test the attached patch?  The old version (in stable/9 now)
 does not support "address range spec + options" properly and ignore
 the options part.

 The attached patch accepts options and treats "netmask" for inet and
 "prefixlen" in inet6 in a reasonable way so that the specified
 options do not conflict with the default /NN values.

-- Hiroki

----Next_Part(Sat_Jul_20_23_46_23_2013_121)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="network.subr.aliases.20130720-1.diff"

Index: etc/network.subr
===================================================================
--- etc/network.subr	(revision 253489)
+++ etc/network.subr	(working copy)
@@ -721,9 +721,14 @@
 #
 ifalias_expand_addr()
 {
+	local _af _action

-	afexists $1 || return
-	ifalias_expand_addr_$1 $2 $3
+	_af=$1
+	_action=$2
+	shift 2
+
+	afexists $_af || return
+	ifalias_expand_addr_$_af $_action $*
 }

 # ifalias_expand_addr_inet action addr
@@ -731,19 +736,31 @@
 #
 ifalias_expand_addr_inet()
 {
-	local _action _arg _cidr _cidr_addr
+	local _action _arg _cidr _cidr_addr _exargs
 	local _ipaddr _plen _range _iphead _iptail _iplow _iphigh _ipcount
 	local _retstr _c
 	_action=$1
 	_arg=$2
+	shift 2
+	_exargs=$*
 	_retstr=

-	case $_action:$_arg in
+	case $_action:$_arg:$_exargs in
 	*:*--*)		return ;;			# invalid
-	tmp:*)		echo $_arg && return ;;		# already expanded
-	tmp:*-*)	_action="alias"	;;		# to be expanded
-	*:*-*)		;;				# to be expanded
-	*:*)		echo inet $_arg && return ;;	# already expanded
+	tmp:*:*netmask*)		# already expanded w/ netmask option
+		echo ${_arg%/[0-9]*} $_exargs && return
+	;;
+	tmp:*:*)			# already expanded w/o netmask option
+		echo $_arg $_exargs && return
+	;;
+	tmp:*[0-9]-[0-9]*:*)	_action="alias"	;;	# to be expanded
+	*:*[0-9]-[0-9]*:*)	;;			# to be expanded
+	*:*:*netmask*)			# already expanded w/ netmask option
+		echo inet ${_arg%/[0-9]*} $_exargs && return
+	;;
+	*:*:*)				# already expanded w/o netmask option
+		echo inet $_arg $_exargs && return
+	;;
 	esac

 	for _cidr in $_arg; do
@@ -796,7 +813,7 @@
 	done

 	for _c in $_retstr; do
-		ifalias_expand_addr_inet $_action $_c
+		ifalias_expand_addr_inet $_action $_c $_exargs
 	done
 }

@@ -805,20 +822,32 @@
 #
 ifalias_expand_addr_inet6()
 {
-	local _action _arg _cidr _cidr_addr
+	local _action _arg _cidr _cidr_addr _exargs
 	local _ipaddr _plen _ipleft _ipright _iplow _iphigh _ipcount
 	local _ipv4part
 	local _retstr _c
 	_action=$1
 	_arg=$2
+	shift 2
+	_exargs=$*
 	_retstr=

-	case $_action:$_arg in
-	*:*--*)		return ;;			# invalid
-	tmp:*)		echo $_arg && return ;;
-	tmp:*-*)	_action="alias"	;;
-	*:*-*)		;;
-	*:*)		echo inet6 $_arg && return ;;
+	case $_action:$_arg:$_exargs in
+	*:*--*:*)	return ;;			# invalid
+	tmp:*:*prefixlen*)	# already expanded w/ prefixlen option
+		echo ${_arg%/[0-9]*} $_exargs && return
+	;;
+	tmp:*:*)		# already expanded w/o prefixlen option
+		echo $_arg $_exargs && return
+	;;
+	tmp:*[0-9a-zA-Z]-[0-9a-zA-Z]*:*)_action="alias"	;;# to be expanded
+	*:*[0-9a-zA-Z]-[0-9a-zA-Z]*:*)	;;		# to be expanded
+	*:*:*prefixlen*)	# already expanded w/ prefixlen option
+		echo inet6 ${_arg%/[0-9]*} $_exargs && return
+	;;
+	*:*:*)			# already expanded w/o prefixlen option
+		echo inet6 $_arg $_exargs && return
+	;;
 	esac

 	for _cidr in $_arg; do
@@ -872,7 +901,7 @@
 			fi

 			for _c in $_retstr; do
-				ifalias_expand_addr_inet6 $_action $_c
+				ifalias_expand_addr_inet6 $_action $_c $_exargs
 			done
 		else
 			# v4mapped/v4compat should handle as an IPv4 alias
@@ -888,7 +917,7 @@
 			_retstr=`ifalias_expand_addr_inet \
 			    tmp ${_ipv4part}${_plen:+/}${_plen}`
 			for _c in $_retstr; do
-				ifalias_expand_addr_inet $_action $_c
+				ifalias_expand_addr_inet $_action $_c $_exargs
 			done
 		fi
 	done

----Next_Part(Sat_Jul_20_23_46_23_2013_121)----

----Security_Multipart0(Sat_Jul_20_23_46_23_2013_911)--
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (FreeBSD)

iEYEABECAAYFAlHqor8ACgkQTyzT2CeTzy1SjQCgkDjlVNixQRS34lwUjrIcBwET
k/kAn3JZfZIz0kkswVa8LJJz3h8ZzaBU
=UinY
-----END PGP SIGNATURE-----

----Security_Multipart0(Sat_Jul_20_23_46_23_2013_911)----



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