Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jun 2014 12:48:03 +0900 (JST)
From:      Hiroki Sato <hrs@FreeBSD.org>
To:        jhay@meraka.org.za
Cc:        freebsd-net@freebsd.org
Subject:   Re: network.subr vlan handling broken
Message-ID:  <20140620.124803.562992300308664968.hrs@allbsd.org>
In-Reply-To: <20140619103513.GA92393@zibbi.meraka.csir.co.za>
References:  <20140619103513.GA92393@zibbi.meraka.csir.co.za>

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

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

John Hay <jhay@meraka.org.za> wrote
  in <20140619103513.GA92393@zibbi.meraka.csir.co.za>:

jh> Hi Guys,
jh>
jh> freebsd-rc did not react, so I'm just checking on -net too.
jh>
jh> I found after upgrading that vlan handling broke. I tried the following:
jh>
jh> vlans_bce1="6"
jh> ipv4_addrs_bce1_6="inet 10.239.100.2/24"
jh> ifconfig_bce1_6_aliases="inet 10.239.100.2/24"
jh> ifconfig_bce1_6_alias0="inet 10.239.100.2/24"
jh>
jh> I traced it down to ifalias_af_common_handler being called with the
jh> mangled interfcace name _if and it then calls ifconfig with it. Here
jh> is my fix. Any reason not to commit it? My diff is against 10-stable,
jh> but head looks the same.

 Can you try the attached patch?  It seemed broken after list_vars()
 was introduced.  Replacing $_if with $1 also fixes it, but $_if
 should be used for ifname as the other parts do.

jh> While looking through the code I saw that ltr is called with different
jh> styling. Is there a reason for it? Which is the prefered style?
jh>
jh> 	ltr ${_if} "${_punct}" '_' _if
jh> 	ltr "$_if" "$_punct" "_" _if

 I do not think there is a reason.

 I think there is no consensus about the style but I am using {} only
 when boundary between the variable name and the subsequent characters
 can be ambiguous.

-- Hiroki

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

Index: network.subr
===================================================================
--- network.subr	(revision 267636)
+++ network.subr	(working copy)
@@ -1077,7 +1077,7 @@
 ifalias_af_common()
 {
 	local _ret _if _af _action alias ifconfig_args _aliasn _c _tmpargs _iaf
-	local _punct=".-/+"
+	local _vif _punct=".-/+"

 	_ret=1
 	_aliasn=
@@ -1086,11 +1086,11 @@
 	_action=$3

 	# Normalize $_if before using it in a pattern to list_vars()
-	ltr "$_if" "$_punct" "_" _if
+	ltr "$_if" "$_punct" "_" _vif

 	# ifconfig_IF_aliasN which starts with $_af
-	for alias in `list_vars ifconfig_${_if}_alias[0-9]\* |
-		sort_lite -nk1.$((9+${#_if}+7))`
+	for alias in `list_vars ifconfig_${_vif}_alias[0-9]\* |
+		sort_lite -nk1.$((9+${#_vif}+7))`
 	do
 		eval ifconfig_args=\"\$$alias\"
 		_iaf=
@@ -1118,8 +1118,8 @@
 	# backward compatibility: ipv6_ifconfig_IF_aliasN.
 	case $_af in
 	inet6)
-		for alias in `list_vars ipv6_ifconfig_${_if}_alias[0-9]\* |
-			sort_lite -nk1.$((14+${#_if}+7))`
+		for alias in `list_vars ipv6_ifconfig_${_vif}_alias[0-9]\* |
+			sort_lite -nk1.$((14+${#_vif}+7))`
 		do
 			eval ifconfig_args=\"\$$alias\"
 			case ${_action}:"${ifconfig_args}" in
@@ -1129,7 +1129,7 @@
 			alias:*)
 				_aliasn="${_aliasn} inet6 ${ifconfig_args}"
 				warn "\$${alias} is obsolete. " \
-				    "Use ifconfig_$1_aliasN instead."
+				    "Use ifconfig_${_vif}_aliasN instead."
 			;;
 			esac
 		done

----Next_Part(Fri_Jun_20_12_48_03_2014_919)----

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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iEYEABECAAYFAlOjrvMACgkQTyzT2CeTzy2fTQCfR95aWy54z905YblPX/X90QgX
CPQAn1hs2/nSNJaAdC0Wp3meUPyADJM6
=ir9k
-----END PGP SIGNATURE-----

----Security_Multipart0(Fri_Jun_20_12_48_03_2014_705)----



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