public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/openrc:master commit in: net/
Date: Mon, 16 May 2011 05:22:42 +0000 (UTC)	[thread overview]
Message-ID: <2493a1f32e7ae95f0f3d3c63cb4af7abdc34959b.vapier@gentoo> (raw)

commit:     2493a1f32e7ae95f0f3d3c63cb4af7abdc34959b
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon May 16 05:21:20 2011 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon May 16 05:22:32 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=2493a1f3

net: ccwgroup: forward port changes from baselayout-1

Quite a bit of work happened in baselayout-1 on the ccwgroup module, but
seems it didn't make it into openrc.  So forward port all the existing
code so we can work with more than just qeth and layer2 options.

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

---
 net/ccwgroup.sh |   83 +++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 56 insertions(+), 27 deletions(-)

diff --git a/net/ccwgroup.sh b/net/ccwgroup.sh
index 6fcba1d..248b159 100644
--- a/net/ccwgroup.sh
+++ b/net/ccwgroup.sh
@@ -8,60 +8,89 @@ ccwgroup_depend()
 	before interface
 }
 
-ccwgroup_pre_start()
+ccwgroup_load_modules()
 {
-	local ccwgroup="$(_get_array "ccwgroup_${IFVAR}")"
-	[ -z "${ccwgroup}" ] && return 0
-
-	if [ ! -d /sys/bus/ccwgroup ]; then
-		modprobe qeth
-		if [ ! -d /sys/bus/ccwgroup ]; then
+	# make sure we have ccwgroup support or this is a crap shoot
+	if [ ! -d /sys/bus/ccwgroup ] ; then
+		modprobe -q ccwgroup
+		if [ ! -d /sys/bus/ccwgroup ] ; then
 			eerror "ccwgroup support missing in kernel"
 			return 1
 		fi
 	fi
 
-	einfo "Enabling ccwgroup on ${IFACE}"
-	local x= ccw= first= layer2=
-	for x in ${ccwgroup}; do
-		[ -z "${first}" ] && first=${x}
-		ccw="${ccw}${ccw:+,}${x}"
-	done
-	if [ -e /sys/devices/qeth/"${first}" ]; then
-		echo "0" >/sys/devices/qeth/"${first}"/online
+	# verify the specific interface is supported
+	if [ ! -d /sys/bus/ccwgroup/drivers/$1 ] ; then
+		modprobe $1 >& /dev/null
+		if [ ! -d /sys/bus/ccwgroup/drivers/$1 ] ; then
+			eerror "$1 support missing in kernel"
+			return 1
+		fi
+	fi
+
+	return 0
+}
+
+ccwgroup_pre_start()
+{
+	local ccwgroup="$(_get_array "ccwgroup_${IFVAR}")"
+	[ -z "${ccwgroup}" ] && return 0
+
+	local ccw_type
+	eval ccw_type=\${ccwgroup_type_${IFVAR}:-qeth}
+
+	ccwgroup_load_modules ${ccw_type} || return 1
+
+	einfo "Enabling ccwgroup/${ccw_type} on ${IFACE}"
+
+	set -- ${ccwgroup}
+	local first=$1; shift
+	if [ -e /sys/devices/${ccw_type}/${first}/online ]; then
+		echo "0" >/sys/devices/${ccw_type}/${first}/online
 	else
-		echo "${ccw}" >/sys/bus/ccwgroup/drivers/qeth/group
+		echo "${first}$(printf ',%s' "$@")" >/sys/bus/ccwgroup/drivers/${ccw_type}/group
 	fi
-	eval layer2=\$qeth_layer2_${IFVAR}
-	echo "${layer2:-0}" > /sys/devices/qeth/"${first}"/layer2
-	echo "1" >/sys/devices/qeth/"${first}"/online
+
+	local var val
+	for var in $(_get_array "ccwgroup_opts_${IFVAR}") online=1 ; do
+		val=${var#*=}
+		var=${var%%=*}
+		echo "${val}" > /sys/devices/${ccw_type}/${first}/${var}
+	done
 	eend $?
 }
 
 ccwgroup_pre_stop()
 {
+	local path="/sys/class/net/${IFACE}"
+
 	# Erase any existing ccwgroup to be safe
 	service_set_value ccwgroup_device ""
+	service_set_value ccwgroup_type ""
 
-	[ ! -L /sys/class/net/"${FACE}"/driver ] && return 0
-	local driver="$(readlink /sys/class/net/"${IFACE}"/driver)"
-	case "${diver}" in
-		*/bus/ccwgroup/*);;
+	[ ! -L "${path}"/device/driver ] && return 0
+	case "$(readlink "${path}"/device/driver)" in
+		*/bus/ccwgroup/*) ;;
 		*) return 0;;
 	esac
 
-	local device="$(readlink /sys/class/net/"${IFACE}"/device)"
+	local device
+	device="$(readlink "${path}"/device)"
 	device=${device##*/}
 	service_set_value ccwgroup_device "${device}"
+	device="$(readlink "${path}"/device/driver)"
+	device=${device##*/}
+	service_set_value ccwgroup_type "${device}"
 }
 
 ccwgroup_post_stop()
 {
 	local device="$(service_get_value ccwgroup_device)"
 	[ -z "${device}" ] && return 0
+	local ccw_type="$(service_get_value ccwgroup_type)"
 
-	einfo "Disabling ccwgroup on ${iface}"
-	echo "0" >/sys/devices/qeth/"${device}"/online
-	echo "1" >/sys/devices/qeth/"${device}"/ungroup
+	einfo "Disabling ccwgroup/${ccw_type} on ${IFACE}"
+	echo "0" >/sys/devices/${ccw_type}/"${device}"/online
+	echo "1" >/sys/devices/${ccw_type}/"${device}"/ungroup
 	eend $?
 }



             reply	other threads:[~2011-05-16  5:22 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-16  5:22 Mike Frysinger [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-02-17 21:39 [gentoo-commits] proj/openrc:master commit in: net/ William Hubbs
2012-12-21 22:45 William Hubbs
2012-12-20 21:28 Robin H. Johnson
2012-11-10 20:58 William Hubbs
2012-11-07  1:45 Robin H. Johnson
2012-11-07  1:45 Robin H. Johnson
2012-11-06 23:23 Robin H. Johnson
2012-11-06 23:19 Robin H. Johnson
2012-11-06 23:19 Robin H. Johnson
2012-10-17 18:51 William Hubbs
2012-10-11  3:57 Robin H. Johnson
2012-10-11  3:57 Robin H. Johnson
2012-10-10  0:11 Robin H. Johnson
2012-09-07 19:57 William Hubbs
2012-07-04 14:20 William Hubbs
2012-06-07  5:36 William Hubbs
2012-05-03 20:43 Robin H. Johnson
2012-04-24  3:32 Christian Ruppert
2012-04-03 21:31 Robin H. Johnson
2012-04-02  4:28 William Hubbs
2012-03-11 19:55 Robin H. Johnson
2012-03-02 19:55 Robin H. Johnson
2012-02-09  9:43 Robin H. Johnson
2012-02-09  9:40 Robin H. Johnson
2012-01-25 18:47 Robin H. Johnson
2012-01-16 17:33 Robin H. Johnson
2012-01-13  4:39 Robin H. Johnson
2012-01-07 21:56 William Hubbs
2012-01-07 21:56 William Hubbs
2012-01-06 21:08 William Hubbs
2012-01-04 21:38 Mike Frysinger
2011-12-30  1:22 William Hubbs
2011-12-30  0:11 William Hubbs
2011-12-28 20:32 Robin H. Johnson
2011-12-27  2:01 Robin H. Johnson
2011-12-27  1:51 Robin H. Johnson
2011-12-27  1:24 Robin H. Johnson
2011-12-27  1:09 Robin H. Johnson
2011-12-21  8:11 Robin H. Johnson
2011-12-21  8:11 Robin H. Johnson
2011-12-21  8:11 Robin H. Johnson
2011-12-13  8:43 Robin H. Johnson
2011-12-13  6:53 Robin H. Johnson
2011-12-13  6:38 William Hubbs
2011-12-13  3:20 Robin H. Johnson
2011-12-13  3:20 Robin H. Johnson
2011-12-10  4:12 William Hubbs
2011-12-10  2:59 William Hubbs
2011-11-23 14:26 William Hubbs
2011-11-22 15:14 William Hubbs
2011-10-07 21:47 Robin H. Johnson
2011-09-21 11:29 Christian Ruppert
2011-09-21  1:58 Christian Ruppert
2011-09-18 22:04 Christian Ruppert
2011-09-18 12:45 Christian Ruppert
2011-09-16 23:14 Christian Ruppert
2011-09-16 22:18 Christian Ruppert
2011-09-16 21:48 Christian Ruppert
2011-07-18 23:57 Robin H. Johnson
2011-06-28  4:08 Mike Frysinger
2011-05-16 19:58 William Hubbs
2011-05-16 13:23 Anthony G. Basile
2011-04-07 12:51 William Hubbs
2011-03-27 20:46 William Hubbs
2011-03-18 18:25 Mike Frysinger
2011-02-21  9:56 Robin H. Johnson
2011-02-12 19:37 William Hubbs
2011-02-05 13:28 William Hubbs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2493a1f32e7ae95f0f3d3c63cb4af7abdc34959b.vapier@gentoo \
    --to=vapier@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox