summaryrefslogtreecommitdiff
path: root/templates/interfaces/tunnel
diff options
context:
space:
mode:
authorRobert Bays <rbays@roatan.(none)>2010-06-17 23:32:43 -0700
committerRobert Bays <rbays@roatan.(none)>2010-06-17 23:32:43 -0700
commit5c971f8ddcfff0f8e2bb29261f52586d2701aea8 (patch)
treeba42104cec916ef6691d450e29fb6f5344456c94 /templates/interfaces/tunnel
parent26f0b004bf39bce9e8e0cd2f5d318b28b9bec6bc (diff)
downloadvyatta-cfg-quagga-5c971f8ddcfff0f8e2bb29261f52586d2701aea8.tar.gz
vyatta-cfg-quagga-5c971f8ddcfff0f8e2bb29261f52586d2701aea8.zip
initial support for gre-bridge tunnels.
Diffstat (limited to 'templates/interfaces/tunnel')
-rw-r--r--templates/interfaces/tunnel/node.def41
-rw-r--r--templates/interfaces/tunnel/node.tag/bridge-group/bridge/node.def16
-rw-r--r--templates/interfaces/tunnel/node.tag/bridge-group/cost/node.def9
-rw-r--r--templates/interfaces/tunnel/node.tag/bridge-group/node.def1
-rw-r--r--templates/interfaces/tunnel/node.tag/bridge-group/priority/node.def8
-rw-r--r--templates/interfaces/tunnel/node.tag/encapsulation/node.def6
-rw-r--r--templates/interfaces/tunnel/node.tag/ttl/node.def8
7 files changed, 67 insertions, 22 deletions
diff --git a/templates/interfaces/tunnel/node.def b/templates/interfaces/tunnel/node.def
index 34ef1ad6..2a80592e 100644
--- a/templates/interfaces/tunnel/node.def
+++ b/templates/interfaces/tunnel/node.def
@@ -1,9 +1,8 @@
tag:
priority: 380
type: txt
-help: Set tunnel interface name
+help: Set tunnel interface
comp_help: Enter tunnel interface name (tun0 - tun999)
-
syntax:expression: pattern $VAR(@) "^tun[0-9]+$" \
; "tunnel must be (tun0-tun999)"
@@ -14,18 +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; \
- ip tunnel add $VAR(@) \
- local $VAR(./local-ip/@) remote $VAR(./remote-ip/@) \
- mode $VAR(./encapsulation/@) $KEY; \
- ip link set $VAR(@) $MC up;" ; \
- "Error creating $VAR(@)"
-
-delete:expression: "ip tunnel del $VAR(@)" ; "Error deleting $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
+ sudo ip link add $VAR(@) type gretap local $VAR(./local-ip/@) remote $VAR(./remote-ip/@) ||
+ echo "interfaces tunnel $VAR(@): error creating tunnel interface"
+ else
+ sudo 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
+ sudo ip link set $VAR(@) $MC up ||
+ echo "interfaces tunnel $VAR(@): error setting tunnel interface active"
+delete:if [ "$VAR(./encapsulation/@)" == "gre-bridge" ]; then
+ sudo ip link delete $VAR(@)
+ else
+ sudo ip tunnel del $VAR(@)
+ fi
diff --git a/templates/interfaces/tunnel/node.tag/bridge-group/bridge/node.def b/templates/interfaces/tunnel/node.tag/bridge-group/bridge/node.def
new file mode 100644
index 00000000..9c28ed63
--- /dev/null
+++ b/templates/interfaces/tunnel/node.tag/bridge-group/bridge/node.def
@@ -0,0 +1,16 @@
+type: txt
+help: Set this interface to a bridge-group
+allowed: /opt/vyatta/sbin/vyatta-interfaces.pl --show=bridge
+commit:expression: exec \
+ "/opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(@) --check=bridge"
+commit:expression: $VAR(../../encapsulation/@) == "gre-bridge"; "tunnel encapsulation type must be gre-bridge"
+create:
+ # TODO: need to add logic for update as we need to remove the interface first.
+ if [ "$(ip link show $VAR(../../@) | grep ether)" ]; then
+ sudo brctl addif $VAR(@) $VAR(../../@) ||
+ echo interfaces tunnel $VAR(../../@) bridge-group bridge $VAR(@): error adding interface to bridge
+ else
+ echo interfaces tunnel $VAR(../../@) bridge-group bridge $VAR(@): tunnel encapsulation type must be gre-bridge
+ exit 1
+ fi
+delete: sudo brctl delif $VAR(@) $VAR(../../@)
diff --git a/templates/interfaces/tunnel/node.tag/bridge-group/cost/node.def b/templates/interfaces/tunnel/node.tag/bridge-group/cost/node.def
new file mode 100644
index 00000000..ed3bee26
--- /dev/null
+++ b/templates/interfaces/tunnel/node.tag/bridge-group/cost/node.def
@@ -0,0 +1,9 @@
+type: u32
+help: Set the path cost for this port
+comp_help: possible completions:
+ <0-2147483647> Set port cost
+commit:expression: $VAR(../bridge/@) != ""; "interface must first be assigned to a bridge"
+create: sudo brctl setpathcost $VAR(../bridge/@) $VAR(../../@) $VAR(@) ||
+ echo interfaces tunnel $VAR(../../@) bridge-group cost: error setting bridge cost
+delete: if [ -n "$( sudo brctl show | egrep $VAR(../../@) )" ]; then sudo brctl setpathcost $VAR(../bridge/@) $VAR(../../@) 0; fi;
+
diff --git a/templates/interfaces/tunnel/node.tag/bridge-group/node.def b/templates/interfaces/tunnel/node.tag/bridge-group/node.def
new file mode 100644
index 00000000..663979dd
--- /dev/null
+++ b/templates/interfaces/tunnel/node.tag/bridge-group/node.def
@@ -0,0 +1 @@
+help: Add this interface to a bridge group
diff --git a/templates/interfaces/tunnel/node.tag/bridge-group/priority/node.def b/templates/interfaces/tunnel/node.tag/bridge-group/priority/node.def
new file mode 100644
index 00000000..fe174f1f
--- /dev/null
+++ b/templates/interfaces/tunnel/node.tag/bridge-group/priority/node.def
@@ -0,0 +1,8 @@
+type: u32
+help: Set the path priority for this port
+comp_help: possible completions:
+ <0-255> Set port priority
+commit:expression: $VAR(../bridge/@) != ""; "interface must first be assigned to a bridge"
+create: sudo brctl setportprio $VAR(../bridge/@) $VAR(../../@) $VAR(@) ||
+ echo interfaces tunnel $VAR(../../@) bridge-group priority: error setting bridge priority
+delete: if [ -n "$( sudo brctl show | egrep "$VAR(../../@)" )" ]; then sudo brctl setportprio $VAR(../bridge/@) $VAR(../../@) 0; fi;
diff --git a/templates/interfaces/tunnel/node.tag/encapsulation/node.def b/templates/interfaces/tunnel/node.tag/encapsulation/node.def
index 6b97b190..5374568c 100644
--- a/templates/interfaces/tunnel/node.tag/encapsulation/node.def
+++ b/templates/interfaces/tunnel/node.tag/encapsulation/node.def
@@ -1,13 +1,15 @@
type: txt
help: Set the encapsulation of this tunnel interface [REQUIRED]
-syntax:expression: $VAR(@) in "ipip", "gre", "sit"; "Must be (ipip, gre, sit)"
+syntax:expression: $VAR(@) in "ipip", "gre", "sit", "gre-bridge"; "Must be (ipip, gre, gre-bridge, sit)"
create:expression: "true"
update:expression: "false" ; \
"Encapsulation can only be set at tunnel creation for $VAR(../@)"
-comp_help: "possible completions:
+comp_help: possible completions:
gre Set Generic Routing Encapsulation
+ gre-bridge Set Generic Routing Encapsulation bridge interface
ipip Set IP in IP encapsulation
sit Set Simple Internet Transition encapsulation
+
diff --git a/templates/interfaces/tunnel/node.tag/ttl/node.def b/templates/interfaces/tunnel/node.tag/ttl/node.def
index a42a199f..cfab7264 100644
--- a/templates/interfaces/tunnel/node.tag/ttl/node.def
+++ b/templates/interfaces/tunnel/node.tag/ttl/node.def
@@ -1,8 +1,8 @@
type: u32
-help: Set the tunnel time to live field
default: 255
-syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 255; "Must be between 0-255"
-update: ip tunnel change $VAR(../@) ttl $VAR(@)
-delete: ip tunnel change $VAR(../@) ttl inherit
+help: Set the tunnel time to live field
comp_help: possible completions:
<0-255> Set time to live (default 255)
+syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 255; "Must be between 0-255"
+update:if [ "$VAR(../encapsulation/@)" != "gre-bridge" ]; then sudo ip tunnel change $VAR(../@) ttl $VAR(@); fi;
+delete:if [ "$VAR(../encapsulation/@)" != "gre-bridge" ]; then sudo ip tunnel change $VAR(../@) ttl inherit; fi;