Explorar o código

bird: Add support for L3-based access VLANs.

Signed-off-by: Maximilian Wilhelm <max@rfc2324.org>
Maximilian Wilhelm %!s(int64=7) %!d(string=hai) anos
pai
achega
df905ea166
Modificáronse 3 ficheiros con 69 adicións e 14 borrados
  1. 42 13
      bird/init.sls
  2. 11 0
      bird/l3-access.conf
  3. 16 1
      bird/radv.conf

+ 42 - 13
bird/init.sls

@@ -296,17 +296,6 @@ bird6-configure:
 # B.A.T.M.A.N. Gateway
 #
 {% if 'batman_gw' in roles %}
-/etc/bird/bird6.d/radv.conf:
-  file.managed:
-    - source: salt://bird/radv.conf
-    - template: jinja
-    - watch_in:
-      - cmd: bird6-configure
-    - require:
-      - file: /etc/bird/bird6.d
-    - require_in:
-      - service: bird6
-
 /etc/bird/bird.d/mesh_routes.conf:
   file.managed:
     - source: salt://bird/mesh_routes.conf
@@ -330,10 +319,50 @@ bird6-configure:
       - service: bird6
 
 {% else %}
-/etc/bird/bird6.d/ravd.conf:
-  file.absent
 /etc/bird/bird.d/mesh_routes.conf:
   file.absent
 /etc/bird/bird6.d/mesh_routes.conf:
   file.absent
 {% endif %}
+
+
+#
+# L3 Access
+#
+{% if 'l3_access' in roles %}
+/etc/bird/bird.d/l3-access.conf:
+  file.managed:
+    - source: salt://bird/l3-access.conf
+    - template: jinja
+
+/etc/bird/bird6.d/l3-access.conf:
+  file.managed:
+    - source: salt://bird/l3-access.conf
+    - template: jinja
+
+{% else %}
+/etc/bird/bird.d/l3-access.conf:
+  file.absent
+/etc/bird/bird6.d/l3-access.conf:
+  file.absent
+{% endif %}
+
+
+#
+# RAdvd (for B.A.T.M.A.N. Gateways / L3-Access)
+#
+{% if 'batman_gw' in roles or "l3_access" in roles %}
+/etc/bird/bird6.d/radv.conf:
+  file.managed:
+    - source: salt://bird/radv.conf
+    - template: jinja
+    - watch_in:
+      - cmd: bird6-configure
+    - require:
+      - file: /etc/bird/bird6.d
+    - require_in:
+      - service: bird6
+{% else %}
+/etc/bird/bird6.d/ravd.conf:
+  file.absent
+{% endif %}

+ 11 - 0
bird/l3-access.conf

@@ -0,0 +1,11 @@
+#
+# L3 Access VLANs
+#
+
+protocol direct l3_access {
+{%- for iface in salt['pillar.get']('nodes:' ~ grains['id'] ~ ':ifaces') %}
+  {%- if salt['ffho.re_search']('^vlan3\d\d$', iface) %}
+	interface "{{ iface }}";
+  {%- endif %}
+{%- endfor %}
+}

+ 16 - 1
bird/radv.conf

@@ -8,7 +8,7 @@ protocol radv {
 
 	rdnss 2a03:2260:2342:f251::53;
 
-{% for site in node_config.get ('sites') %} 
+{% for site in node_config.get ('sites', []) %}
   {%- set iface = 'br-' ~ site %}
   {%- set site_config = sites_config.get (site) %}
 	# {{ site }} / {{ site_config.get ('name') }}
@@ -21,4 +21,19 @@ protocol radv {
 	};
 
 {% endfor %}
+{%- for iface, iface_config in node_config.get ('ifaces').items ()|sort %}
+  {%- if salt['ffho.re_search']('^vlan3\d\d$', iface) %}
+    {%- set v6_ip = salt['ffho_net.get_node_iface_ips'](node_config, iface, with_mask = True)['v6'][0] %}
+    {%- set prefix = salt['ffho_net.get_network_address'](v6_ip, with_prefixlen = True) %}
+	# {{ iface_config.get ('desc', 'L3-Access') }}
+	interface "{{ iface }}" {
+		default   lifetime 600 sensitive yes;
+
+		prefix {{ prefix }} {
+			preferred lifetime 3600;
+		};
+	};
+
+  {%- endif %}
+{%- endfor %}
 }