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 1SEYtB-0000u0-TQ for garchives@archives.gentoo.org; Mon, 02 Apr 2012 04:29:10 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4B53FE0A76; Mon, 2 Apr 2012 04:28:57 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 0A7DAE0A76 for ; Mon, 2 Apr 2012 04:28:56 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 451AF1B400B for ; Mon, 2 Apr 2012 04:28:56 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 367BDE5403 for ; Mon, 2 Apr 2012 04:28:54 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <1333339140.9127684553ea7b0f9285bc3fbe6c554f4519016c.WilliamH@gentoo> Subject: [gentoo-commits] proj/openrc:master commit in: net/ X-VCS-Repository: proj/openrc X-VCS-Files: net/ifconfig.sh.Linux.in net/iproute2.sh X-VCS-Directories: net/ X-VCS-Committer: WilliamH X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 9127684553ea7b0f9285bc3fbe6c554f4519016c X-VCS-Branch: master Date: Mon, 2 Apr 2012 04:28:54 +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: b92c387f-c186-4ab7-a171-636c5a334433 X-Archives-Hash: 574a85cae1e003b4dca76c81ba603131 commit: 9127684553ea7b0f9285bc3fbe6c554f4519016c Author: William Hubbs gentoo org> AuthorDate: Mon Apr 2 03:59:00 2012 +0000 Commit: William Hubbs gentoo org> CommitDate: Mon Apr 2 03:59:00 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/openrc.git;a=3D= commit;h=3D91276845 Change the method for calculating the interface metric for linux systems On linux systems running >=3Dlinux-3.2, the /proc/net/dev file cannot be relied on to show the order network interfaces were added to the system. Also, there is currently a bug in the implementation of the seek call for this file which can cause a system to go into an infinite loop. This commit changes the _ifindex function to retreive the value of /sys/class/net/${IFACE}/ifindex and use that value instead of attempting to calculate one from the interface's position in /proc/net/dev. reported-by: John Keeping lineone.net> X-Gentoo-Bug: 410127 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=3D410127 --- net/ifconfig.sh.Linux.in | 26 +++++++++++++------------- net/iproute2.sh | 26 +++++++++++++------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/net/ifconfig.sh.Linux.in b/net/ifconfig.sh.Linux.in index 411401d..8abc998 100644 --- a/net/ifconfig.sh.Linux.in +++ b/net/ifconfig.sh.Linux.in @@ -24,19 +24,19 @@ _exists() =20 _ifindex() { - local line=3D i=3D-2 - while read line; do - : $(( i +=3D 1 )) - [ ${i} -lt 1 ] && continue - case "${line}" in - "${IFACE}:"*) echo "${i}"; return 0;; - esac - done < /proc/net/dev - - # Return the next available index - : $(( i +=3D 1 )) - echo "${i}" - return 1 + local index=3D-1 + local f v + if [ -e /sys/class/net/"${IFACE}"/ifindex ]; then + index=3D$(cat /sys/class/net/"${IFACE}"/ifindex) + else + for f in /sys/class/net/*/ifindex ; do + v=3D$(cat $f) + [ $v -gt $index ] && index=3D$v + done=20 + : $(( index +=3D 1 )) + fi + echo "${index}" + return 0 } =20 _is_wireless() diff --git a/net/iproute2.sh b/net/iproute2.sh index e06152f..b420e41 100644 --- a/net/iproute2.sh +++ b/net/iproute2.sh @@ -25,19 +25,19 @@ _exists() =20 _ifindex() { - local line=3D i=3D-2 - while read line; do - : $(( i +=3D 1 )) - [ ${i} -lt 1 ] && continue - case "${line}" in - "${IFACE}:"*) echo "${i}"; return 0;; - esac - done < /proc/net/dev - - # Return the next available index - : $(( i +=3D 1 )) - echo "${i}" - return 1 + local index=3D-1 + local f v + if [ -e /sys/class/net/"${IFACE}"/ifindex ]; then + index=3D$(cat /sys/class/net/"${IFACE}"/ifindex) + else + for f in /sys/class/net/*/ifindex ; do + v=3D$(cat $f) + [ $v -gt $index ] && index=3D$v + done=20 + : $(( index +=3D 1 )) + fi + echo "${index}" + return 0 } =20 _is_wireless()