summaryrefslogtreecommitdiff
path: root/templates/protocols/static
diff options
context:
space:
mode:
authorCarl Byington <carl@five-ten-sg.com>2015-01-08 16:28:11 -0800
committerDaniil Baturin <daniil@baturin.org>2015-05-03 19:16:22 +0200
commit3ec3f2e3576b887d2c15ef548f28e087885cb801 (patch)
tree000355235760117e0e9f211f6d6e1ec906468b1d /templates/protocols/static
parentd22cda1ad0ba9c14efb62f2f8f8c3ed43a08099d (diff)
downloadvyatta-cfg-quagga-3ec3f2e3576b887d2c15ef548f28e087885cb801.tar.gz
vyatta-cfg-quagga-3ec3f2e3576b887d2c15ef548f28e087885cb801.zip
allow dhcp-interface for the next-hop on static routes
Signed-off-by: Daniil Baturin <daniil@baturin.org>
Diffstat (limited to 'templates/protocols/static')
-rw-r--r--templates/protocols/static/route/node.def6
-rw-r--r--templates/protocols/static/route/node.tag/dhcp-interface/node.def23
-rw-r--r--templates/protocols/static/route/node.tag/next-hop/node.def8
-rw-r--r--templates/protocols/static/table/node.tag/route/node.def6
-rw-r--r--templates/protocols/static/table/node.tag/route/node.tag/dhcp-interface/node.def26
-rw-r--r--templates/protocols/static/table/node.tag/route/node.tag/next-hop/node.def2
6 files changed, 62 insertions, 9 deletions
diff --git a/templates/protocols/static/route/node.def b/templates/protocols/static/route/node.def
index 682ca944..e86812db 100644
--- a/templates/protocols/static/route/node.def
+++ b/templates/protocols/static/route/node.def
@@ -3,5 +3,7 @@ type: ipv4net
help: Static route
syntax:expression: exec "${vyatta_sbindir}/check_prefix_boundary $VAR(@)"
-commit:expression: $VAR(./next-hop/) != "" || $VAR(./blackhole/) != ""; \
- "Must add either a next-hop or blackhole for route $VAR(@)"
+commit:expression: $VAR(./next-hop/) != "" || $VAR(./blackhole/) != "" || $VAR(./dhcp-interface/) != ""; \
+ "Must add either a next-hop or blackhole or dhcp-interface for route $VAR(@)"
+commit:expression: $VAR(./next-hop/) == "" || $VAR(./dhcp-interface/) == ""; \
+ "Must configure only one of next-hop or dhcp-interface for route $VAR(@)"
diff --git a/templates/protocols/static/route/node.tag/dhcp-interface/node.def b/templates/protocols/static/route/node.tag/dhcp-interface/node.def
new file mode 100644
index 00000000..4942bf5f
--- /dev/null
+++ b/templates/protocols/static/route/node.tag/dhcp-interface/node.def
@@ -0,0 +1,23 @@
+type: txt
+help: DHCP interface that supplies the next-hop IP address for this static route
+allowed:
+ local -a array ;
+ array=( /var/lib/dhcp3/eth* /var/lib/dhcp3/br* /var/lib/dhcp3/bond* ) ;
+ echo -n ${array[@]##*/}
+create:
+ sudo /opt/vyatta/sbin/vyatta-update-static-route.pl --interface=$VAR(@) --route=$VAR(../@) --table=main --option=create
+ RIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$VAR(@) --want=router)
+ vtysh -c "configure terminal" \
+ -c "ip route $VAR(../@) $RIP"
+update:
+ sudo /opt/vyatta/sbin/vyatta-update-static-route.pl --interface=$VAR(@) --route=$VAR(../@) --table=main --option=create
+ RIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$VAR(@) --want=router)
+ vtysh -c "configure terminal" \
+ -c "ip route $VAR(../@) $RIP"
+delete:
+ sudo /opt/vyatta/sbin/vyatta-update-static-route.pl --interface=$VAR(@) --route=$VAR(../@) --table=main --option=delete
+ RIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$VAR(@) --want=router)
+ if [ "$RIP" != "127.0.0.1" ]; then
+ vtysh -c "configure terminal" \
+ -c "no ip route $VAR(../@) $RIP"
+ fi
diff --git a/templates/protocols/static/route/node.tag/next-hop/node.def b/templates/protocols/static/route/node.tag/next-hop/node.def
index f5d5d417..e5106b02 100644
--- a/templates/protocols/static/route/node.tag/next-hop/node.def
+++ b/templates/protocols/static/route/node.tag/next-hop/node.def
@@ -1,17 +1,17 @@
tag:
type: ipv4
-help: Next-hop router [REQUIRED]
+help: Next-hop router
end:
if [[ -z "$VAR(./disable)" ]]
- then
+ then
if [[ ${COMMIT_ACTION} = 'DELETE' ]]
- then
+ then
if ! ${vyatta_sbindir}/vyatta-next-hop-check $VAR(../@) ipv4 address; then
exit 1;
fi
if ${vyatta_sbindir}/vyatta-gateway-static_route-check.pl \
"$VAR(../@)" "$VAR(@)"
- then
+ then
vtysh -c "configure terminal" \
-c "no ip route $VAR(../@) $VAR(@)"
fi
diff --git a/templates/protocols/static/table/node.tag/route/node.def b/templates/protocols/static/table/node.tag/route/node.def
index 682ca944..e86812db 100644
--- a/templates/protocols/static/table/node.tag/route/node.def
+++ b/templates/protocols/static/table/node.tag/route/node.def
@@ -3,5 +3,7 @@ type: ipv4net
help: Static route
syntax:expression: exec "${vyatta_sbindir}/check_prefix_boundary $VAR(@)"
-commit:expression: $VAR(./next-hop/) != "" || $VAR(./blackhole/) != ""; \
- "Must add either a next-hop or blackhole for route $VAR(@)"
+commit:expression: $VAR(./next-hop/) != "" || $VAR(./blackhole/) != "" || $VAR(./dhcp-interface/) != ""; \
+ "Must add either a next-hop or blackhole or dhcp-interface for route $VAR(@)"
+commit:expression: $VAR(./next-hop/) == "" || $VAR(./dhcp-interface/) == ""; \
+ "Must configure only one of next-hop or dhcp-interface for route $VAR(@)"
diff --git a/templates/protocols/static/table/node.tag/route/node.tag/dhcp-interface/node.def b/templates/protocols/static/table/node.tag/route/node.tag/dhcp-interface/node.def
new file mode 100644
index 00000000..177d153a
--- /dev/null
+++ b/templates/protocols/static/table/node.tag/route/node.tag/dhcp-interface/node.def
@@ -0,0 +1,26 @@
+type: txt
+help: DHCP interface that supplies the next-hop IP address for this static route
+allowed:
+ local -a array ;
+ array=( /var/lib/dhcp3/eth* /var/lib/dhcp3/br* /var/lib/dhcp3/bond* ) ;
+ echo -n ${array[@]##*/}
+create:
+ [ -n "$VAR(../../../table/@)" ] && table="table $VAR(../../../table/@)"
+ sudo /opt/vyatta/sbin/vyatta-update-static-route.pl --interface=$VAR(@) --route=$VAR(../@) --table=$VAR(../../@) --option=create
+ RIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$VAR(@) --want=router)
+ vtysh -c "configure terminal" \
+ -c "ip route $VAR(../@) $RIP $table"
+update:
+ [ -n "$VAR(../../../table/@)" ] && table="table $VAR(../../../table/@)"
+ sudo /opt/vyatta/sbin/vyatta-update-static-route.pl --interface=$VAR(@) --route=$VAR(../@) --table=$VAR(../../@) --option=create
+ RIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$VAR(@) --want=router)
+ vtysh -c "configure terminal" \
+ -c "ip route $VAR(../@) $RIP $table"
+delete:
+ [ -n "$VAR(../../../table/@)" ] && table="table $VAR(../../../table/@)"
+ sudo /opt/vyatta/sbin/vyatta-update-static-route.pl --interface=$VAR(@) --route=$VAR(../@) --table=$VAR(../../@) --option=delete
+ RIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$VAR(@) --want=router)
+ if [ "$RIP" != "127.0.0.1" ]; then
+ vtysh -c "configure terminal" \
+ -c "no ip route $VAR(../@) $RIP $table"
+ fi \ No newline at end of file
diff --git a/templates/protocols/static/table/node.tag/route/node.tag/next-hop/node.def b/templates/protocols/static/table/node.tag/route/node.tag/next-hop/node.def
index 5fb54a8b..17f1f0dc 100644
--- a/templates/protocols/static/table/node.tag/route/node.tag/next-hop/node.def
+++ b/templates/protocols/static/table/node.tag/route/node.tag/next-hop/node.def
@@ -1,6 +1,6 @@
tag:
type: ipv4
-help: Next-hop router [REQUIRED]
+help: Next-hop router
end:
if [[ -n "$VAR(../../../table/@)" ]]
then