aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2009-03-19 17:07:51 -0400
committerBill Nottingham <notting@redhat.com>2009-03-19 17:07:51 -0400
commit242e38c178b6509496452d4a9d9e01024a415e64 (patch)
tree0bde093d565f4dad9b4491bb307d4d8d495eed27
parent8d96a60141a556e25e251d817f072aca7e4d4e8d (diff)
downloadinitscripts-242e38c178b6509496452d4a9d9e01024a415e64.tar
initscripts-242e38c178b6509496452d4a9d9e01024a415e64.tar.gz
initscripts-242e38c178b6509496452d4a9d9e01024a415e64.tar.bz2
initscripts-242e38c178b6509496452d4a9d9e01024a415e64.tar.xz
initscripts-242e38c178b6509496452d4a9d9e01024a415e64.zip
Add support for creating TUN/TAP devices on the fly (#453973, <scott@zahna.com>)
-rw-r--r--sysconfig.txt3
-rwxr-xr-xsysconfig/network-scripts/ifdown-eth4
-rwxr-xr-xsysconfig/network-scripts/ifup-eth12
3 files changed, 19 insertions, 0 deletions
diff --git a/sysconfig.txt b/sysconfig.txt
index 03499971..e4759809 100644
--- a/sysconfig.txt
+++ b/sysconfig.txt
@@ -925,6 +925,9 @@ Files in /etc/sysconfig/network-scripts/
STP=off|on (see 'brctl stp')
DELAY=forward delay time in seconds (see 'brctl setfd')
+ TUN/TAP-specific items:
+ OWNER=<owner of the device>
+
/etc/sysconfig/network-scripts/chat-<interface-name>:
chat script for PPP or SLIP connection intended to establish
diff --git a/sysconfig/network-scripts/ifdown-eth b/sysconfig/network-scripts/ifdown-eth
index 5d22ba69..62dd354b 100755
--- a/sysconfig/network-scripts/ifdown-eth
+++ b/sysconfig/network-scripts/ifdown-eth
@@ -118,6 +118,10 @@ if [ -n "${BRIDGE}" -a -x /usr/sbin/brctl ]; then
fi
fi
+if [ "${TYPE}" = "Tap" ]; then
+ tunctl -d "${DEVICE}" >/dev/null
+fi
+
# wait up to 5 seconds for device to actually come down...
waited=0
while ! check_device_down ${DEVICE} && [ "$waited" -lt 50 ] ; do
diff --git a/sysconfig/network-scripts/ifup-eth b/sysconfig/network-scripts/ifup-eth
index fa755535..989f73ea 100755
--- a/sysconfig/network-scripts/ifup-eth
+++ b/sysconfig/network-scripts/ifup-eth
@@ -50,6 +50,7 @@ if [ -n "${HWADDR}" ]; then
fi
fi
+# If the device is a bridge, create it with brctl, if available.
if [ "${TYPE}" = "Bridge" ]; then
if [ ! -x /usr/sbin/brctl ]; then
echo $"Bridge support not available: brctl not found"
@@ -62,6 +63,16 @@ if [ "${TYPE}" = "Bridge" ]; then
[ -n "${STP}" ] && /usr/sbin/brctl stp ${DEVICE} ${STP}
fi
+# If the device is a tap device, create it with tunctl, if available.
+if [ "${TYPE}" = "Tap" ]; then
+ if [ ! -x /usr/sbin/tunctl ]; then
+ echo $"Tap support not available: tunctl not found"
+ exit 1
+ fi
+ [ -n "${OWNER}" ] && OWNER="-u ${OWNER}"
+ /usr/sbin/tunctl ${OWNER} -t ${DEVICE} > /dev/null
+fi
+
# now check the real state
is_available ${REALDEVICE} || {
if [ -n "$alias" ]; then
@@ -137,6 +148,7 @@ if [ "$ISALIAS" = no ] && is_bonding_device ${DEVICE} ; then
done
fi
+# If the device is part of a bridge, add the device to the bridge
if [ -n "${BRIDGE}" -a -x /usr/sbin/brctl ]; then
if [ ! -d /sys/class/net/${BRIDGE}/bridge ]; then
/usr/sbin/brctl addbr ${BRIDGE} 2>/dev/null