Skip to content

Commit

Permalink
Core/Gateway: Babel: add metrics for IPv4
Browse files Browse the repository at this point in the history
  • Loading branch information
spolack committed Dec 2, 2024
1 parent 3469890 commit 78c477c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
16 changes: 15 additions & 1 deletion roles/cfg_openwrt/templates/corerouter/bird.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,21 @@ protocol babel {
};
};
ipv4 {
import all;
import filter {
{% 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 where source = RTS_BABEL; # For now only advertise routes learned from babel
};

Expand Down
15 changes: 14 additions & 1 deletion roles/cfg_openwrt/templates/gateway/bird.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,20 @@ protocol babel babel_mesh {
};
ipv4 {
table v4_main;
import where ifname !~ "gre4-*"; # Drop IPv4 routes learned via GRE, which remains a rather dirty hack for IPv6
import filter {
if ifname ~ "gre4-*" then reject;
{% for interface in mesh_links %}
if ifname = "{{ interface['ifname'] }}" then {
babel_metric = babel_metric + {{ interface.get('mesh_metric', mesh_metric_default_in) }};
accept;
}
{% endfor %}
if ifname ~ "wg_*" then {
babel_metric = babel_metric + {{ mesh_metric_tunnel_in }};
accept;
}
accept;
};
export where source = RTS_BABEL || net = 0.0.0.0/0; # Readvertise Babel routes and advertise default route
};

Expand Down

0 comments on commit 78c477c

Please sign in to comment.