From 019c0a14e4094d9d35f4802862bf04319057ee61 Mon Sep 17 00:00:00 2001 From: Simon Polack Date: Fri, 22 Nov 2024 17:52:08 +0100 Subject: [PATCH] corerouter: use patched version of bird2 and add proper inbound metrics Switch to using a patched version of the BIRD daemon (`bird2-babelpatch`) maintained in our own repository. This version includes modifications to the Babel protocol, allowing route filtering based on specific interfaces and neighbors, while exporting all Babel routes to BIRD's core for enhanced flexibility. Link: https://bird.network.cz/pipermail/bird-users/2023-February/016705.html Link: https://github.com/freifunk-berlin/bbb-configs/pull/1087 --- group_vars/role_corerouter/imageprofile.yml | 2 +- .../templates/corerouter/bird.conf.j2 | 22 ++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/group_vars/role_corerouter/imageprofile.yml b/group_vars/role_corerouter/imageprofile.yml index 7dad0602c..9be0ee496 100644 --- a/group_vars/role_corerouter/imageprofile.yml +++ b/group_vars/role_corerouter/imageprofile.yml @@ -1,6 +1,6 @@ --- role_corerouter__packages__to_merge: - - bird2 + - bird2-babelpatch - bird2c - collectd-mod-dhcpleases - collectd-mod-olsrd diff --git a/roles/cfg_openwrt/templates/corerouter/bird.conf.j2 b/roles/cfg_openwrt/templates/corerouter/bird.conf.j2 index 2345f259f..664029de0 100644 --- a/roles/cfg_openwrt/templates/corerouter/bird.conf.j2 +++ b/roles/cfg_openwrt/templates/corerouter/bird.conf.j2 @@ -27,7 +27,23 @@ protocol babel { ipv6 sadr { table v6_main; # Import only /56 location aggregates and default routes - import where (net.len = 56) || (net = ::/0 from {{ freifunk_global_prefix }} ); + import filter { + if ! (net.len = 56 || net = ::/0 from {{ freifunk_global_prefix }}) then reject; +{% for nw in networks | selectattr('role', 'equalto', 'mesh') %} + {# metrics for 2 GHz adhoc get a penalty over 5 GHz adhoc so 5 GHz is preferred #} + {% set default_mesh_metric = hostvars[inventory_hostname].get('mesh_metric_adhoc_' ~ nw.get('mesh_radio'), mesh_metric_default_in) %} + if ifname = "{{ libnetwork.getIfname(nw) }}" then { + babel_metric = babel_metric + {{ nw.get('mesh_metric', default_mesh_metric) }}; + } +{% endfor %} +{% for nw in networks | selectattr('role', 'equalto', 'tunnel') %} + if ifname = "{{ nw.get('ifname') }}" then { + babel_metric = babel_metric + {{ nw.get('mesh_metric', mesh_metric_tunnel_in) }}; + } +{% endfor %} + accept; + }; + export filter { if net = {{ ipv6_prefix }} from ::/0 then accept; if source = RTS_BABEL then accept; @@ -40,19 +56,15 @@ protocol babel { }; # Mesh interfaces -{# metrics for 2 GHz adhoc get a penalty over 5 GHz adhoc so 5 GHz is preferred #} {% for nw in networks | selectattr('role', 'equalto', 'mesh') %} - {% set default_mesh_metric = hostvars[inventory_hostname].get('mesh_metric_adhoc_' ~ nw.get('mesh_radio'), mesh_metric_default_in) %} interface "{{ libnetwork.getIfname(nw) }}" { type wireless; - rxcost {{ nw.get('mesh_metric', default_mesh_metric) }}; }; {% endfor %} # Tunnel interfaces provided by tunspace {% for nw in networks | selectattr('role', 'equalto', 'tunnel') %} interface "{{ nw.get('ifname') }}" { type wireless; - rxcost {{ nw.get('mesh_metric', mesh_metric_tunnel_in) }}; }; {% endfor %} }