Hiroki Sato <h...@freebsd.org> wrote in <20130718.123323.1730389945845032580....@allbsd.org>:
hr> Michael Grimm <trash...@odo.in-berlin.de> wrote hr> in <eb3c4472-02bf-4415-bb2d-b4929063d...@odo.in-berlin.de>: hr> hr> tr> On 12.07.2013, at 09:03, Hiroki Sato <h...@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
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
pgpKhbGX9jid7.pgp
Description: PGP signature