diff options
author | Robert Bays <rbays@roatan.(none)> | 2010-06-17 23:32:43 -0700 |
---|---|---|
committer | Robert Bays <rbays@roatan.(none)> | 2010-06-17 23:32:43 -0700 |
commit | 5c971f8ddcfff0f8e2bb29261f52586d2701aea8 (patch) | |
tree | ba42104cec916ef6691d450e29fb6f5344456c94 /templates/interfaces/tunnel/node.def | |
parent | 26f0b004bf39bce9e8e0cd2f5d318b28b9bec6bc (diff) | |
download | vyatta-cfg-system-5c971f8ddcfff0f8e2bb29261f52586d2701aea8.tar.gz vyatta-cfg-system-5c971f8ddcfff0f8e2bb29261f52586d2701aea8.zip |
initial support for gre-bridge tunnels.
Diffstat (limited to 'templates/interfaces/tunnel/node.def')
-rw-r--r-- | templates/interfaces/tunnel/node.def | 41 |
1 files changed, 25 insertions, 16 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 |