From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 04A07138010 for ; Thu, 11 Oct 2012 03:57:25 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6FBF521C014; Thu, 11 Oct 2012 03:57:16 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id C3A8021C017 for ; Thu, 11 Oct 2012 03:57:15 +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 0635D33D7E4 for ; Thu, 11 Oct 2012 03:57:15 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id CE373E543E for ; Thu, 11 Oct 2012 03:57:12 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <1349927797.a9f1ac2dfdc3ab7421ea33ae977f7e078750e542.robbat2@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: net/ X-VCS-Repository: proj/openrc X-VCS-Files: net/bonding.sh X-VCS-Directories: net/ X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: a9f1ac2dfdc3ab7421ea33ae977f7e078750e542 X-VCS-Branch: master Date: Thu, 11 Oct 2012 03:57:12 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 2acc9166-ad4a-4cbd-88ee-f184031f1cf0 X-Archives-Hash: 856854b8d22c7208badbaa30e8695ef8 commit: a9f1ac2dfdc3ab7421ea33ae977f7e078750e542 Author: Robin H. Johnson gentoo org> AuthorDate: Thu Oct 11 03:54:32 2012 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Thu Oct 11 03:56:37 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=a9f1ac2d net/bonding: Sanity-check sysfs usage If sysfs is not available, you might still be able to create bond interfaces, but only in very specific configurations, and you must have the ifenslave binary instead to call ioctls. Signed-off-by: Robin H. Johnson gentoo.org> --- net/bonding.sh | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/net/bonding.sh b/net/bonding.sh index 67b0d9b..7ea7508 100644 --- a/net/bonding.sh +++ b/net/bonding.sh @@ -5,6 +5,11 @@ bonding_depend() { before interface macchanger program /sbin/ifconfig /bin/ifconfig + # If you do not have sysfs, you MUST have this binary instead for ioctl + # Also you will loose some functionality that cannot be done via sysfs: + if [ ! -d /sys/class/net ]; then + program /sbin/ifenslave + fi } _config_vars="$_config_vars slaves" @@ -38,6 +43,10 @@ bonding_pre_start() fi fi + if [ ! -d /sys/class/net ]; then + ewarn "sysfs is not available! You will be unable to create new bonds, or change dynamic parameters!" + fi + # We can create the interface name we like now, but this # requires sysfs if ! _exists && [ -d /sys/class/net ]; then @@ -55,7 +64,7 @@ bonding_pre_start() # Configure the bond mode, then we can reloop to ensure we configure # All other options - for x in /sys/class/net/"${IFACE}"/bonding/mode; do + [ -d /sys/class/net ] && for x in /sys/class/net/"${IFACE}"/bonding/mode; do [ -f "${x}" ] || continue n=${x##*/} eval s=\$${n}_${IFVAR} @@ -66,7 +75,7 @@ bonding_pre_start() fi done # Nice and dynamic for remaining options:) - for x in /sys/class/net/"${IFACE}"/bonding/*; do + [ -d /sys/class/net ] && for x in /sys/class/net/"${IFACE}"/bonding/*; do [ -f "${x}" ] || continue n=${x##*/} eval s=\$${n}_${IFVAR} @@ -154,7 +163,7 @@ bonding_pre_start() fi done else - /sbin/ifenslave "${IFACE}" ${slaves} >/dev/null + ifenslave "${IFACE}" ${slaves} >/dev/null fi eend $? @@ -187,7 +196,7 @@ bonding_stop() echo -"${s}" > /sys/class/net/"${IFACE}"/bonding/slaves done else - /sbin/ifenslave -d "${IFACE}" ${slaves} + ifenslave -d "${IFACE}" ${slaves} fi # reset all slaves