summaryrefslogtreecommitdiff
path: root/templates/interfaces/tunnel/node.def
diff options
context:
space:
mode:
authorMichael Larson <slioch@slioch.vyatta.com>2010-06-21 11:09:51 -0700
committerMichael Larson <slioch@slioch.vyatta.com>2010-06-21 11:09:51 -0700
commitd801c05f63b0b16f485b176db64e3147ad7d3086 (patch)
tree9829f0bf340a55986aa6d11f1b1d8d5334306abd /templates/interfaces/tunnel/node.def
parent6d59b5077ef1834379a950437b01d15d687c7a53 (diff)
parent7369bf61abd3eed1fdd17a56908cf2c0ffc9843f (diff)
downloadvyatta-cfg-system-d801c05f63b0b16f485b176db64e3147ad7d3086.tar.gz
vyatta-cfg-system-d801c05f63b0b16f485b176db64e3147ad7d3086.zip
Merge branch 'larkspur' of http://git.vyatta.com/vyatta-cfg-system into larkspur
Diffstat (limited to 'templates/interfaces/tunnel/node.def')
-rw-r--r--templates/interfaces/tunnel/node.def41
1 files changed, 25 insertions, 16 deletions
diff --git a/templates/interfaces/tunnel/node.def b/templates/interfaces/tunnel/node.def
index ba3fa49a..a90c01f9 100644
--- a/templates/interfaces/tunnel/node.def
+++ b/templates/interfaces/tunnel/node.def
@@ -2,7 +2,7 @@ tag:
priority: 380
type: txt
help: Set tunnel interface
-
+comp_help: Enter tunnel interface name (tun0 - tun999)
syntax:expression: pattern $VAR(@) "^tun[0-9]+$" \
; "tunnel must be (tun0-tun999)"
@@ -13,19 +13,28 @@ commit:expression: $VAR(./remote-ip/) != "" ; \
commit:expression: $VAR(./encapsulation/) != "" ; \
"Must configure the tunnel encapsulation for $VAR(@)"
-create:expression: "\
- if [ -n \"$VAR(./key/@)\" ]; then \
- KEY=\"key $VAR(./key/@)\"; \
- fi; \
- if [ x$VAR(./multicast/@) == xenable ]; then \
- MC=\"multicast on allmulticast on\"; \
- fi; \
- sudo ip tunnel add $VAR(@) \
- local $VAR(./local-ip/@) remote $VAR(./remote-ip/@) \
- mode $VAR(./encapsulation/@) $KEY; \
- sudo ip link set $VAR(@) $MC up;" ; \
- "Error creating $VAR(@)"
+create:if [ -n "$VAR(./key/@)" ]; then
+ KEY="key $VAR(./key/@)";
+ fi
+ if [ x$VAR(./multicast/@) == xenable ]; then
+ MC="multicast on allmulticast on";
+ fi
+ if [ -n "$VAR(./bridge-group/)" ] && [ "$VAR(./encapsulation/@)" != "gre-bridge" ]; then
+ echo "interfaces tunnel $VAR(@): Tunnel encapsulation type must be gre-bridge if a bridge group is defined";
+ exit 1;
+ fi
+ if [ "$VAR(./encapsulation/@)" == "gre-bridge" ]; then
+ ip link add $VAR(@) type gretap local $VAR(./local-ip/@) remote $VAR(./remote-ip/@) ||
+ echo "interfaces tunnel $VAR(@): error creating tunnel interface"
+ else
+ ip tunnel add $VAR(@) local $VAR(./local-ip/@) remote $VAR(./remote-ip/@) mode $VAR(./encapsulation/@) $KEY ||
+ echo "interfaces tunnel $VAR(@): error creating tunnel interface"
+ fi
+ ip link set $VAR(@) $MC up ||
+ echo "interfaces tunnel $VAR(@): error setting tunnel interface active"
-delete:expression: "sudo ip tunnel del $VAR(@)" ; "Error deleting $VAR(@)"
-
-comp_help: Enter tunnel interface name (tun0 - tun999)
+delete:if [ "$VAR(./encapsulation/@)" == "gre-bridge" ]; then
+ ip link delete $VAR(@)
+ else
+ ip tunnel del $VAR(@)
+ fi