File sysconfig-ifup-tunnel-allow-existing-tap.bnc557864.diff of Package sysconfig

From 302017e4fa868afdea635d0e72674a4dc1e3b9b1 Mon Sep 17 00:00:00 2001
From: mt <mt@bf393798-0adf-0310-9952-bd479070b6c1>
Date: Wed, 16 Dec 2009 21:39:38 +0000
Subject: [PATCH] Fix to allow ifup $tap when tap is already created by e.g. kvm
 (bnc#557864).

git-svn-id: https://svn.suse.de/svn/sysconfig/branches/opensuse-11.2@2070 bf393798-0adf-0310-9952-bd479070b6c1
---
 scripts/ifup-tunnel |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/scripts/ifup-tunnel b/scripts/ifup-tunnel
index da9e6f7..295af49 100755
--- a/scripts/ifup-tunnel
+++ b/scripts/ifup-tunnel
@@ -252,8 +252,20 @@ up)
 		esac
 	;;
 	tun|tap)
-		# we use a persistent tunnel by default
-		if [ "$TUNNEL_SET_PERSISTENT" != no ] ; then
+		if [ -d "/sys/class/net/$INTERFACE" ] ; then
+			owner=`cat /sys/class/net/$INTERFACE/owner 2>/dev/null`
+			group=`cat /sys/class/net/$INTERFACE/group 2>/dev/null`
+			debug "Tunnel interface $INTERFACE exists ($owner:$group)"
+			info="Already exists"
+			if [ -n "$owner" ] ; then
+				info="$info, owned by uid $owner"
+			fi
+			if [ "x$group" != "x-1" ] ; then
+				info="$info, gid $group"
+			fi
+			printf "    %-9s %s\n" "$INTERFACE" "$info"
+		elif [ "$TUNNEL_SET_PERSISTENT" != no ] ; then
+			# we use a persistent tunnel by default
 			case "$INTERFACETYPE" in
 			tap)	TUNCTL_TYPE_ARG="-p" ;;
 			tun)	TUNCTL_TYPE_ARG="-n" ;;
-- 
1.6.4.2
openSUSE Build Service is sponsored by