From owner-freebsd-rc@FreeBSD.ORG Sun Mar 30 21:19:11 2014 Return-Path: Delivered-To: rc@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8C620F6C; Sun, 30 Mar 2014 21:19:11 +0000 (UTC) Received: from mx1.fisglobal.com (mx1.fisglobal.com [199.200.24.190]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx1.fisglobal.com", Issuer "VeriSign Class 3 Secure Server CA - G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 506B5BBF; Sun, 30 Mar 2014 21:19:07 +0000 (UTC) Received: from smarthost.fisglobal.com ([10.132.206.192]) by ltcfislmsgpa04.fnfis.com (8.14.5/8.14.5) with ESMTP id s2ULJ0Cw009646 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Sun, 30 Mar 2014 16:19:00 -0500 Received: from THEMADHATTER (10.242.181.54) by smarthost.fisglobal.com (10.132.206.192) with Microsoft SMTP Server id 14.3.174.1; Sun, 30 Mar 2014 16:18:57 -0500 From: Sender: Devin Teske To: "'Hiroki Sato'" References: <11c101cf2f6b$e3aee5d0$ab0cb170$@FreeBSD.org> <20140222.141935.520275210006153242.hrs@allbsd.org> <122101cf2f94$bfd81b30$3f885190$@FreeBSD.org> <20140224.125955.1719844232391066.hrs@allbsd.org> <156001cf33dd$f3b5a330$db20e990$@FreeBSD.org> In-Reply-To: <156001cf33dd$f3b5a330$db20e990$@FreeBSD.org> Subject: RE: network.subr _aliasN handling Date: Sun, 30 Mar 2014 14:18:50 -0700 Message-ID: <04c901cf4c5d$a6a4a030$f3ede090$@FreeBSD.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_04CA_01CF4C22.FA45C830" X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQHttkVtKbJQZ7hszActUMJnbew5kAHwlHOYAhb5coEB8/98xQFzxWDomoG9JUA= Content-Language: en-us X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.11.87, 1.0.14, 0.0.0000 definitions=2014-03-30_02:2014-03-28,2014-03-30,1970-01-01 signatures=0 Cc: jhellenthal@dataix.net, rc@FreeBSD.org, dteske@FreeBSD.org X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Mar 2014 21:19:11 -0000 ------=_NextPart_000_04CA_01CF4C22.FA45C830 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit > -----Original Message----- > From: dteske@FreeBSD.org [mailto:dteske@FreeBSD.org] > Sent: Thursday, February 27, 2014 9:04 AM > To: 'Hiroki Sato' > Cc: jhellenthal@dataix.net; lists@jnielsen.net; rc@FreeBSD.org; > dteske@FreeBSD.org > Subject: RE: network.subr _aliasN handling > > > -----Original Message----- > > From: Hiroki Sato [mailto:hrs@FreeBSD.org] > > Sent: Sunday, February 23, 2014 8:00 PM > > To: dteske@FreeBSD.org > > Cc: jhellenthal@dataix.net; lists@jnielsen.net; rc@FreeBSD.org > > Subject: Re: network.subr _aliasN handling > > > > wrote > > in <122101cf2f94$bfd81b30$3f885190$@FreeBSD.org>: > > > > dt> > +list_vars() > > dt> > +{ > > dt> > + set | { while read LINE; do > > dt> > + var="${LINE%%=*}" > > dt> > + case "$var" in > > dt> > + "$LINE"|*[!a-zA-Z0-9_]*) continue ;; > > dt> > + $1) echo $var > > dt> > + esac > > dt> > + done; } > > dt> > +} > > dt> > > > dt> > This can be inconsistent with normalization of $_if in > > dt> > get_if_var() > when > > dt> [.-/+] > > dt> > is included. > > dt> > > > dt> [Devin Teske] > > dt> > > dt> I'm not sure what you mean by "when [.-/+] is included". The line > > dt> of > code > > > > get_if_var() normalizes IF part in the variable name before eval: > > > > | _if=$1 > > | _punct=". - / +" > > | for _punct_c in $_punct; do > > | _if=`ltr ${_if} ${_punct_c} '_'` > > | done > > > > while list_vars ifconfig_${_if}_alias[0-9]\* does not. > > > > I think this breaks the following configuration, for example: > > > > ifconfig_bge0_name="ext.1" > > ifconfig_ext_1="inet 192.168.0.1/24" > > ifconfig_ext_1_alias0="inet 192.168.1.1/24" > > > > Thanks! Didn't know about that feature. I've attached an updated patch for > review which takes this normalization into account I was noticing /etc/rc.d/mdconfig and /etc/rc.d/mdconfig2 exhibit the same behavior, so I've attached a new patch. I didn't find any other instances where a break in the count would stop the loop prematurely. No changes to the old patch, just added mdconfig{,2} to it. -- Devin _____________ The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you. ------=_NextPart_000_04CA_01CF4C22.FA45C830 Content-Type: text/plain; name="patch.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="patch.txt" Index: head/etc/network.subr=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= --- etc/network.subr (revision 263946)=0A= +++ etc/network.subr (working copy)=0A= @@ -1076,6 +1076,7 @@ ifalias_af_common_handler()=0A= ifalias_af_common()=0A= {=0A= local _ret _if _af _action alias ifconfig_args _aliasn _c _tmpargs _iaf=0A= + local _punct=3D".-/+"=0A= =0A= _ret=3D1=0A= _aliasn=3D=0A= @@ -1083,10 +1084,16 @@ ifalias_af_common()=0A= _af=3D$2=0A= _action=3D$3=0A= =0A= + # Normalize $_if before using it in a pattern to list_vars()=0A= + while case "$_if" in *[$_punct]*) true;; *) false; esac; do=0A= + _if=3D"${_if%%[$_punct]*}_${_if#*[$_punct]}"=0A= + done=0A= +=0A= # ifconfig_IF_aliasN which starts with $_af=0A= - alias=3D0=0A= - while : ; do=0A= - ifconfig_args=3D`get_if_var $_if ifconfig_IF_alias${alias}`=0A= + for alias in `list_vars ifconfig_${_if}_alias[0-9]\* |=0A= + sort -nk1.$((9+${#_if}+7))`=0A= + do=0A= + eval ifconfig_args=3D\"\$$alias\"=0A= _iaf=3D=0A= case $ifconfig_args in=0A= inet\ *) _iaf=3Dinet ;;=0A= @@ -1107,15 +1114,15 @@ ifalias_af_common()=0A= warn "\$ifconfig_${_if}_alias${alias} needs " \=0A= "\"inet\" keyword for an IPv4 address."=0A= esac=0A= - alias=3D$(($alias + 1))=0A= done=0A= =0A= # backward compatibility: ipv6_ifconfig_IF_aliasN.=0A= case $_af in=0A= inet6)=0A= - alias=3D0=0A= - while : ; do=0A= - ifconfig_args=3D`get_if_var $_if ipv6_ifconfig_IF_alias${alias}`=0A= + for alias in `list_vars ipv6_ifconfig_${_if}_alias[0-9]\* |=0A= + sort -nk1.$((14+${#_if}+7))`=0A= + do=0A= + eval ifconfig_args=3D\"\$$alias\"=0A= case ${_action}:"${ifconfig_args}" in=0A= *:"")=0A= break=0A= @@ -1127,7 +1134,6 @@ ifalias_af_common()=0A= "instead."=0A= ;;=0A= esac=0A= - alias=3D$(($alias + 1))=0A= done=0A= esac=0A= =0A= Index: head/etc/rc.d/mdconfig=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= --- etc/rc.d/mdconfig (revision 263946)=0A= +++ etc/rc.d/mdconfig (working copy)=0A= @@ -181,17 +181,13 @@ fi=0A= =0A= load_rc_config $name=0A= =0A= -_mdconfig_unit=3D0=0A= if [ -z "${_mdconfig_list}" ]; then=0A= - while :; do=0A= - eval _mdconfig_config=3D\$mdconfig_md${_mdconfig_unit}=0A= - if [ -z "${_mdconfig_config}" ]; then=0A= - break=0A= - else=0A= - _mdconfig_list=3D"${_mdconfig_list}${_mdconfig_list:+ = }md${_mdconfig_unit}"=0A= - _mdconfig_unit=3D$((${_mdconfig_unit} + 1))=0A= - fi=0A= + for _mdconfig_config in `list_vars mdconfig_md[0-9]\* | sort -nk1.12`=0A= + do=0A= + _mdconfig_unit=3D${_mdconfig_config#mdconfig_md}=0A= + _mdconfig_list=3D"$_mdconfig_list md$_mdconfig_unit"=0A= done=0A= + _mdconfig_list=3D"${_mdconfig_list# }"=0A= fi=0A= =0A= run_rc_command "${_mdconfig_cmd}"=0A= Index: head/etc/rc.d/mdconfig2=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= --- etc/rc.d/mdconfig2 (revision 263946)=0A= +++ etc/rc.d/mdconfig2 (working copy)=0A= @@ -211,17 +211,13 @@ fi=0A= =0A= load_rc_config $name=0A= =0A= -_mdconfig2_unit=3D0=0A= if [ -z "${_mdconfig2_list}" ]; then=0A= - while :; do=0A= - eval _mdconfig2_config=3D\$mdconfig_md${_mdconfig2_unit}=0A= - if [ -z "${_mdconfig2_config}" ]; then=0A= - break=0A= - else=0A= - _mdconfig2_list=3D"${_mdconfig2_list}${_mdconfig2_list:+ = }md${_mdconfig2_unit}"=0A= - _mdconfig2_unit=3D$((${_mdconfig2_unit} + 1))=0A= - fi=0A= + for _mdconfig2_config in `list_vars mdconfig_md[0-9]\* | sort -nk1.12`=0A= + do=0A= + _mdconfig2_unit=3D${_mdconfig2_config#mdconfig_md}=0A= + _mdconfig2_list=3D"$_mdconfig2_list md$_mdconfig2_unit"=0A= done=0A= + _mdconfig2_list=3D"${_mdconfig2_list# }"=0A= fi=0A= =0A= run_rc_command "${_mdconfig2_cmd}"=0A= Index: head/etc/rc.subr=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= --- etc/rc.subr (revision 263946)=0A= +++ etc/rc.subr (working copy)=0A= @@ -54,6 +54,20 @@ JID=3D`$PS -p $$ -o jid=3D`=0A= # functions=0A= # ---------=0A= =0A= +# list_vars pattern=0A= +# List vars matching pattern.=0A= +# =0A= +list_vars()=0A= +{=0A= + set | { while read LINE; do=0A= + var=3D"${LINE%%=3D*}"=0A= + case "$var" in=0A= + "$LINE"|*[!a-zA-Z0-9_]*) continue ;;=0A= + $1) echo $var=0A= + esac=0A= + done; }=0A= +}=0A= +=0A= # set_rcvar_obsolete oldvar [newvar] [msg]=0A= # Define obsolete variable.=0A= # Global variable $rcvars_obsolete is used.=0A= ------=_NextPart_000_04CA_01CF4C22.FA45C830--