network.subr _aliasN handling

dteske at FreeBSD.org dteske at FreeBSD.org
Thu Feb 27 17:04:34 UTC 2014



> -----Original Message-----
> From: Hiroki Sato [mailto:hrs at FreeBSD.org]
> Sent: Sunday, February 23, 2014 8:00 PM
> To: dteske at FreeBSD.org
> Cc: jhellenthal at dataix.net; lists at jnielsen.net; rc at FreeBSD.org
> Subject: Re: network.subr _aliasN handling
> 
> <dteske at FreeBSD.org> 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 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 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 (and does it more
efficiently
than the get_if_var function).

NB: Calling "ltr" in a sub-shell to catch the output on stdout just to
assign back
to the original string is an unnecessary use of sub-shells. See attached
patch for
a recipe that doesn't fork or use sub-shells to replace the _punct
characters in
$_if with the underscore `_' (thus sanitizing the name before extending it
to
list_vars as a pattern (containing glob(7) characters).
-- 
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.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.txt
URL: <http://lists.freebsd.org/pipermail/freebsd-rc/attachments/20140227/ae55878c/attachment.txt>


More information about the freebsd-rc mailing list