From 3f4de1390d6459cdd17dd1b6f22b1a3aec002671 Mon Sep 17 00:00:00 2001
From: Christian Breunig <christian@breunig.cc>
Date: Sat, 8 Apr 2023 22:09:04 +0200
Subject: T5150: initial implementation of new Kernel/Zebra route-map support

It is possible to install a route-map which filters the routes between routing
daemons and the OS kernel (zebra)

As of now this can be done by e.g.
* set protocols ospf route-map foo
* set protocols ospfv3 route-map foo
* set protocols bgp route-map foo

Which in turn will install the following lines into FRR
* ip protocol ospf route-map foo
* ipv6 protocol ospf6 route-map foo
* ip protocol bgp route-map foo

The current state of the VyOS CLI is incomplete as there is no way to:
* Install a filter for BGP IPv6 routes
* Install a filter for static routes
* Install a filter for connected routes

Thus the CLI should be redesigned to close match what FRR does for both the
default and any other VRF

* set system ip protocol ospf route-map foo
* set system ipv6 protocol ospfv3 route-map foo
* set system ip protocol bgp route-map foo
* set system ipv6 protocol bgp route-map foo

The configuration can be migrated accordingly. This commit does not come with
the migrator, it will be comitted later.
---
 data/templates/frr/zebra.route-map.frr.j2 | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 data/templates/frr/zebra.route-map.frr.j2

(limited to 'data')

diff --git a/data/templates/frr/zebra.route-map.frr.j2 b/data/templates/frr/zebra.route-map.frr.j2
new file mode 100644
index 000000000..bd461d904
--- /dev/null
+++ b/data/templates/frr/zebra.route-map.frr.j2
@@ -0,0 +1,21 @@
+!
+{% if vrf is vyos_defined %}
+vrf {{ vrf }}
+{%     if protocol is vyos_defined %}
+{%         for prot, prot_config in protocol.items() %}
+ {{ afi }} protocol {{ protocol }} route-map {{ prot_config.route_map }}
+{%         endfor %}
+{%     endif %}
+ exit-vrf
+!
+{% else %}
+{%     if protocol is vyos_defined %}
+{%         for prot, prot_config in protocol.items() %}
+{%             if prot is vyos_defined('ospfv3') %}
+{%                 set prot = 'ospf6' %}
+{%             endif %}
+{{ afi }} protocol {{ prot }} route-map {{ prot_config.route_map }}
+{%         endfor %}
+{%     endif %}
+{% endif %}
+!
-- 
cgit v1.2.3