bird: function -> filter

This commit is contained in:
jeltz 2022-12-22 12:12:01 +01:00
parent 6773c5e90d
commit ac9947c50f
Signed by: jeltz
GPG key ID: 800882B66C0C3326

View file

@ -116,7 +116,7 @@ protocol ospf v3 ospf6 {
} }
{% endif %} {% endif %}
{% macro bird_filter_function(filter, last) %} {% macro bird_filter(filter, last) %}
{% if filter.as_prepend is defined %} {% if filter.as_prepend is defined %}
{% for _ in range(filter.as_prepend.size) %} {% for _ in range(filter.as_prepend.size) %}
bgp_path.prepend({{ filter.as_prepend.asn }}); bgp_path.prepend({{ filter.as_prepend.asn }});
@ -133,7 +133,7 @@ return {{ filter.accept | ternary("true", "false") }};
{% for session in bird__bgp_sessions %} {% for session in bird__bgp_sessions %}
{% for version in [4, 6] %} {% for version in [4, 6] %}
{% for direction in ["import", "export"] %} {% for direction in ["import", "export"] %}
function bgp{{ version }}_{{ direction }}_{{ session.name }}() { filter bgp{{ version }}_{{ direction }}_{{ session.name }} {
{% for filter in session[direction] %} {% for filter in session[direction] %}
{% if filter.prefix | default([]) %} {% if filter.prefix | default([]) %}
{% set op = {% set op =
@ -149,11 +149,11 @@ function bgp{{ version }}_{{ direction }}_{{ session.name }}() {
| ternary("+", "")) %} | ternary("+", "")) %}
{% if networks %} {% if networks %}
if net {{ op }} [ {{ networks | join(", ") }} ] then { if net {{ op }} [ {{ networks | join(", ") }} ] then {
{{ bird_filter_function(filter) | indent(8) }} {{ bird_filter(filter) | indent(8) }}
} }
{% endif %} {% endif %}
{% else %} {% else %}
{{ bird_filter_function(filter) | indent(4) }} {{ bird_filter(filter) | indent(4) }}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
} }
@ -177,8 +177,8 @@ protocol bgp bgp{{ version }}_{{ session.name }} {
neighbor {{ remote_address }} as {{ session.remote.as }}; neighbor {{ remote_address }} as {{ session.remote.as }};
{{ "ipv4" if version == 4 else "ipv6" }} { {{ "ipv4" if version == 4 else "ipv6" }} {
import where bgp{{ version }}_import_{{ session.name }}(); import filter bgp{{ version }}_import_{{ session.name }};
export where bgp{{ version }}_export_{{ session.name }}(); export filter bgp{{ version }}_export_{{ session.name }};
}; };
} }