From c0dec8842b6dfb5778b3e91d9ebe6a86e61f12e3 Mon Sep 17 00:00:00 2001 From: Simon Polack Date: Sat, 10 Aug 2024 23:34:35 +0200 Subject: [PATCH] corerouter: implement olsrd-babel ipv4 soft migration --- group_vars/role_corerouter/imageprofile.yml | 2 + .../files/common/iproute2/rt_tables | 20 ++++++++ .../cfg_openwrt/files/corerouter/babeld.conf | 1 + roles/cfg_openwrt/files/corerouter/bird.conf | 47 +++++++++++++++++++ .../files/corerouter/iproute2/rt_tables | 1 + .../templates/common/config/network.j2 | 22 +++++++++ .../templates/corerouter/config/olsrd.j2 | 2 + 7 files changed, 95 insertions(+) create mode 100644 roles/cfg_openwrt/files/common/iproute2/rt_tables create mode 100644 roles/cfg_openwrt/files/corerouter/babeld.conf create mode 100644 roles/cfg_openwrt/files/corerouter/bird.conf create mode 120000 roles/cfg_openwrt/files/corerouter/iproute2/rt_tables diff --git a/group_vars/role_corerouter/imageprofile.yml b/group_vars/role_corerouter/imageprofile.yml index 868111950..65767c205 100644 --- a/group_vars/role_corerouter/imageprofile.yml +++ b/group_vars/role_corerouter/imageprofile.yml @@ -1,5 +1,7 @@ --- role_corerouter__packages__to_merge: + - bird2 + - bird2c - babeld - luci-app-babeld - collectd-mod-dhcpleases diff --git a/roles/cfg_openwrt/files/common/iproute2/rt_tables b/roles/cfg_openwrt/files/common/iproute2/rt_tables new file mode 100644 index 000000000..f2b20ed9a --- /dev/null +++ b/roles/cfg_openwrt/files/common/iproute2/rt_tables @@ -0,0 +1,20 @@ +# +# reserved values +# +128 prelocal +255 local +254 main +253 default + +0 unspec +# +# local +# +#1 inr.ruhep + +10 babel-ff +11 babel-default +12 babel-src +20 olsr-ff +21 olsr-default + diff --git a/roles/cfg_openwrt/files/corerouter/babeld.conf b/roles/cfg_openwrt/files/corerouter/babeld.conf new file mode 100644 index 000000000..9396a788c --- /dev/null +++ b/roles/cfg_openwrt/files/corerouter/babeld.conf @@ -0,0 +1 @@ +export-table 12 diff --git a/roles/cfg_openwrt/files/corerouter/bird.conf b/roles/cfg_openwrt/files/corerouter/bird.conf new file mode 100644 index 000000000..9683d4129 --- /dev/null +++ b/roles/cfg_openwrt/files/corerouter/bird.conf @@ -0,0 +1,47 @@ +log syslog all; +debug protocols all; + +ipv4 table babel_src; +ipv4 table babel_ff; +ipv4 table babel_default; + +protocol device { +} + +protocol kernel { + learn; + kernel table 12; + ipv4 { + table babel_src; + import all; + }; +} + +protocol kernel { + kernel table 10; + ipv4 { + table babel_ff; + export all; + }; +} + +protocol kernel { + kernel table 11; + ipv4 { + table babel_default; + export all; + }; +} + + +protocol pipe { + table babel_src; + peer table babel_ff; + export where net != 0.0.0.0/0; +} + +protocol pipe { + table babel_src; + peer table babel_default; + export where net = 0.0.0.0/0; +} diff --git a/roles/cfg_openwrt/files/corerouter/iproute2/rt_tables b/roles/cfg_openwrt/files/corerouter/iproute2/rt_tables new file mode 120000 index 000000000..c0ed137f3 --- /dev/null +++ b/roles/cfg_openwrt/files/corerouter/iproute2/rt_tables @@ -0,0 +1 @@ +../../common/iproute2/rt_tables \ No newline at end of file diff --git a/roles/cfg_openwrt/templates/common/config/network.j2 b/roles/cfg_openwrt/templates/common/config/network.j2 index 6e94bcd28..4596e834d 100644 --- a/roles/cfg_openwrt/templates/common/config/network.j2 +++ b/roles/cfg_openwrt/templates/common/config/network.j2 @@ -2,6 +2,28 @@ {% set profile = wireless_profiles | selectattr('name', 'equalto', wireless_profile) | list | first %} {% set wifi_networks = profile | json_query('ifaces[].network') | default([], true) %} + +# Babel inserts into seperate route table, add that to lookup list for IPv6 +config rule6 + option priority 33000 + option lookup 'babel-src' + +# IPv4 Soft Migration by priotizing Babel over OLSR +config rule + option priority 33100 + option lookup 'babel-ff' + +config rule + option priority 33101 + option lookup 'olsr-ff' + +config rule + option priority 33200 + option lookup 'babel-default' +config rule + option priority 33201 + option lookup 'olsr-default' + config interface 'loopback' option device 'lo' option proto 'static' diff --git a/roles/cfg_openwrt/templates/corerouter/config/olsrd.j2 b/roles/cfg_openwrt/templates/corerouter/config/olsrd.j2 index 2eb55f6da..f23d0f457 100644 --- a/roles/cfg_openwrt/templates/corerouter/config/olsrd.j2 +++ b/roles/cfg_openwrt/templates/corerouter/config/olsrd.j2 @@ -40,6 +40,8 @@ config olsrd option OlsrPort '698' option Willingness '3' option TosValue '16' + option RtTable '20' + option RtTableDefault '21' config InterfaceDefaults option MidValidityTime '500.0'