From 89437816d720711bc806291a68ea1107d4352314 Mon Sep 17 00:00:00 2001 From: Monviech Date: Fri, 22 May 2026 11:19:44 +0200 Subject: [PATCH] Adjust BGP template to only emit a single set for multiple selected items with the same name --- .../templates/OPNsense/Quagga/bgpd.conf | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/net/frr/src/opnsense/service/templates/OPNsense/Quagga/bgpd.conf b/net/frr/src/opnsense/service/templates/OPNsense/Quagga/bgpd.conf index 3b1aa0ecb..11613b2a1 100644 --- a/net/frr/src/opnsense/service/templates/OPNsense/Quagga/bgpd.conf +++ b/net/frr/src/opnsense/service/templates/OPNsense/Quagga/bgpd.conf @@ -280,37 +280,48 @@ bgp community-list {{ communitylist.number }} seq {{ communitylist.seqnumber }} {% for routemap in helpers.sortDictList(OPNsense.quagga.bgp.routemaps.routemap, 'name', 'id' ) %} {% if routemap.enabled == '1' %} route-map {{ routemap.name }} {{ routemap.action }} {{ routemap.id }} +{# XXX: Multiple lists that have the same name can be selected (intentionally), but each is stored as unique item. #} +{# The relationship is a bit loose, unique solves part of this issue. Match, Match2 and Match3 are affected. #} {% if routemap.match|default("") != "" %} +{% set aspath_numbers = [] %} {% for aspath in routemap.match.split(",") %} {% set aspath_data = helpers.getUUID(aspath) %} -{% if 'match' in routemap and routemap.match != '' %} - match as-path {{ aspath_data.number }} -{% endif %} +{% do aspath_numbers.append(aspath_data.number) %} +{% endfor %} +{% for aspath_number in aspath_numbers | unique %} + match as-path {{ aspath_number }} {% endfor %} {% endif %} {% if routemap.set|default("") != '' %} set {{ routemap.set }} {% endif %} {% if routemap.match2|default("") != "" %} +{% set ipv4_prefixlist_names = [] %} +{% set ipv6_prefixlist_names = [] %} {% for prefixlist in routemap.match2.split(",") %} {% set prefixlist_data = helpers.getUUID(prefixlist) %} -{% if 'match2' in routemap and routemap.match2 != '' and ':' in prefixlist_data.network %} - match ipv6 address prefix-list {{ prefixlist_data.name }} +{% if ':' in prefixlist_data.network %} +{% do ipv6_prefixlist_names.append(prefixlist_data.name) %} {% else %} - match ip address prefix-list {{ prefixlist_data.name }} +{% do ipv4_prefixlist_names.append(prefixlist_data.name) %} {% endif %} {% endfor %} +{% for prefixlist_name in ipv4_prefixlist_names | unique %} + match ip address prefix-list {{ prefixlist_name }} +{% endfor %} +{% for prefixlist_name in ipv6_prefixlist_names | unique %} + match ipv6 address prefix-list {{ prefixlist_name }} +{% endfor %} {% endif %} {% if routemap.match3|default("") != "" %} +{% set communitylist_numbers = [] %} {% for communitylist in routemap.match3.split(",") %} {% set communitylist_data = helpers.getUUID(communitylist) %} -{% if 'match3' in routemap and routemap.match3 != '' %} - match community {{ communitylist_data.number }} -{% endif %} +{% do communitylist_numbers.append(communitylist_data.number) %} +{% endfor %} +{% for communitylist_number in communitylist_numbers | unique %} + match community {{ communitylist_number }} {% endfor %} -{% endif %} -{% if routemap.set|default("") != '' and routemap.match2|default("") != '' %} - set {{ routemap.set }} {% endif %} {% endif %} {% endfor %}