diff options
Diffstat (limited to 'templates/interfaces/tunnel')
11 files changed, 74 insertions, 31 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 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/disable/node.def b/templates/interfaces/tunnel/node.tag/disable/node.def index cd3c019a..26199646 100644 --- a/templates/interfaces/tunnel/node.tag/disable/node.def +++ b/templates/interfaces/tunnel/node.tag/disable/node.def @@ -1,6 +1,4 @@ help: Disable interface -update:expression: "sudo ip link set $VAR(../@) down"; \ - "Error disabling dev $VAR(../@)" +update: ip link set $VAR(../@) down -delete:expression: "sudo ip link set $VAR(../@) up"; \ - "Error enabling dev $VAR(../@)" +delete: ip link set $VAR(../@) up 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/key/node.def b/templates/interfaces/tunnel/node.tag/key/node.def index 1ece7642..c137107c 100644 --- a/templates/interfaces/tunnel/node.tag/key/node.def +++ b/templates/interfaces/tunnel/node.tag/key/node.def @@ -3,7 +3,7 @@ help: Set the tunnel key syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 999999; \ "Must be between 0-999999 for $VAR(../@)" syntax:expression: exec " \ - if [ -n \"`sudo ip tunnel show $VAR(../@) | grep $VAR(../@) `\" ]; then \ + if [ -n \"`ip tunnel show $VAR(../@) | grep $VAR(../@) `\" ]; then \ echo Key can only be set at tunnel creation for $VAR(../@); \ exit 1 ; \ fi ; " diff --git a/templates/interfaces/tunnel/node.tag/mtu/node.def b/templates/interfaces/tunnel/node.tag/mtu/node.def index f1fdf39b..400533f9 100644 --- a/templates/interfaces/tunnel/node.tag/mtu/node.def +++ b/templates/interfaces/tunnel/node.tag/mtu/node.def @@ -1,7 +1,7 @@ type: u32 help: Set the tunnel Maximum Transmission Unit (MTU) syntax:expression: $VAR(@) >= 64 && $VAR(@) <= 8024; "Must be between 64-8024" -update:expression: "sudo ip link set $VAR(../@) mtu $VAR(@)" -delete:expression: "sudo ip link set $VAR(../@) mtu 1476" +update: ip link set $VAR(../@) mtu $VAR(@) +delete: ip link set $VAR(../@) mtu 1476 comp_help: possible completions: <64-8024> Set MTU diff --git a/templates/interfaces/tunnel/node.tag/tos/node.def b/templates/interfaces/tunnel/node.tag/tos/node.def index 1f739966..58a4cee0 100644 --- a/templates/interfaces/tunnel/node.tag/tos/node.def +++ b/templates/interfaces/tunnel/node.tag/tos/node.def @@ -1,7 +1,7 @@ type: u32 help: Set the tunnel Type of Service (TOS) syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 99; "Must be between 0-99" -update:expression: "sudo ip tunnel change $VAR(../@) tos $VAR(@)" -delete:expression: "sudo ip tunnel change $VAR(../@) tos inherit" +update: ip tunnel change $VAR(../@) tos $VAR(@) +delete: ip tunnel change $VAR(../@) tos inherit comp_help: possible completions <0-99> Set type of service diff --git a/templates/interfaces/tunnel/node.tag/ttl/node.def b/templates/interfaces/tunnel/node.tag/ttl/node.def index 298c4d61..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:expression: "sudo ip tunnel change $VAR(../@) ttl $VAR(@)" -delete:expression: "sudo 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; |