From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Qixgg-0002C6-GB for garchives@archives.gentoo.org; Mon, 18 Jul 2011 23:57:22 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7935A21C020; Mon, 18 Jul 2011 23:57:12 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 438C421C020 for ; Mon, 18 Jul 2011 23:57:12 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8B9D1654CD for ; Mon, 18 Jul 2011 23:57:11 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id E48518003D for ; Mon, 18 Jul 2011 23:57:10 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <6fa6f9523f80b2fcb49728b349f3eefc3e45a769.robbat2@gentoo> Subject: [gentoo-commits] proj/openrc:master commit in: net/ X-VCS-Repository: proj/openrc X-VCS-Files: net/iproute2.sh X-VCS-Directories: net/ X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: 6fa6f9523f80b2fcb49728b349f3eefc3e45a769 Date: Mon, 18 Jul 2011 23:57:10 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: b08f1ada68a8322e9240c6cb89a5252c commit: 6fa6f9523f80b2fcb49728b349f3eefc3e45a769 Author: Robin H. Johnson gentoo org> AuthorDate: Mon Jul 18 07:09:28 2011 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Mon Jul 18 23:55:32 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/openrc.git;a=3D= commit;h=3D6fa6f952 Rewrite iproute2 addr argument parsing. This was originally to fix the fact that our code did not handle certain orders of arguments in conversion, but it was easier to rewrite the entire argument handling to support more options at the same time. Now supports all options documented in the ip manpage, including the IPv6-specific options that must be passed after the interface argument. Signed-off-by: Robin H. Johnson gentoo.org> Reported-by: Tony Vroon gentoo.org> X-Gentoo-Bug: 366905 X-Gentoo-Bug-URL: https://bugs.gentoo.org/366905 --- net/iproute2.sh | 48 +++++++++++++++++++++--------------------------- 1 files changed, 21 insertions(+), 27 deletions(-) diff --git a/net/iproute2.sh b/net/iproute2.sh index d76e60f..2e02fbe 100644 --- a/net/iproute2.sh +++ b/net/iproute2.sh @@ -111,38 +111,32 @@ _add_address() return 0 fi =20 - # Convert an ifconfig line to iproute2 - if [ "$2" =3D "netmask" ]; then - local one=3D"$1" three=3D"$3" - shift; shift; shift - set -- "${one}/$(_netmask2cidr "${three}")" "$@" - fi - - # tunnel keyword is 'peer' in iproute2, but 'pointopoint' in ifconfig. - if [ "$2" =3D "pointopoint" ]; then - local one=3D"$1" - shift; shift - set -- "${one}" "peer" "$@" - fi + local address netmask broadcast peer anycast label scope + local valid_lft preferred_lft home nodad + address=3D"$1" ; shift + while [ -n "$*" ]; do + case "$1" in + netmask) + netmask=3D"/$(_netmask2cidr "$2")" ; shift ; shift ;; + broadcast|brd) + broadcast=3D"broadcast $2" ; shift ; shift ;; + pointopoint|pointtopoint|peer) + peer=3D"peer $2" ; shift ; shift ;; + anycast|label|scope|valid_lft|preferred_lft) + eval "$1=3D$2" ; shift ; shift ;; + home|nodad) + eval "$1=3D$1" ; shift ;; + esac + done =20 # Always scope lo addresses as host unless specified otherwise if [ "${IFACE}" =3D "lo" ]; then - set -- "$@" "scope" "host" + [ -z "$scope" ] && scope=3D"scope host" fi =20 - # IPv4 specifics - case "$1" in - *.*.*.*) - case "$@" in - *" brd "*);; - *" broadcast "*);; - *) set -- "$@" brd +;; - esac - ;; - esac - - veinfo ip addr add "$@" dev "${IFACE}" - ip addr add "$@" dev "${IFACE}" + set -- "${address}${netmask}" $peer $broadcast $anycast $label $scope d= ev "${IFACE}" $valid_lft $preferred_lft $home $nodad + veinfo ip addr add "$@" + ip addr add "$@" } =20 _add_route()