diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-03-06 18:52:53 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-03-06 18:52:53 +0100 |
commit | e927cd2a3e98b4396626db0276c4caa3699d2c44 (patch) | |
tree | 3fe65034693199443a8d73cd931d15d8f76c693b /templates | |
parent | 289798bbd9f74d8f87f3626b8edf7c25e94a61a7 (diff) | |
download | vyatta-cfg-quagga-e927cd2a3e98b4396626db0276c4caa3699d2c44.tar.gz vyatta-cfg-quagga-e927cd2a3e98b4396626db0276c4caa3699d2c44.zip |
vrf: T31: add IPv4 static routing support
Diffstat (limited to 'templates')
10 files changed, 137 insertions, 0 deletions
diff --git a/templates/protocols/vrf/node.def b/templates/protocols/vrf/node.def new file mode 100644 index 00000000..d8da3d39 --- /dev/null +++ b/templates/protocols/vrf/node.def @@ -0,0 +1,5 @@ +tag: +type: txt +help: VRF routing protocol parameters +allowed: cli-shell-api listNodes vrf name +val_help: <vrf> ; Name of VRF to add route for diff --git a/templates/protocols/vrf/node.tag/static/node.def b/templates/protocols/vrf/node.tag/static/node.def new file mode 100644 index 00000000..3926f26d --- /dev/null +++ b/templates/protocols/vrf/node.tag/static/node.def @@ -0,0 +1,9 @@ +priority: 481 +help: Static route parameters +end: + if [ "$COMMIT_ACTION" != "DELETE" ]; then + vtysh -d zebra -c 'sh run' > /opt/vyatta/etc/quagga/zebra.conf + else + rm -f /opt/vyatta/etc/quagga/zebra.conf + fi + diff --git a/templates/protocols/vrf/node.tag/static/route/node.def b/templates/protocols/vrf/node.tag/static/route/node.def new file mode 100644 index 00000000..0d17bb4b --- /dev/null +++ b/templates/protocols/vrf/node.tag/static/route/node.def @@ -0,0 +1,8 @@ +tag: +priority: 482 +type: ipv4net +help: Static route +syntax:expression: exec "ipaddrcheck --verbose --is-ipv4-net $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(@)" diff --git a/templates/protocols/vrf/node.tag/static/route/node.tag/blackhole/distance/node.def b/templates/protocols/vrf/node.tag/static/route/node.tag/blackhole/distance/node.def new file mode 100644 index 00000000..61abcc65 --- /dev/null +++ b/templates/protocols/vrf/node.tag/static/route/node.tag/blackhole/distance/node.def @@ -0,0 +1,4 @@ +type: u32 +help: Distance value for this route +syntax:expression: $VAR(@) >= 1 && $VAR(@) <= 255; "Must be between (1-255)" +val_help: u32:1-255; Distance for this route diff --git a/templates/protocols/vrf/node.tag/static/route/node.tag/blackhole/node.def b/templates/protocols/vrf/node.tag/static/route/node.tag/blackhole/node.def new file mode 100644 index 00000000..0e7d56d7 --- /dev/null +++ b/templates/protocols/vrf/node.tag/static/route/node.tag/blackhole/node.def @@ -0,0 +1,18 @@ +help: Silently discard pkts when matched + +end: + VRF_NAME=$VAR(../../../@) + if [ ${COMMIT_ACTION} = 'DELETE' ]; then + if ! ${vyatta_sbindir}/vyatta-next-hop-check $VAR(../@) ipv4 address; then + exit 1; + fi + + vtysh -c "configure terminal" \ + -c "no ip route $VAR(../@) Null0 vrf $VRF_NAME"; + else + if [ -n "$VAR(./distance/@)" ]; then + DIST="$VAR(./distance/@)"; + fi; + vtysh -c "configure terminal" \ + -c "ip route $VAR(../@) Null0 vrf $VRF_NAME $DIST"; + fi; diff --git a/templates/protocols/vrf/node.tag/static/route/node.tag/dhcp-interface/node.def b/templates/protocols/vrf/node.tag/static/route/node.tag/dhcp-interface/node.def new file mode 100644 index 00000000..aa9b0956 --- /dev/null +++ b/templates/protocols/vrf/node.tag/static/route/node.tag/dhcp-interface/node.def @@ -0,0 +1,30 @@ +type: txt +help: DHCP interface that supplies the next-hop IP address for this static route +allowed: + local -a array ; + array=( /var/lib/dhcp/en* /var/lib/dhcp/eth* /var/lib/dhcp/br* /var/lib/dhcp/bond* ) ; + echo -n ${array[@]##*/} +create: + sudo /opt/vyatta/sbin/vyatta-update-static-route.pl --interface=$VAR(@) --route=$VAR(../@) --table=main --option=create + VRF_NAME=$VAR(../../../@) + RIP=$(/opt/vyatta/sbin/vyatta-dhcp-helper.pl --interface=$VAR(@) --want=router) + if [ "$RIP" != "127.0.0.1" ]; then + vtysh -c "configure terminal" \ + -c "ip route $VAR(../@) $RIP vrf $VRF_NAME" + fi +update: + VRF_NAME=$VAR(../../../@) + 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) + if [ "$RIP" != "127.0.0.1" ]; then + vtysh -c "configure terminal" \ + -c "ip route $VAR(../@) $RIP vrf $VRF_NAME" + fi +delete: + VRF_NAME=$VAR(../../../@) + 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 vrf $VRF_NAME" + fi diff --git a/templates/protocols/vrf/node.tag/static/route/node.tag/next-hop/node.def b/templates/protocols/vrf/node.tag/static/route/node.tag/next-hop/node.def new file mode 100644 index 00000000..de930727 --- /dev/null +++ b/templates/protocols/vrf/node.tag/static/route/node.tag/next-hop/node.def @@ -0,0 +1,41 @@ +tag: +type: ipv4 +help: Next-hop router +end: + VRF_NAME=$VAR(../../../@) + if [[ -z "$VAR(./disable)" ]] + then + ### remove the old entry from frr first on an update + if [ ${COMMIT_ACTION} = 'ACTIVE' ] + then + OLD_IF=`cli-shell-api returnEffectiveValue protocols static route $VAR(../@) next-hop $VAR(@) next-hop-interface` + vtysh -c "configure terminal" \ + -c "no ip route $VAR(../@) $VAR(@) $OLD_IF vrf $VRF_NAME $VAR(./distance/@)"; + fi + if [[ ${COMMIT_ACTION} = 'DELETE' ]] + 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 + vtysh -c "configure terminal" \ + -c "no ip route $VAR(../@) $VAR(@) vrf $VRF_NAME" + fi + else + vtysh -c "configure terminal" \ + -c "ip route $VAR(../@) $VAR(@) $VAR(./next-hop-interface/@) vrf $VRF_NAME $VAR(./distance/@)"; + fi + else + if ${vyatta_sbindir}/vyatta-gateway-static_route-check.pl \ + "$VAR(../@)" "$VAR(@)" + then + vtysh -c "configure terminal" \ + -c "no ip route $VAR(../@) $VAR(@) vrf $VRF_NAME" + fi + fi + if [[ "$VAR(../@)" = "0.0.0.0/0" ]] + then + ${vyatta_sbindir}/vyatta-gateway-static_route-check.pl warn + fi diff --git a/templates/protocols/vrf/node.tag/static/route/node.tag/next-hop/node.tag/disable/node.def b/templates/protocols/vrf/node.tag/static/route/node.tag/next-hop/node.tag/disable/node.def new file mode 100644 index 00000000..de3afda4 --- /dev/null +++ b/templates/protocols/vrf/node.tag/static/route/node.tag/next-hop/node.tag/disable/node.def @@ -0,0 +1 @@ +help: Disable IPv4 next-hop static route diff --git a/templates/protocols/vrf/node.tag/static/route/node.tag/next-hop/node.tag/distance/node.def b/templates/protocols/vrf/node.tag/static/route/node.tag/next-hop/node.tag/distance/node.def new file mode 100644 index 00000000..61abcc65 --- /dev/null +++ b/templates/protocols/vrf/node.tag/static/route/node.tag/next-hop/node.tag/distance/node.def @@ -0,0 +1,4 @@ +type: u32 +help: Distance value for this route +syntax:expression: $VAR(@) >= 1 && $VAR(@) <= 255; "Must be between (1-255)" +val_help: u32:1-255; Distance for this route diff --git a/templates/protocols/vrf/node.tag/static/route/node.tag/next-hop/node.tag/next-hop-interface/node.def b/templates/protocols/vrf/node.tag/static/route/node.tag/next-hop/node.tag/next-hop-interface/node.def new file mode 100644 index 00000000..e4bbb99d --- /dev/null +++ b/templates/protocols/vrf/node.tag/static/route/node.tag/next-hop/node.tag/next-hop-interface/node.def @@ -0,0 +1,17 @@ +type: txt +help: network interface +allowed: sh -c "${vyos_completion_dir}/list_interfaces.py" +end: + VRF_NAME=$VAR(../../../../@) + if [[ ${COMMIT_ACTION} = 'DELETE' ]] + 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 + vtysh -c "configure terminal" \ + -c "no ip route $VAR(../../@) $VAR(../@) $VAR(@) vrf $VRF_NAME" + fi + fi |