From 242e38c178b6509496452d4a9d9e01024a415e64 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Thu, 19 Mar 2009 17:07:51 -0400 Subject: Add support for creating TUN/TAP devices on the fly (#453973, ) --- sysconfig.txt | 3 +++ sysconfig/network-scripts/ifdown-eth | 4 ++++ sysconfig/network-scripts/ifup-eth | 12 ++++++++++++ 3 files changed, 19 insertions(+) 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= + /etc/sysconfig/network-scripts/chat-: 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 -- cgit v1.2.1