Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPv4 Default Route via Babel #1101

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
20 changes: 17 additions & 3 deletions roles/cfg_openwrt/templates/gateway/bird.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ protocol kernel kernel_v6_main {
protocol kernel kernel_v4_main {
ipv4 {
table v4_main;
import none;
import where net = 0.0.0.0/0; # Import Default Gateway from kernel
export none;
};
learn all;
}

protocol kernel kernel_v4_babel_ff {
Expand Down Expand Up @@ -96,8 +97,21 @@ protocol babel babel_mesh {
};
ipv4 {
table v4_main;
import all;
export where source = RTS_BABEL; # For now only advertise routes learned from babel
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
};

# Mesh interfaces
Expand Down
Loading