From d3298d4a3c547002f6d712941c4eb7f97b358013 Mon Sep 17 00:00:00 2001 From: Julian Labus Date: Thu, 1 Feb 2018 16:24:32 +0100 Subject: [PATCH] Role network-routing: move interface specific routes to role network-meshbridge --- roles/network-meshbridge/templates/bridge.j2 | 17 +++++++++++++++++ .../templates/ffmwu-add-static-routes.sh.j2 | 15 --------------- .../templates/ffmwu-del-static-routes.sh.j2 | 15 --------------- 3 files changed, 17 insertions(+), 30 deletions(-) diff --git a/roles/network-meshbridge/templates/bridge.j2 b/roles/network-meshbridge/templates/bridge.j2 index 984d3ac..f499491 100644 --- a/roles/network-meshbridge/templates/bridge.j2 +++ b/roles/network-meshbridge/templates/bridge.j2 @@ -14,3 +14,20 @@ iface {{ item.id }}br address {{ prefix | ipaddr('net') | ipsubnet(64, 0) | ipaddr(magic) | ipaddr('ip/prefix') }} {% endfor %} bridge-ports {{ item.id }}bat + # static routes for rt_table mwu + post-up /sbin/ip -4 route add {{ item.ipv4_network }} proto static dev $IFACE table mwu +{% for ula in item.ipv6_ula %} + post-up /sbin/ip -6 route add {{ ula | ipaddr('net') | ipsubnet(64, 0) | ipaddr('subnet') }} proto static dev $IFACE table mwu +{% endfor %} +{% for public in item.ipv6_public %} + post-up /sbin/ip -6 route add {{ public | ipaddr('net') | ipsubnet(64, 0) | ipaddr('subnet') }} proto static dev $IFACE table mwu + post-up /sbin/ip -6 route add {{ public | ipaddr('net') | ipsubnet(56, magic) | ipsubnet(64, 0) | ipaddr('subnet') }} proto static dev $IFACE table mwu +{% endfor %} + pre-down /sbin/ip -4 route del {{ item.ipv4_network }} proto static dev $IFACE table mwu +{% for ula in item.ipv6_ula %} + pre-down /sbin/ip -6 route del {{ ula | ipaddr('net') | ipsubnet(64, 0) | ipaddr('subnet') }} proto static dev $IFACE table mwu +{% endfor %} +{% for public in item.ipv6_public %} + pre-down /sbin/ip -6 route del {{ public | ipaddr('net') | ipsubnet(64, 0) | ipaddr('subnet') }} proto static dev $IFACE table mwu + pre-down /sbin/ip -6 route del {{ public | ipaddr('net') | ipsubnet(56, magic) | ipsubnet(64, 0) | ipaddr('subnet') }} proto static dev $IFACE table mwu +{% endfor %} diff --git a/roles/network-routing/templates/ffmwu-add-static-routes.sh.j2 b/roles/network-routing/templates/ffmwu-add-static-routes.sh.j2 index 07834e8..02f37b9 100644 --- a/roles/network-routing/templates/ffmwu-add-static-routes.sh.j2 +++ b/roles/network-routing/templates/ffmwu-add-static-routes.sh.j2 @@ -3,21 +3,6 @@ # {{ ansible_managed }} # -{% for mesh in meshes %} -# static {{ mesh.site_name }} routes for rt_table mwu -/sbin/ip -4 route add {{ mesh.ipv4_network }} proto static dev {{ mesh.id }}br table mwu -{% for ula in mesh.ipv6_ula %} -/sbin/ip -6 route add {{ ula | ipaddr('net') | ipsubnet(64, 0) | ipaddr('subnet') }} proto static dev {{ mesh.id }}br table mwu -{% endfor %} -{% for public in mesh.ipv6_public %} -/sbin/ip -6 route add {{ public | ipaddr('net') | ipsubnet(64, 0) | ipaddr('subnet') }} proto static dev {{ mesh.id }}br table mwu -/sbin/ip -6 route add {{ public | ipaddr('net') | ipsubnet(56, magic) | ipsubnet(64, 0) | ipaddr('subnet') }} proto static dev {{ mesh.id }}br table mwu -{% endfor %} -{% if not loop.last %} - -{% endif %} -{% endfor %} - # static blackhole routes for rt_table internet /sbin/ip -4 route add blackhole 0.0.0.0/8 table internet /sbin/ip -4 route add blackhole 10.0.0.0/8 table internet diff --git a/roles/network-routing/templates/ffmwu-del-static-routes.sh.j2 b/roles/network-routing/templates/ffmwu-del-static-routes.sh.j2 index 1a71a32..572f983 100644 --- a/roles/network-routing/templates/ffmwu-del-static-routes.sh.j2 +++ b/roles/network-routing/templates/ffmwu-del-static-routes.sh.j2 @@ -3,21 +3,6 @@ # {{ ansible_managed }} # -{% for mesh in meshes %} -# static {{ mesh.site_name }} routes for rt_table mwu -/sbin/ip -4 route del {{ mesh.ipv4_network }} proto static dev {{ mesh.id }}br table mwu -{% for ula in mesh.ipv6_ula %} -/sbin/ip -6 route del {{ ula | ipaddr('net') | ipsubnet(64, 0) }} proto static dev {{ mesh.id }}br table mwu -{% endfor %} -{% for public in mesh.ipv6_public %} -/sbin/ip -6 route del {{ public | ipaddr('net') | ipsubnet(64, 0) }} proto static dev {{ mesh.id }}br table mwu -/sbin/ip -6 route del {{ public | ipaddr('net') | ipsubnet(64, magic) }} proto static dev {{ mesh.id }}br table mwu -{% endfor %} -{% if not loop.last %} - -{% endif %} -{% endfor %} - # static blackhole routes for rt_table internet /sbin/ip -4 route del blackhole 0.0.0.0/8 table internet /sbin/ip -4 route del blackhole 10.0.0.0/8 table internet