From e590c623c8ecec1846fe6977a4234b18d8d26b9f Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen.hemminger@vyatta.com>
Date: Thu, 18 Nov 2010 16:43:13 -0800
Subject: When removing tunnel, remove encapsulation device

Bug 4608
---
 templates/interfaces/tunnel/node.def | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

(limited to 'templates/interfaces/tunnel/node.def')

diff --git a/templates/interfaces/tunnel/node.def b/templates/interfaces/tunnel/node.def
index e86ef9a0..912e4c13 100644
--- a/templates/interfaces/tunnel/node.def
+++ b/templates/interfaces/tunnel/node.def
@@ -33,9 +33,16 @@ create:if [ -n "$VAR(./key/@)" ]; then
        ip link set $VAR(@) $MC up ||
           echo "interfaces tunnel $VAR(@): error setting tunnel interface active"
 
-delete:if [ "$VAR(./encapsulation/@)" == "gre-bridge" ]; then
+delete: ip link set $VAR(@) down
+        if [ "$VAR(./encapsulation/@)" == "gre-bridge" ]; then
           ip link delete $VAR(@) 
-       else 
-          ip link set $VAR(@) down
-          ip tunnel del $VAR(@) 
-       fi
+        else 
+          ip tunnel del $VAR(@) mode $VAR(./encapsulation/@)
+	  case "$VAR(./encapsulation/@)" in
+	      ipip) ip link del tunl0 ;;
+	      gre)  ip link del gre0 ;;
+              sit)  ip link del sit0 ;;
+          esac
+        fi
+
+
-- 
cgit v1.2.3

