summaryrefslogtreecommitdiff
path: root/sys-apps/openrc/files/openrc-0.8.3-ccwgroup.patch
blob: 14ecd5f837d20bdc20e70c21f58f76a7cfbc373f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From c427d3c1fec89f6a9281dccdc123bad73af80804 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Tue, 28 Jun 2011 00:02:11 -0400
Subject: [PATCH] net: ccwgroup: smooth up/down process

We need to bring the link up ourselves after we've properly configured
the device.  The common code tries to bring the link up itself, but it
does so before things are configured, and so it ends up failing.

When shutting down, we need to wait for the kernel to finish destroying
the interface.  Otherwise, when doing a restart, openrc is quick enough
to tell the kernel to destroy things, but then start trying to bring it
back up before the kernel has finished.

X-Gentoo-Bug: 367467
X-Gentoo-Bug-URL: http://bugs.gentoo.org/367467
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 net/ccwgroup.sh |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/net/ccwgroup.sh b/net/ccwgroup.sh
index 248b159..60cd25f 100644
--- a/net/ccwgroup.sh
+++ b/net/ccwgroup.sh
@@ -58,6 +58,11 @@ ccwgroup_pre_start()
 		echo "${val}" > /sys/devices/${ccw_type}/${first}/${var}
 	done
 	eend $?
+
+	# Now that we've properly configured the device, we can run
+	# bring the interface up.  Common code tried to do this already,
+	# but it failed because we didn't setup sysfs yet.
+	_up
 }
 
 ccwgroup_pre_stop()
@@ -88,9 +93,14 @@ ccwgroup_post_stop()
 	local device="$(service_get_value ccwgroup_device)"
 	[ -z "${device}" ] && return 0
 	local ccw_type="$(service_get_value ccwgroup_type)"
+	local path="/sys/devices/${ccw_type}/${device}"
 
 	einfo "Disabling ccwgroup/${ccw_type} on ${IFACE}"
-	echo "0" >/sys/devices/${ccw_type}/"${device}"/online
-	echo "1" >/sys/devices/${ccw_type}/"${device}"/ungroup
+	if echo "0" >"${path}"/online &&
+	   echo "1" >"${path}"/ungroup ; then
+		# The device doesn't disappear right away which breaks
+		# restart, or a quick start up, so wait around.
+		while [ -e "${path}" ] ; do :; done
+	fi
 	eend $?
 }
-- 
1.7.5.3