Browse Source

fastd: only add IPv6 peers if host has IPv6 address in vrf_external

Karsten Böddeker 7 years ago
parent
commit
8d2957dbca
2 changed files with 10 additions and 2 deletions
  1. 6 0
      fastd/init.sls
  2. 4 2
      fastd/inter-gw.peer.tmpl

+ 6 - 0
fastd/init.sls

@@ -132,6 +132,11 @@ fastd@{{ instance_name }}:
 
 #
 # Set up Inter-Gw-VPN link to all nodes of this site
+  {% set has_ipv6 = False %}
+  {% set node_config = salt['pillar.get']('nodes:' ~ grains['id']) %}
+  {% if  salt['ffho_net.get_node_iface_ips'](node_config, 'vrf_external')['v6']|length %}
+    {% set has_ipv6 = True %}
+  {% endif %}
   {% for node, node_config in salt['pillar.get']('nodes').items ()|sort  %}
 /etc/fastd/{{ site }}_intergw/gateways/{{ node }}:
     {% if site in node_config.get ('sites', {}) and 'fastd' in node_config %}
@@ -140,6 +145,7 @@ fastd@{{ instance_name }}:
     - template: jinja
       site: {{ site }}
       site_no: {{ site_no }}
+      has_ipv6: {{ has_ipv6 }}
       node: {{ node }}
       pubkey: {{ salt['pillar.get']('nodes:' ~ node ~ ':fastd:intergw_pubkey') }}
     - require:

+ 4 - 2
fastd/inter-gw.peer.tmpl

@@ -8,9 +8,11 @@
   {%- for ipv4 in ips['v4'] %}
 remote ipv4 "{{ ipv4 }}" port {{ port }};
   {%- endfor %}
-  {%- for ipv6 in ips['v6'] %}
+  {%- if has_ipv6 %}
+    {%- for ipv6 in ips['v6'] %}
 remote ipv6 "{{ ipv6 }}" port {{ port }};
-  {%- endfor %}
+    {%- endfor %}
+  {%- endif %}
 {%- endif %}
 
 key "{{ pubkey }}";