ソースを参照

SDN/bird: Allow configuring OSPF for single AF

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
Maximilian Wilhelm 1 年間 前
コミット
bca847161e
3 ファイル変更15 行追加8 行削除
  1. 1 0
      _modules/ffho_net.py
  2. 12 6
      bird/IGP.conf
  3. 2 2
      bird/init.sls

+ 1 - 0
_modules/ffho_net.py

@@ -1331,6 +1331,7 @@ def get_ospf_config (node_config, grains_id):
 			ospf_on = True
 			ospf_iface_cfg['stub'] = False
 			ospf_iface_cfg['cost'] = 10
+			ospf_iface_cfg['AF'] = 4
 			area = 51
 
 		# OPS Vlans

+ 12 - 6
bird/IGP.conf

@@ -10,7 +10,7 @@
 {%- endif %}
 {%- set ospf_config = salt['ffho_net.get_ospf_config'](node_config, grains['id']) %}
 
-{%- if proto == 'v6' %}
+{%- if AF == 6 %}
 # Bloody workaround for bird6's unwillingness to read !LL IPv6 addresses from lo
 protocol direct lo_v6 {
 	interface "lo";
@@ -19,7 +19,7 @@ protocol direct lo_v6 {
 
 protocol ospf IGP {
 	import all;
-{%- if proto == 'v4' %}
+{%- if AF == 4 %}
   {%- if grains['id'].startswith ('cr') %}
 	export filter {
 		if net = 0.0.0.0/0 then {
@@ -32,7 +32,7 @@ protocol ospf IGP {
   {%- else %}
 	export none;
   {%- endif %}
-{%- elif proto == 'v6' %}
+{%- elif AF == 6 %}
 	export filter {
   {%- if grains['id'].startswith ('cr') %}
 		if net = ::/0 then {
@@ -59,6 +59,9 @@ protocol ospf IGP {
 
 {%- for iface in ospf_config.get(0, {})|sort %}
   {%- set config = ospf_config[0][iface] %}
+  {%- if config.get('AF', AF) != AF %}
+    {%- continue %}
+  {%- endif %}
 
   {#- Interface description? #}
   {%- set desc = salt['pillar.get']('nodes:' ~ grains['id'] ~ ':ifaces:' ~ iface ~ ':desc', "") %}
@@ -68,7 +71,7 @@ protocol ospf IGP {
     {%- if 'desc' in config %}
 			# {{ config.get ('desc') }}
     {%- endif %}
-    {%- for attr in config|sort if attr not in ['desc'] %}
+    {%- for attr in config|sort if attr not in ['desc', 'AF'] %}
       {%- set value = config.get (attr) %}
       {#- 'is bool' only introduced in Jinja 2.11 #}
       {%- if salt['ffho.is_bool'](value) %}
@@ -95,7 +98,7 @@ protocol ospf IGP {
 {%- endfor %}
 {%- for interface, iface_config in interfaces.items()|sort %}
 		interface "{{ interface }}" {
-  {%- if interface.startswith ('ovpn-er-') and not 'yni' in interface and proto == 'v6' %}
+  {%- if interface.startswith ('ovpn-er-') and not 'yni' in interface and AF == 6 %}
 			type broadcast;
   {%- else %}
 			type pointopoint;
@@ -133,11 +136,14 @@ protocol ospf IGP {
 	area {{ area }} {
   {%- for iface in area_ifaces|sort %}
     {%- set iface_config = area_ifaces[iface] %}
+    {%- if iface_config.get('AF', AF) != AF %}
+      {%- continue %}
+    {%- endif %}
 		interface "{{ iface }}" {
     {%- if 'desc' in iface_config %}
 			# {{ iface_config.get ('desc') }}
     {%- endif %}
-    {%- for attr in iface_config|sort if attr not in ['desc'] %}
+    {%- for attr in iface_config|sort if attr not in ['desc', 'AF'] %}
       {%- set value = iface_config.get (attr) %}
       {#- 'is bool' only introduced in Jinja 2.11 #}
       {%- if salt['ffho.is_bool'](value) %}

+ 2 - 2
bird/init.sls

@@ -128,7 +128,7 @@ bird6-configure:
   file.managed:
     - source: salt://bird/IGP.conf
     - template: jinja
-      proto: v4
+      AF: 4
     - watch_in:
       - cmd: bird-configure
     - require:
@@ -140,7 +140,7 @@ bird6-configure:
   file.managed:
     - source: salt://bird/IGP.conf
     - template: jinja
-      proto: v6
+      AF: 6
     - watch_in:
       - cmd: bird6-configure
     - require: